test_mcp.py•1.32 kB
#!/usr/bin/env python3
"""
Simple test MCP server to verify Claude Desktop MCP support
"""
import json
import sys
def main():
"""Simple MCP server that responds to initialization"""
try:
# Read initialization message
line = sys.stdin.readline()
if not line:
return
msg = json.loads(line.strip())
# Respond with server info
if msg.get("method") == "initialize":
response = {
"jsonrpc": "2.0",
"id": msg.get("id"),
"result": {
"protocolVersion": "2024-11-05",
"serverInfo": {
"name": "test-mcp",
"version": "1.0.0"
},
"capabilities": {
"tools": {}
}
}
}
print(json.dumps(response))
sys.stdout.flush()
# Keep running
for line in sys.stdin:
pass
except Exception as e:
error = {
"jsonrpc": "2.0",
"error": {
"code": -32603,
"message": f"Internal error: {str(e)}"
}
}
print(json.dumps(error), file=sys.stderr)
if __name__ == "__main__":
main()