test(mcp): port the slash-worker discovery probe to MCPServer
`tests/tui_gateway/test_slash_worker_mcp_discovery.py` gated on
`pytest.importorskip("mcp.server.fastmcp")` and generated a probe server
that imported `FastMCP`. Since this branch removes that module by pinning
mcp 2.x, the whole file skipped instead of running — and a skip caused by
our own dependency change reads as a pass in a per-file sweep, which is how
it got missed.
The test is real end-to-end coverage of the path this branch migrates: it
spawns an MCP server subprocess, registers it as a profile-local
`mcp_servers` entry, drives `/tools` through the slash worker, and asserts
the prefixed tool name is discovered. Port the probe to
`mcp.server.MCPServer` (`run(transport="stdio")` is unchanged) so it
exercises the migrated client instead of skipping.
The module-level gate now checks for `MCPServer` specifically, so a
FastMCP-era SDK still skips cleanly rather than failing on the 2.x-only
probe.
Verified it now executes rather than skips: 1 passed in 5.37s, versus
"1 skipped in 1.04s" before.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -14,20 +14,29 @@ import threading
|
||||
import pytest
|
||||
import yaml
|
||||
|
||||
pytest.importorskip("mcp.server.fastmcp")
|
||||
_mcp_server_mod = pytest.importorskip("mcp.server")
|
||||
|
||||
if not hasattr(_mcp_server_mod, "MCPServer"):
|
||||
# `mcp.server.MCPServer` replaced `mcp.server.fastmcp.FastMCP` in mcp 2.0.
|
||||
# Skip rather than fail on a FastMCP-era SDK: the probe below is written
|
||||
# against the 2.x API, and the pinned version provides it.
|
||||
pytest.skip(
|
||||
"profile-local MCP discovery probe requires mcp >= 2.0 (MCPServer)",
|
||||
allow_module_level=True,
|
||||
)
|
||||
|
||||
|
||||
def test_profile_local_mcp_tool_is_visible_in_slash_worker(tmp_path):
|
||||
profile_home = tmp_path / "profile-home"
|
||||
profile_home.mkdir()
|
||||
marker = "profile-local-61922"
|
||||
server = tmp_path / "fastmcp_probe.py"
|
||||
server = tmp_path / "mcp_probe.py"
|
||||
server.write_text(
|
||||
textwrap.dedent(
|
||||
f"""
|
||||
from mcp.server.fastmcp import FastMCP
|
||||
from mcp.server import MCPServer
|
||||
|
||||
mcp = FastMCP("profileprobe")
|
||||
mcp = MCPServer("profileprobe")
|
||||
|
||||
@mcp.tool()
|
||||
def hermes_61922_profile_probe() -> str:
|
||||
|
||||
Reference in New Issue
Block a user