Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ dependencies = [

[project.optional-dependencies]
mcp = [
"mcp>=1.2.0",
"mcp>=1.2.0,<2",
]
dev = [
"skillspector[mcp]",
Expand Down
5 changes: 5 additions & 0 deletions src/skillspector/mcp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ def build_server(name: str = "skillspector") -> FastMCP:
try:
from mcp.server.fastmcp import FastMCP
except ModuleNotFoundError as exc:
if exc.name != "mcp":
raise ModuleNotFoundError(
"The installed 'mcp' package is incompatible with the SkillSpector "
"MCP server. Reinstall with: pip install 'skillspector[mcp]'"
) from exc
raise ModuleNotFoundError(
"The MCP server requires the optional 'mcp' dependency. "
"Install it with: pip install 'skillspector[mcp]'"
Expand Down
17 changes: 17 additions & 0 deletions tests/unit/test_mcp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,23 @@ async def test_build_server_registers_scan_skill() -> None:
assert "scan_skill" in {tool.name for tool in tools}


def test_build_server_reports_incompatible_mcp(monkeypatch: pytest.MonkeyPatch) -> None:
"""An installed package without FastMCP must not be reported as missing."""
import builtins

original_import = builtins.__import__

def import_without_fastmcp(name: str, *args: object, **kwargs: object) -> object:
if name == "mcp.server.fastmcp":
raise ModuleNotFoundError("No module named 'mcp.server.fastmcp'", name=name)
return original_import(name, *args, **kwargs)

monkeypatch.setattr(builtins, "__import__", import_without_fastmcp)

with pytest.raises(ModuleNotFoundError, match="installed 'mcp' package is incompatible"):
mcp_server.build_server()


async def test_mcp_stdio_initialize_registers_scan_skill() -> None:
"""The real stdio CLI must initialize and expose the scan_skill tool."""
pytest.importorskip("mcp")
Expand Down
4 changes: 2 additions & 2 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.