-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcomprehensive_test.py
More file actions
88 lines (77 loc) · 2.42 KB
/
comprehensive_test.py
File metadata and controls
88 lines (77 loc) · 2.42 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env python3
"""
Comprehensive test of the jj MCP server
"""
import subprocess
import json
import sys
def send_mcp_request(request):
"""Send a JSON-RPC request to the MCP server"""
try:
result = subprocess.run(
['./target/release/jj-mcp-server'],
input=json.dumps(request),
text=True,
capture_output=True,
timeout=10
)
if result.stdout:
try:
return json.loads(result.stdout)
except json.JSONDecodeError:
print(f"Invalid JSON response: {result.stdout}")
return None
else:
print("No stdout response")
return None
except subprocess.TimeoutExpired:
print("Request timed out")
return None
except Exception as e:
print(f"Error: {e}")
return None
def test_tool(tool_name, arguments):
"""Test a specific tool with arguments"""
print(f"Testing {tool_name} tool...")
request = {
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": tool_name,
"arguments": arguments
}
}
response = send_mcp_request(request)
if response and 'result' in response:
content = response['result']['content'][0]['text']
is_error = response['result'].get('isError', False)
print(f"✓ {tool_name}: {'ERROR' if is_error else 'SUCCESS'}")
print(f" Output: {content[:100]}...")
return not is_error
else:
print(f"✗ {tool_name}: FAILED")
if response:
print(f" Response: {response}")
return False
if __name__ == "__main__":
print("Comprehensive jj MCP Server Test")
print("================================")
tests = [
("status", {}),
("log", {"limit": 3}),
("diff", {"summary": True}),
("new", {"parents": "@"}),
("commit", {"message": "Test commit from MCP server"}),
]
passed = 0
total = len(tests)
for tool_name, args in tests:
if test_tool(tool_name, args):
passed += 1
print()
print(f"Results: {passed}/{total} tests passed")
if passed == total:
print("🎉 All tests passed! The jj MCP server is working correctly.")
else:
print("⚠️ Some tests failed. Check the output above for details.")