comments: support both mcp majors in the MCP server - #292
Merged
Merged
Conversation
mcp 2.x moved mcp.server.fastmcp to mcp.server.mcpserver, renamed FastMCP to MCPServer and Image along with it, and renamed Tool.inputSchema to input_schema. Every one of those is a hard import or attribute error for novem.comments.MCP(), and the extra was pinned to <2 to avoid them. Worse, the failure lied about itself. ModuleNotFoundError is an ImportError, so an installed 2.x was reported as 'The "mcp" extra is required' -- telling the user to install a package they already had. _import_mcp() resolves either spelling, so the pin can open to <3. MCPServer is drop-in for what this module uses: the same positional-name constructor, .tool(), .list_tools() and .run(). The example's call_tool handling also needed widening: v1 returns a list or a (list, dict) tuple, while v2 returns a CallToolResult, which is not subscriptable at all. Nothing installed the extra in CI, which is why this went unnoticed, so the new job runs the compat tests against each major.
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.
mcp 2.x moved
mcp.server.fastmcptomcp.server.mcpserver, renamedFastMCPtoMCPServerand tookImagewith it, and renamedTool.inputSchematoinput_schema. Each is a hard import or attribute error fornovem.comments.MCP(), which is why the extra was pinned to<2. All four confirmed against mcp 2.2.0, not inferred.The failure also lied about itself.
ModuleNotFoundErroris anImportError, so an installed 2.x was reported asThe "mcp" extra is required— telling the user to install a package they already had._import_mcp()resolves either spelling, so the pin opens to<3. That relaxation is only honest becauseMCPServerturned out to be drop-in for everything this module touches — same positional-name constructor,.tool(),.list_tools(),.run()— which I checked before changing the pin rather than after.The example needed widening too: v1's
call_toolreturns a list, or a(list, dict)tuple when the tool declares structured output; v2 returns aCallToolResult, which is not subscriptable at all, so the existingisinstance(result, tuple)guard falls through toresult[0]and raises.Where to spend attention: the pin. Opening it means a fresh
pip install novem[mcp]now resolves to 2.x, so this is the change that alters what users get, and the compat tests are all that stand behind it. If you would rather stay on 1.x for now, keeping<2and taking only the code changes is a coherent half of this PR.Nothing installed the extra in CI, which is why the drift went unnoticed —
uv syncdoes not include it, so the suite stayed green. The new job runs the compat tests against each major; the testsimportorskipso they stay silent for anyone without the extra.To verify:
uv run --with 'mcp>=1,<2' pytest tests/test_mcp_compat.pyand again with'mcp>=2,<3'. Restricting_import_mcpto the v1 module fails four of the five under 2.x.Fixes #265