41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
from __future__ import annotations
|
|
|
|
import anyio
|
|
import os
|
|
from pathlib import Path
|
|
|
|
from mcp import ClientSession, StdioServerParameters
|
|
from mcp.client.stdio import stdio_client
|
|
|
|
|
|
REPO_ROOT = Path(__file__).resolve().parent.parent
|
|
|
|
|
|
async def main() -> None:
|
|
server_params = StdioServerParameters(
|
|
command=str(REPO_ROOT / ".venv-mcp" / "bin" / "python"),
|
|
args=[str(REPO_ROOT / "mcp_server.py")],
|
|
cwd=str(REPO_ROOT),
|
|
env={
|
|
**os.environ,
|
|
"M2PACK_BINARY": os.environ.get("M2PACK_BINARY", str(REPO_ROOT / "build" / "m2pack")),
|
|
},
|
|
)
|
|
|
|
async with stdio_client(server_params) as (read_stream, write_stream):
|
|
async with ClientSession(read_stream, write_stream) as session:
|
|
await session.initialize()
|
|
tools = await session.list_tools()
|
|
binary_info = await session.call_tool("pack_binary_info", {})
|
|
print({
|
|
"ok": True,
|
|
"tool_count": len(tools.tools),
|
|
"tool_names": [tool.name for tool in tools.tools],
|
|
"binary_info": getattr(binary_info, "structuredContent", None),
|
|
})
|
|
|
|
|
|
if __name__ == "__main__":
|
|
anyio.run(main)
|