-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathtest_projects_mcp.py
More file actions
executable file
·52 lines (46 loc) · 1.36 KB
/
test_projects_mcp.py
File metadata and controls
executable file
·52 lines (46 loc) · 1.36 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
#!/usr/bin/env python3
"""Test the find_projects MCP tool"""
import json
import subprocess
import sys
# Test request for find_projects tool
test_request = {
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "find_projects",
"arguments": {
"path": ".",
"depth": 3
}
},
"id": 1
}
# Run st with MCP mode and send the request
proc = subprocess.Popen(
["./target/release/st", "--mcp"],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True
)
# Send the request
request_line = json.dumps(test_request) + "\n"
stdout, stderr = proc.communicate(input=request_line)
# Parse and display the response
for line in stdout.strip().split('\n'):
if line:
try:
response = json.loads(line)
if "result" in response:
print("✅ MCP tool find_projects works!")
print(f"Found {response['result'].get('count', 0)} projects")
if "projects" in response['result']:
for proj in response['result']['projects'][:3]:
print(f" - {proj.get('name', 'Unknown')}")
elif "error" in response:
print("❌ Error:", response['error'])
except json.JSONDecodeError:
pass
if stderr:
print("Stderr:", stderr, file=sys.stderr)