Skip to content

Auto-set server.transport in Transport#initialize#305

Open
koic wants to merge 1 commit intomodelcontextprotocol:mainfrom
koic:auto_set_server_transport
Open

Auto-set server.transport in Transport#initialize#305
koic wants to merge 1 commit intomodelcontextprotocol:mainfrom
koic:auto_set_server_transport

Conversation

@koic
Copy link
Copy Markdown
Member

@koic koic commented Apr 8, 2026

Motivation and Context

Transport subclasses (StreamableHTTPTransport, StdioTransport) already receive the server in their constructor, but users must manually call server.transport = transport after creating a transport instance. This is boilerplate that can be eliminated by setting the connection automatically in Transport#initialize.

How Has This Been Tested?

All existing tests pass. Redundant server.transport = transport lines were removed from tests, examples, README.md, and conformance server.

Breaking Changes

None. Existing code that manually sets server.transport = transport continues to work (idempotent assignment).

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

## Motivation and Context

Transport subclasses (StreamableHTTPTransport, StdioTransport) already
receive the server in their constructor, but users must manually call
`server.transport = transport` after creating a transport instance.
This is boilerplate that can be eliminated by setting the connection
automatically in `Transport#initialize`.

## How Has This Been Tested?

All existing tests pass. Redundant `server.transport = transport` lines
were removed from tests, examples, README.md, and conformance server.

## Breaking Changes

None. Existing code that manually sets `server.transport = transport`
continues to work (idempotent assignment).
@koic koic force-pushed the auto_set_server_transport branch from 15979cb to 4f2d056 Compare April 8, 2026 18:58
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