Skip to content

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

Merged
koic merged 1 commit intomodelcontextprotocol:mainfrom
koic:auto_set_server_transport
Apr 9, 2026
Merged

Auto-set server.transport in Transport#initialize#305
koic merged 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

@koic koic force-pushed the auto_set_server_transport branch 2 times, most recently from 4f2d056 to 3047f53 Compare April 9, 2026 02:48
## 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 3047f53 to de38804 Compare April 9, 2026 03:09
@koic koic merged commit 89281ca into modelcontextprotocol:main Apr 9, 2026
11 checks passed
@koic koic deleted the auto_set_server_transport branch April 9, 2026 19:51
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