-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathclaude_desktop_diagnostic.py
More file actions
executable file
·140 lines (119 loc) · 5.84 KB
/
claude_desktop_diagnostic.py
File metadata and controls
executable file
·140 lines (119 loc) · 5.84 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/usr/bin/env python3
"""
Claude Desktop specific diagnostic for MCP servers
Checks for common issues that cause validation errors
"""
import json
import subprocess
import sys
def check_server():
"""Run diagnostic checks for Claude Desktop compatibility"""
print("=== Claude Desktop MCP Diagnostic ===\n")
issues = []
tools = []
# Test 1: Check tool inputSchema format
print("1. Checking tool schemas...")
tools_req = {"jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {}}
proc = subprocess.Popen(['./odata-mcp'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
stdout, _ = proc.communicate(json.dumps(tools_req))
try:
response = json.loads(stdout)
tools = response.get('result', {}).get('tools', [])
for tool in tools:
# Check required fields
if 'name' not in tool:
issues.append(f"Tool missing 'name' field: {tool}")
if 'description' not in tool:
issues.append(f"Tool missing 'description' field: {tool.get('name', 'unknown')}")
if 'inputSchema' not in tool:
issues.append(f"Tool missing 'inputSchema' field: {tool.get('name', 'unknown')}")
else:
schema = tool['inputSchema']
# Check schema structure
if not isinstance(schema, dict):
issues.append(f"Tool {tool['name']} has invalid inputSchema type")
elif 'type' not in schema:
issues.append(f"Tool {tool['name']} inputSchema missing 'type' field")
elif schema.get('type') != 'object':
issues.append(f"Tool {tool['name']} inputSchema type should be 'object'")
# Check for properties
if 'properties' in schema:
props = schema['properties']
if not isinstance(props, dict):
issues.append(f"Tool {tool['name']} has invalid properties type")
else:
# Check each property
for prop_name, prop_def in props.items():
if not isinstance(prop_def, dict):
issues.append(f"Tool {tool['name']} property {prop_name} has invalid definition")
elif 'type' not in prop_def:
issues.append(f"Tool {tool['name']} property {prop_name} missing 'type'")
print(f" Found {len(tools)} tools")
except Exception as e:
issues.append(f"Failed to parse tools response: {e}")
# Test 2: Check response content format
print("\n2. Checking tool response format...")
if tools:
first_tool = tools[0]['name']
call_req = {
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {"name": first_tool, "arguments": {}}
}
proc = subprocess.Popen(['./odata-mcp'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
stdout, _ = proc.communicate(json.dumps(call_req))
try:
response = json.loads(stdout)
if 'result' in response:
result = response['result']
if 'content' not in result:
issues.append("Tool response missing 'content' field")
elif not isinstance(result['content'], list):
issues.append("Tool response 'content' should be an array")
else:
for item in result['content']:
if 'type' not in item:
issues.append("Content item missing 'type' field")
elif item['type'] != 'text':
issues.append(f"Unknown content type: {item['type']}")
if 'text' not in item:
issues.append("Content item missing 'text' field")
elif not isinstance(item['text'], str):
issues.append("Content 'text' field must be a string")
print(" Tool call response validated")
except Exception as e:
issues.append(f"Failed to parse tool call response: {e}")
# Test 3: Check capability format
print("\n3. Checking capability declarations...")
init_req = {"jsonrpc": "2.0", "id": 3, "method": "initialize", "params": {}}
proc = subprocess.Popen(['./odata-mcp'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
stdout, _ = proc.communicate(json.dumps(init_req))
try:
response = json.loads(stdout)
caps = response.get('result', {}).get('capabilities', {})
# Check required capability sections
required_caps = ['tools', 'resources', 'prompts']
for cap in required_caps:
if cap not in caps:
issues.append(f"Missing capability section: {cap}")
elif not isinstance(caps[cap], dict):
issues.append(f"Capability {cap} should be an object")
print(" Capabilities validated")
except Exception as e:
issues.append(f"Failed to parse initialize response: {e}")
# Summary
print("\n=== Diagnostic Summary ===")
if issues:
print(f"\n❌ Found {len(issues)} potential issues:\n")
for i, issue in enumerate(issues, 1):
print(f" {i}. {issue}")
print("\nThese issues might cause validation errors in Claude Desktop.")
else:
print("\n✅ No issues found! Server appears to be Claude Desktop compatible.")
return len(issues) == 0
if __name__ == "__main__":
if check_server():
sys.exit(0)
else:
sys.exit(1)