Skip to content

fix(fetch): port to mcp SDK v2 - #4565

Open
jayzuccarelli wants to merge 1 commit into
modelcontextprotocol:mainfrom
jayzuccarelli:fetch-mcp-v2
Open

fix(fetch): port to mcp SDK v2#4565
jayzuccarelli wants to merge 1 commit into
modelcontextprotocol:mainfrom
jayzuccarelli:fetch-mcp-v2

Conversation

@jayzuccarelli

Copy link
Copy Markdown

Fixes #4560

mcp 2.0.0 is more than the McpError -> MCPError rename: the low-level
Server decorator API is gone, replaced by constructor callbacks with new
handler signatures and result-object returns, and MCPError now takes
code/message directly instead of ErrorData. So the server can't be
fixed with an alias import - it needs a port.

This ports src/fetch to the v2 API:

  • handlers move to on_list_tools / on_call_tool / on_list_prompts /
    on_get_prompt, returning ListToolsResult / CallToolResult /
    ListPromptsResult / GetPromptResult
  • raise MCPError(code=..., message=...) at the existing raise sites,
    message text unchanged
  • mcp>=2,<3 in pyproject, uv.lock regenerated
  • tests updated for the exception rename

Tool/prompt descriptions, robots.txt handling and truncation behavior are
unchanged. #4563 caps mcp<2 as immediate triage; this is the follow-up
that 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

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
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.

fetch: ImportError on startup with mcp SDK 2.0.0 (McpError renamed to MCPError)

1 participant