-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_server.py
More file actions
74 lines (58 loc) · 2.03 KB
/
test_server.py
File metadata and controls
74 lines (58 loc) · 2.03 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
68
69
70
71
72
73
74
#!/usr/bin/env python3
"""
Test du serveur Francis.
Simule les requêtes MCP pour vérifier que ça marche.
"""
import subprocess
import json
def send_request(proc, method: str, params: dict = None, req_id: int = 1):
"""Envoie une requête JSON-RPC et récupère la réponse."""
request = {
"jsonrpc": "2.0",
"id": req_id,
"method": method,
}
if params:
request["params"] = params
proc.stdin.write(json.dumps(request) + "\n")
proc.stdin.flush()
response = proc.stdout.readline()
return json.loads(response)
def main():
# Lance le serveur
proc = subprocess.Popen(
["python", "server.py"],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
bufsize=1,
)
print("=== Test Francis MCP Server ===\n")
# Test 1: Initialize
print("1. Initialize...")
resp = send_request(proc, "initialize", {}, 1)
print(f" Server: {resp['result']['serverInfo']['name']} v{resp['result']['serverInfo']['version']}")
# Test 2: List tools
print("\n2. List tools...")
resp = send_request(proc, "tools/list", {}, 2)
tools = resp['result']['tools']
for tool in tools:
print(f" - {tool['name']}: {tool['description']}")
# Test 3: Call ping
print("\n3. Call ping...")
resp = send_request(proc, "tools/call", {"name": "ping", "arguments": {}}, 3)
print(f" Result: {resp['result']['content'][0]['text']}")
# Test 4: Call echo
print("\n4. Call echo...")
resp = send_request(proc, "tools/call", {"name": "echo", "arguments": {"message": "Hello World!"}}, 4)
print(f" Result: {resp['result']['content'][0]['text']}")
# Test 5: Call stm32_info
print("\n5. Call stm32_info...")
resp = send_request(proc, "tools/call", {"name": "stm32_info", "arguments": {"mcu": "STM32F411RE"}}, 5)
print(f" Result: {resp['result']['content'][0]['text']}")
# Cleanup
proc.terminate()
print("\n=== Tests OK ===")
if __name__ == "__main__":
main()