Skip to content

add type field to client session config BaseModels #1127

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 1 commit into
base: main
Choose a base branch
from

Conversation

bfineran
Copy link

@bfineran bfineran commented Jul 11, 2025

Adds a pre-set type field to SseServerParameters, StreamableHttpParameters, and StdioServerParameters so serialized parameters will easily be loaded into the correct class.

Motivation and Context

All fields of SseServerParameters overlap with StreamableHttpParameters, so a third party application that would want to connect to multiple session with a config such as:

class ClientConfig(BaseModel):
    mcp_configs: List[Union[StreamableHttpParameters, SseServerParameters]]

would not have a way to be instantiated from a serialized config (like a yaml file) since the following is ambiguous.

mcp_configs:
  - url: ""

Additionally, if someone were to serialize either the sse or http config classes they would not be able to reload the second class listed in the union.

Adding the preset type field should fix this in a backwards compatible way.

How Has This Been Tested?

Existing tests cover backwards compatibility, confirmed this PR addresses the described use case

Breaking Changes

No, added fields include the only valid Literal default.

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

@bfineran bfineran force-pushed the session-config-type-field branch from e455823 to 55cf14d Compare July 11, 2025 18:59
@bfineran bfineran force-pushed the session-config-type-field branch from 7119405 to cae5231 Compare July 11, 2025 19:21
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.

1 participant