Skip to content

fix(fetch): cap mcp dependency below 2.0 - #4611

Open
guptaishaan wants to merge 1 commit into
modelcontextprotocol:mainfrom
guptaishaan:fix-4600
Open

fix(fetch): cap mcp dependency below 2.0#4611
guptaishaan wants to merge 1 commit into
modelcontextprotocol:mainfrom
guptaishaan:fix-4600

Conversation

@guptaishaan

Copy link
Copy Markdown

Fixes #4600

mcp>=1.1.3 has no upper bound, so a fresh uvx mcp-server-fetch now resolves mcp 2.0.0, which renamed McpError to MCPError and dropped the low-level Server decorators. server.py dies on the import at line 6 before writing anything to stdout, which the client sees as connection closed: initialize response.

This caps the requirement at mcp>=1.1.3,<2 and updates uv.lock to match. The lock already pinned mcp 1.28.1, so CI never saw this; only fresh resolves are affected.

I did not port fetch to mcp 2.0. It is not just the exception rename: list_tools, list_prompts, call_tool, and get_prompt are all gone from the low-level Server, and server.py uses all four. That is a migration, not a bug fix.

Verified on Linux, Python 3.12, uv 0.12.0, with a real JSON-RPC stdio handshake:

  • published mcp-server-fetch==2026.7.10: no initialize response, ImportError: cannot import name 'McpError'
  • wheel built from this branch: resolves mcp==1.29.0, initialize ok: server=mcp-fetch version=1.29.0, tools=['fetch']

Added tests/test_dependencies.py, which fails on the old specifier and passes on the new one. ruff check and pyright are clean. tests/test_server.py::test_empty_content_returns_error fails on my machine both with and without this patch, because there is no Node.js on PATH and readabilipy falls back to pure-Python mode. Unrelated to this change.

Not verified: I reproduced with my own stdio client, not with Codex, and the "after" run used a locally built wheel rather than a published one.

Two things for you to decide. First, src/git and src/time have the same unbounded range and break the same way under mcp 2.0.0 (mcp-server-time on the same McpError import, mcp-server-git on 'Server' object has no attribute 'list_tools'). I left them out to keep this scoped to the reported issue, happy to add the same one-line cap to both. Second, if you would rather port to mcp 2.0 than cap, close this.

Thanks to @tking007 for the report, including the correct diagnosis and the --with "mcp<2" workaround.

mcp>=1.1.3 had no upper bound, so a fresh `uvx mcp-server-fetch`
resolved mcp 2.0.0. That release renamed McpError to MCPError and
removed the low-level Server decorators, so server.py raised
ImportError at line 6 and exited before writing an initialize
response. Clients reported "connection closed: initialize response".

Cap the requirement at mcp>=1.1.3,<2 and refresh uv.lock to match. The
lock already pinned mcp 1.28.1, so CI was unaffected; only fresh
resolves broke.

Not a port to mcp 2.0: list_tools, list_prompts, call_tool, and
get_prompt are all gone from the low-level Server and server.py uses
all four.

Verified with a real stdio handshake on Python 3.12. The published
2026.7.10 returns no initialize response; a wheel built from this
change resolves mcp 1.29.0 and answers tools/list with ['fetch'].
tests/test_dependencies.py covers the specifier.
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.

MCP client for fetch failed to start

1 participant