feat(mcp): add preset setup and capability mentions

This commit is contained in:
Xubin Ren
2026-05-24 19:43:20 +08:00
parent 8be258212e
commit 704ac558f6
54 changed files with 8425 additions and 708 deletions
+34 -1
View File
@@ -52,10 +52,17 @@ def _fake_mcp_module(
)
class _FakeStdioServerParameters:
def __init__(self, command: str, args: list[str], env: dict | None = None) -> None:
def __init__(
self,
command: str,
args: list[str],
env: dict | None = None,
cwd: str | None = None,
) -> None:
self.command = command
self.args = args
self.env = env
self.cwd = cwd
class _FakeClientSession:
def __init__(self, _read: object, _write: object) -> None:
@@ -561,6 +568,32 @@ async def test_connect_mcp_servers_wraps_windows_stdio_launchers(
assert captured["env"] is None
@pytest.mark.asyncio
async def test_connect_mcp_servers_passes_stdio_cwd(
fake_mcp_runtime: dict[str, object | None],
monkeypatch: pytest.MonkeyPatch,
) -> None:
fake_mcp_runtime["session"] = _make_fake_session(["demo"])
captured: dict[str, object] = {}
@asynccontextmanager
async def _capturing_stdio_client(params: object):
captured["cwd"] = params.cwd
yield object(), object()
monkeypatch.setattr(sys.modules["mcp.client.stdio"], "stdio_client", _capturing_stdio_client)
registry = ToolRegistry()
stacks = await connect_mcp_servers(
{"test": MCPServerConfig(command="fake", cwd="/tmp/nanobot-mcp-test")},
registry,
)
for stack in stacks.values():
await stack.aclose()
assert captured["cwd"] == "/tmp/nanobot-mcp-test"
# ---------------------------------------------------------------------------
# MCPResourceWrapper tests
# ---------------------------------------------------------------------------