Skip to content

types: Setting default value for method: Literal #1292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sreenaths
Copy link
Contributor

method fields are literals that enforce a specific value. As the value is not set by default, we have to pass the correct value every time a model is instantiated.

Motivation and Context

This change simplifies model instantiation, as the method would be automatically set.
For example

    initialize_request = InitializeRequest(
        # method="initialize", - This wouldn't be required
        params=InitializeRequestParams(
            ...
        )
    )

How Has This Been Tested?

Existing tests work as expected, and a new test was added.

Breaking Changes

No

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

None

@sreenaths sreenaths requested a review from a team as a code owner August 21, 2025 22:07
@sreenaths sreenaths requested a review from Kludex August 21, 2025 22:07
Copy link

@ochafik ochafik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @sreenaths, thanks for your PR!

I think this makes sense, could you please also remove the now-redundant method ctor args throughout the SDK? (mostly in {client,server}/session.py and tests)

@sreenaths
Copy link
Contributor Author

Hi @ochafik,
Thank you so much for the review.
I have updated the PR to remove redundant method args.

@sreenaths sreenaths requested a review from ochafik August 22, 2025 22:53
@sreenaths sreenaths force-pushed the setting-default-method branch from 1657a51 to 8e0fe0a Compare August 22, 2025 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants