test_mcp_jsonrpc.py•844 B
import requests
import json
def test_mcp_tools():
"""Test that MCP tools are properly registered using the JSON-RPC endpoint."""
response = requests.post(
"http://localhost:8000/mcp/jsonrpc",
json={
"jsonrpc": "2.0",
"id": 1,
"method": "mcp.list_tools",
"params": {}
}
)
if response.status_code == 200:
result = response.json()
if "error" in result:
print(f"Error: {result['error']}")
else:
tools = result.get("result", [])
print(f"Found {len(tools)} tools:")
for tool in tools:
print(f"- {tool.get('name')}: {tool.get('description')}")
else:
print(f"Error: {response.status_code} - {response.text}")
if __name__ == "__main__":
test_mcp_tools()