fix(fetch): port to mcp SDK v2 - #4565
Open
jayzuccarelli wants to merge 1 commit into
Open
Conversation
mcp 2.0.0 renamed McpError to MCPError and replaced the low-level decorator API with constructor callbacks, so the server failed at import with an unbounded mcp>=1.1.3 pin. Port the handlers to the v2 API (on_list_tools/on_call_tool/on_list_prompts/on_get_prompt, result objects, snake_case fields), raise MCPError directly instead of wrapping ErrorData, pin mcp>=2,<3, and refresh uv.lock. Fixes modelcontextprotocol#4560
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4560
mcp 2.0.0 is more than the
McpError->MCPErrorrename: the low-levelServerdecorator API is gone, replaced by constructor callbacks with newhandler signatures and result-object returns, and
MCPErrornow takescode/messagedirectly instead ofErrorData. So the server can't befixed with an alias import - it needs a port.
This ports src/fetch to the v2 API:
on_list_tools/on_call_tool/on_list_prompts/on_get_prompt, returningListToolsResult/CallToolResult/ListPromptsResult/GetPromptResultraise MCPError(code=..., message=...)at the existing raise sites,message text unchanged
mcp>=2,<3in pyproject, uv.lock regeneratedTool/prompt descriptions, robots.txt handling and truncation behavior are
unchanged. #4563 caps
mcp<2as immediate triage; this is the follow-upthat moves fetch onto the new SDK, same shape as #4564 does for src/git.
Verified against mcp 2.0.0:
uv run pytest(20 passed),uv run --frozen pyright(clean), and a live stdio session (initialize, tools/list,tools/call, prompts/get, plus MCPError propagation on invalid params).
🤖 Generated with Claude Code