Skip to content

feat: expose negotiated protocol version on stdio transports#1660

Open
rechedev9 wants to merge 2 commits intomodelcontextprotocol:mainfrom
rechedev9:feat/stdio-protocol-version-1468
Open

feat: expose negotiated protocol version on stdio transports#1660
rechedev9 wants to merge 2 commits intomodelcontextprotocol:mainfrom
rechedev9:feat/stdio-protocol-version-1468

Conversation

@rechedev9
Copy link

Summary

Closes #1468

  • Adds setProtocolVersion(version: string): void and protocolVersion getter to StdioServerTransport and StdioClientTransport
  • Client already calls transport.setProtocolVersion() after the initialize handshake — StdioClientTransport now stores and exposes that value
  • Server._oninitialize() now calls transport.setProtocolVersion?.() so StdioServerTransport is also populated after the handshake — matching behaviour for HTTP transports

Previously the negotiated MCP protocol version was only observable on HTTP-based transports (where it is needed for request headers). After this change it is accessible on stdio transports too, which is useful for debugging clients/servers and for tools like mcpc.

Test plan

  • Unit test in packages/server/test/server/stdio.test.ts — verifies StdioServerTransport.protocolVersion getter
  • Unit test in packages/client/test/client/stdio.test.ts — verifies StdioClientTransport.protocolVersion getter
  • Integration test in test/integration/test/issues/test1468.stdio-protocol-version.test.ts — verifies that both client and server transports have setProtocolVersion called with LATEST_PROTOCOL_VERSION after a full MCP handshake
  • pnpm typecheck:all passes
  • pnpm lint:fix:all passes

Add setProtocolVersion() method and protocolVersion getter to both
StdioServerTransport and StdioClientTransport, so callers can inspect
the MCP protocol version negotiated during the initialize handshake.

- Client already calls transport.setProtocolVersion() after handshake,
  so StdioClientTransport now surfaces that value.
- Server._oninitialize() now calls transport.setProtocolVersion?() so
  StdioServerTransport is populated on the server side as well.

Closes modelcontextprotocol#1468
@rechedev9 rechedev9 requested a review from a team as a code owner March 11, 2026 18:08
@changeset-bot
Copy link

changeset-bot bot commented Mar 11, 2026

🦋 Changeset detected

Latest commit: 1c1cc4e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@modelcontextprotocol/server Patch
@modelcontextprotocol/client Patch
@modelcontextprotocol/express Patch
@modelcontextprotocol/hono Patch
@modelcontextprotocol/node Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 11, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/client@1660

@modelcontextprotocol/server

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/server@1660

@modelcontextprotocol/express

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/express@1660

@modelcontextprotocol/hono

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/hono@1660

@modelcontextprotocol/node

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/node@1660

commit: d0a5854

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.

Implement StdioServerTransport.setProtocolVersion to save protocol version for stdio transport

1 participant