-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsmoke.py
More file actions
67 lines (56 loc) · 1.86 KB
/
Copy pathsmoke.py
File metadata and controls
67 lines (56 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
"""Launches the FinMind MCP server as a subprocess, sends initialize +
tools/list over stdio, and asserts exactly 4 tools are registered.
Usage:
uv run python smoke.py
"""
import asyncio
import json
import os
import sys
async def main() -> None:
proc = await asyncio.create_subprocess_exec(
sys.executable,
"-m",
"finmind_mcp.server",
stdin=asyncio.subprocess.PIPE,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
env={**os.environ, "FINMIND_TOKEN": "smoke-test"},
)
assert proc.stdin is not None and proc.stdout is not None
async def send(msg: dict) -> None:
proc.stdin.write((json.dumps(msg) + "\n").encode())
await proc.stdin.drain()
async def recv() -> dict:
line = await proc.stdout.readline()
if not line:
stderr = await proc.stderr.read()
raise RuntimeError(
f"server closed stdout. stderr=\n{stderr.decode(errors='replace')}"
)
return json.loads(line)
await send(
{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"protocolVersion": "2024-11-05",
"capabilities": {},
"clientInfo": {"name": "smoke", "version": "0"},
},
}
)
init_resp = await recv()
assert "result" in init_resp, init_resp
await send({"jsonrpc": "2.0", "method": "notifications/initialized"})
await send({"jsonrpc": "2.0", "id": 2, "method": "tools/list"})
tools_resp = await recv()
tools_list = tools_resp["result"]["tools"]
names = [t["name"] for t in tools_list]
print("tools:", names)
assert len(tools_list) == 4, f"expected 4, got {len(tools_list)}: {names}"
proc.terminate()
await proc.wait()
print("SMOKE OK")
asyncio.run(main())