fix(fetch): cap mcp dependency below 2.0 - #4563
Open
guptaishaan wants to merge 1 commit into
Open
Conversation
mcp 2.0.0 renamed McpError to MCPError, so server.py:6 raises ImportError at module import and the server exits before the initialize handshake. The dependency was declared as mcp>=1.1.3 with no upper bound, so unpinned launchers such as uvx resolve 2.0.0 and every fresh install breaks. Cap the requirement at mcp>=1.1.3,<2 and regenerate uv.lock. Resolution is unchanged at mcp 1.23.0, only the recorded specifier moves. No alias import, because 2.0.0 also changed the constructor from McpError(ErrorData(code=..., message=...)) to MCPError(code, message, data=None). Importing MCPError under the old name would import cleanly and then mis-construct all 8 call sites, replacing a loud startup crash with quiet runtime breakage. The 2.x migration belongs on v2/main. Add a regression test that parses pyproject.toml and asserts the declared mcp specifier does not admit 2.0.0. It fails on the unbounded specifier and passes with the cap. Verified by reproducing the exact traceback against mcp==2.0.0, then confirming a fresh unpinned install resolves mcp 1.29.0 and completes a real stdio initialize handshake with exit 0.
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
mcp2.0.0 renamedMcpErrortoMCPError, soserver.py:6raisesImportErroratmodule import and the process exits before the initialize handshake.
src/fetchdeclaredmcp>=1.1.3with no upper bound, so unpinned launchers likeuvxstarted resolving 2.0.0as soon as it shipped.
This caps the dependency at
mcp>=1.1.3,<2and regeneratesuv.lock. Resolution isunchanged at mcp 1.23.0, only the recorded specifier moves.
I deliberately did not add an alias import. In 2.0.0 the constructor changed too, from
McpError(ErrorData(code=..., message=...))toMCPError(code, message, data=None), soimporting
MCPErrorunder the old name would import cleanly and then mis-construct all 8call sites. That trades a loud startup crash for quiet runtime breakage. The real 2.x
migration is a separate job for
v2/mainper #4475.Also adds a regression test that parses
pyproject.tomland asserts the declaredmcpspecifier does not admit 2.0.0. It fails on the unbounded specifier and passes with the
cap. It needs no new dev dependency,
packagingalready comes in with pytest, andtomllibis fine because CI reads.python-version, which is 3.11 here.Verified on Linux, Python 3.11 and 3.12:
mcp==2.0.0, sameline, same
Did you mean: 'MCPError'?.initializehandshake returnsserverInfomcp-fetch 1.29.0with exit 0 and emptystderr. That matches what the reporter saw with the
uvx --with "mcp<2"workaround.ruff checkandpyrightclean.uv lock --checkanduv sync --frozenclean.Not verified: Windows 11 / uv 0.11.8, the reporter's exact environment, and the literal
uvx mcp-server-fetchagainst a published release rather than a local fresh resolve.Nothing in the change is platform-sensitive. This patch does not make fetch work on mcp
2.x, it only stops 2.x from being selected.
Unrelated pre-existing failure, present before this change and left alone:
test_empty_content_returns_errorfails when Node.js is absent, becausereadabilipyfalls back to pure-Python mode.
Separately, and not changed here since this issue is scoped to fetch:
src/git(
mcp>=1.0.0) andsrc/time(mcp>=1.23.0) are also unbounded and exposed to the sameresolution.
Thanks to @Jason26214 for the report, which included the root cause, the exact traceback,
and a working
uvx --with "mcp<2"workaround.