From d3b6b821517008ef26b4f3e20a8ecc322fe8ab23 Mon Sep 17 00:00:00 2001 From: Petru Conduraru Date: Wed, 29 Jul 2026 12:10:28 +0300 Subject: [PATCH] ifcmcp: pin mcp below 2.0 to fix broken FastMCP import mcp 2.0.0 (unpinned in CI and in the ifcmcp[mcp] extra) renamed mcp.server.fastmcp.FastMCP to mcp.server.mcpserver.MCPServer, which ifcmcp does not support yet. server.py caught the resulting ModuleNotFoundError with a bare except Exception and silently reported it as FastMCP not installed, masking the real breakage until the ifcmcp test suite failed in CI. Pinned mcp to >=1.0,<2 in both ci.yml and ifcmcp's pyproject.toml mcp extra, confirmed the full ifcmcp test suite (70 tests) passes against mcp 1.29.0, and confirmed the genuinely-not-installed path still raises the expected ImportError. Also narrowed the except clause to ImportError only so an unrelated future bug in that import block surfaces instead of being swallowed as "not installed". Generated with the assistance of an AI coding tool. --- .github/workflows/ci.yml | 4 +++- src/ifcmcp/ifcmcp/server.py | 2 +- src/ifcmcp/pyproject.toml | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c6cdd9b1a7..a31f29d508 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -263,7 +263,9 @@ jobs: cd ../ifcquery && make test || ERROR=1 pip install -e ../ifcedit --no-deps cd ../ifcedit && make test || ERROR=1 - pip install mcp + # Pinned <2: mcp 2.0.0 renamed mcp.server.fastmcp.FastMCP to + # mcp.server.mcpserver.MCPServer, which ifcmcp doesn't support yet. + pip install "mcp>=1.0,<2" pip install -e ../ifcmcp --no-deps cd ../ifcmcp && make test || ERROR=1 pip install -e ../ifctester --no-deps diff --git a/src/ifcmcp/ifcmcp/server.py b/src/ifcmcp/ifcmcp/server.py index 08ba86a2cb..202333b2ac 100644 --- a/src/ifcmcp/ifcmcp/server.py +++ b/src/ifcmcp/ifcmcp/server.py @@ -9,7 +9,7 @@ from ifcmcp.core import IfcSession try: from mcp.server.fastmcp import FastMCP # type: ignore from mcp.types import ImageContent # type: ignore -except Exception: # pragma: no cover +except ImportError: # pragma: no cover FastMCP = None # type: ignore ImageContent = None # type: ignore diff --git a/src/ifcmcp/pyproject.toml b/src/ifcmcp/pyproject.toml index 295954d0c5..2463e5a5cf 100644 --- a/src/ifcmcp/pyproject.toml +++ b/src/ifcmcp/pyproject.toml @@ -18,7 +18,9 @@ classifiers = [ dependencies = ["ifcopenshell", "ifcquery", "ifcedit"] [project.optional-dependencies] -mcp = ["mcp"] +# Pinned <2: mcp 2.0.0 renamed mcp.server.fastmcp.FastMCP to +# mcp.server.mcpserver.MCPServer, which this package doesn't support yet. +mcp = ["mcp>=1.0,<2"] [project.scripts] ifcmcp = "ifcmcp.__main__:main"