Skip to content

feat(docker): migrate mcp_bridge to the mcp v2 low-level API - #2149

Open
weike-zhang wants to merge 2 commits into
unclecode:developfrom
weike-zhang:feat/mcp-v2-migration
Open

feat(docker): migrate mcp_bridge to the mcp v2 low-level API#2149
weike-zhang wants to merge 2 commits into
unclecode:developfrom
weike-zhang:feat/mcp-v2-migration

Conversation

@weike-zhang

Copy link
Copy Markdown

Part of #2147 (mcp 2.0.0 broke the docker server). Supersedes the mcp<2 cap from #2148 by migrating the code forward instead of pinning.

What changed

deploy/docker/mcp_bridge.py was using the mcp v1 low-level API:

  • Server.list_tools() / call_tool() / list_resources() / read_resource() / list_resource_templates() decorators — removed in mcp 2.0.0
  • Server.run() talking raw JSONRPCMessage frames over the WS transport

v2 migration

  • Handlers are now registered through the Server constructor: on_list_tools, on_call_tool, on_list_resources, on_read_resource, on_list_resource_templates. Each handler receives (ctx, params); params.name/params.arguments and params.uri map 1:1 to the old name/arguments/name arguments.
  • Handlers return the v2 result models (ListToolsResult, CallToolResult, ReadResourceResult, ...) instead of bare lists.
  • Data builders (_tools_data, _resources_data, _templates_data) extracted so the /mcp/schema endpoint no longer needs to invoke MCP handlers directly.
  • WS transport wraps inbound frames in SessionMessage(message=...) and unwraps outbound SessionMessage.message (v2 Server.run no longer accepts raw JSONRPCMessage).
  • deploy/docker/requirements.txt: mcp>=1.18.0mcp>=2.0.0.

Verification (against mcp==2.0.0)

  • SSE /mcp/sse handshake + tools/list + tools/call (through the loopback HTTP proxy + AuthGate service token) + /mcp/schema all pass.
  • Raw WS /mcp/ws client: initialize, tools/list, tools/call all respond correctly (previously the server closed the socket with no response).

If this merges, #2148's <2 pin is no longer needed.

@weike-zhang
weike-zhang force-pushed the feat/mcp-v2-migration branch from 61fbbc7 to 40a1e87 Compare August 20, 2026 05:21
mcp 2.0.0 replaced the v1 decorator-based Server registration with
constructor-based on_* handlers, and Server.run now speaks
SessionMessage envelopes instead of raw JSONRPCMessage.

- register on_list_tools/on_call_tool/on_list_resources/on_read_resource/
  on_list_resource_templates via the Server constructor
- wrap WS frames in SessionMessage and unwrap replies
- require mcp>=2.0.0 (supersedes the mcp<2 cap from unclecode#2148)
@weike-zhang
weike-zhang force-pushed the feat/mcp-v2-migration branch from 40a1e87 to 36e5e5c Compare August 20, 2026 05:23
mcp 2.0.0 requires sse-starlette>=3.0.0, which conflicts with the pinned
==2.2.1. Loosen the pin so the mcp v2 migration resolves cleanly.
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