Skip to content

mcp: wire server and toolLookup on StreamableServerTransport in Server.Connect - #1536

Closed
tang-ontheway wants to merge 1 commit into
modelcontextprotocol:mainfrom
tang-ontheway:fix/streamable-server-connect-custom-methods
Closed

tang-ontheway wants to merge 1 commit into
modelcontextprotocol:mainfrom
tang-ontheway:fix/streamable-server-connect-custom-methods

Conversation

@tang-ontheway

Copy link
Copy Markdown

Fixes #1506

Root Cause

StreamableServerTransport's POST handler looks up custom methods registered via AddReceivingCustomMethod on c.server (falling back to standard-only serverMethodInfos when c.server is nil). Previously, transport.connection.server and transport.connection.toolLookup were only assigned inside connectStreamable (mcp/streamable.go), so calling Server.Connect directly with a *StreamableServerTransport left c.server == nil and rejected custom methods with HTTP 400 (unsupported).

Changes

  • In Server.Connect (mcp/server.go), wire st.connection.server = s and st.connection.toolLookup = s.getServerTool whenever t is a *StreamableServerTransport with a non-nil connection.
  • Added unit test TestStreamableServerTransport_ServerConnectCustomMethod in mcp/streamable_test.go.

Verification

  • go test ./mcp -run TestStreamableServerTransport_ServerConnectCustomMethod -v: PASS (0.699s).

@github-actions github-actions Bot added the missing-issue-link Auto-closed: PR needs a linked issue assigned to its author (see CONTRIBUTING.md) label Nov 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR has been closed automatically. This repo only keeps pull requests open when they come from a maintainer, or from a contributor a maintainer has assigned to the linked issue, and you aren't currently assigned to #1506.

You're welcome to keep pushing commits here (just avoid force-pushing, since GitHub can't reopen a rewritten branch), but that on its own won't get the PR reviewed or the issue assigned. There's no need to open a new PR either way.

Maintainers: reopen, remove missing-issue-link, or add bypass-issue-check to override.

@github-actions github-actions Bot closed this Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

missing-issue-link Auto-closed: PR needs a linked issue assigned to its author (see CONTRIBUTING.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mcp: custom methods rejected on a StreamableServerTransport connected with Server.Connect

1 participant