Skip to content

Under mcp 2.x, netspec discards the migration message and blames a missing extra #35

Description

@CameronBrooks11

PR #33 widens mcp to <3. That pulls 2.x, where mcp.server.fastmcp no longer exists. The typecheck catches it, but the runtime behaviour is the defect worth fixing, and it is §2.1's failure mode in our own error handling.

Reproduced

Fresh venv, mcp>=2,<3 resolving to 2.1.1, with kicad-netspec installed from this working tree:

$ python -c "import mcp.server.fastmcp"
ModuleNotFoundError: No module named 'mcp.server.fastmcp'. This is mcp 2.x, where
FastMCP was renamed to MCPServer (from mcp.server.mcpserver import MCPServer) and
other APIs changed; see the migration guide at
https://py.sdk.modelcontextprotocol.io/v2/migration/#fastmcp-renamed-to-mcpserver
or pin 'mcp<2' to keep running v1 code.

Upstream could hardly be more helpful: it names the rename, the new import path, the guide, and the escape hatch.

Now netspec:

$ netspec-mcp
netspec-mcp needs the mcp extra: pip install 'kicad-netspec[mcp]'
$ echo $?
4

The extra is installed. mcp.py:212 catches ImportError — and ModuleNotFoundError is a subclass — so the precise upstream diagnosis is discarded and replaced with a confident statement of the wrong cause. The user is told to install something they already have.

Exit 4 is arguably the right outcome: netspec could not tell you about your board. The reason is fabricated, which is the thing §2.3 forbids — a plausible substitute for an answer we did not have.

Correcting my own earlier note

I wrote on #33 that netspec "raises a deliberate error naming that migration, and it fired correctly on its first real occasion." That was wrong twice: the handler is not deliberate about the rename, and it does not name it. What actually fires is pyright, in the Check job:

src/kicad_netspec/mcp.py:36:36 - error: "FastMCP" is unknown import symbol
src/kicad_netspec/mcp.py:113:36 - error: "FastMCP" is unknown import symbol

The typecheck is the only thing that reports the truth, and it only runs in CI. A user on mcp 2.x gets the misleading message.

Two separable pieces of work

1. Stop discarding the cause. An ImportError whose module is mcp.* is not evidence that the extra is missing. Distinguish "the package is absent" from "the package is present and the symbol moved", and when it is the latter, print what upstream said rather than a guess. This is worth doing regardless of when the migration happens, and it is small.

2. The migration itself. from mcp.server.fastmcp import FastMCP becomes from mcp.server.mcpserver import MCPServer (mcp.server.MCPServer also resolves on 2.1.1). Whether the rest of the API netspec uses moved as well is unestablished — I checked the import, not the surface — so the guide is the starting point, not this issue.

Keeping mcp<2 is a legitimate answer to (2) and no answer at all to (1).

Done when

  • with mcp 2.x installed, netspec-mcp reports the actual cause; a test pins the two cases apart, with the absent-package case still saying to install the extra
  • either the migration lands, or the pin stays and the reason is recorded where the pin is
  • just check is green against whichever mcp the lock resolves

Refs #33.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    silence-defectSilence read as success. Add the case to https://heibench.com/silence.html

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions