- Enhanced `ARCHITECTURE.md` with details on LLM models for work (Llama 3.1 70B Q4) and family agents (Phi-3 Mini 3.8B Q4). - Introduced new documents: - `ASR_EVALUATION.md` for ASR engine evaluation and selection. - `HARDWARE.md` outlining hardware requirements and purchase plans. - `IMPLEMENTATION_GUIDE.md` for Milestone 2 implementation steps. - `LLM_CAPACITY.md` assessing VRAM and context window limits. - `LLM_MODEL_SURVEY.md` surveying open-weight LLM models. - `LLM_USAGE_AND_COSTS.md` detailing LLM usage and operational costs. - `MCP_ARCHITECTURE.md` describing the Model Context Protocol architecture. - `MCP_IMPLEMENTATION_SUMMARY.md` summarizing MCP implementation status. These updates provide comprehensive guidance for the next phases of development and ensure clarity in project documentation.
149 lines
3.5 KiB
Python
Executable File
149 lines
3.5 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
Test script for MCP server.
|
|
"""
|
|
|
|
import requests
|
|
import json
|
|
|
|
MCP_URL = "http://localhost:8000/mcp"
|
|
|
|
|
|
def test_tools_list():
|
|
"""Test tools/list endpoint."""
|
|
print("Testing tools/list...")
|
|
|
|
request = {
|
|
"jsonrpc": "2.0",
|
|
"method": "tools/list",
|
|
"id": 1
|
|
}
|
|
|
|
response = requests.post(MCP_URL, json=request)
|
|
response.raise_for_status()
|
|
|
|
result = response.json()
|
|
print(f"Response: {json.dumps(result, indent=2)}")
|
|
|
|
if "result" in result and "tools" in result["result"]:
|
|
tools = result["result"]["tools"]
|
|
print(f"\n✓ Found {len(tools)} tools:")
|
|
for tool in tools:
|
|
print(f" - {tool['name']}: {tool['description']}")
|
|
return True
|
|
else:
|
|
print("✗ Unexpected response format")
|
|
return False
|
|
|
|
|
|
def test_echo_tool():
|
|
"""Test echo tool."""
|
|
print("\nTesting echo tool...")
|
|
|
|
request = {
|
|
"jsonrpc": "2.0",
|
|
"method": "tools/call",
|
|
"params": {
|
|
"name": "echo",
|
|
"arguments": {
|
|
"text": "Hello, MCP!"
|
|
}
|
|
},
|
|
"id": 2
|
|
}
|
|
|
|
response = requests.post(MCP_URL, json=request)
|
|
response.raise_for_status()
|
|
|
|
result = response.json()
|
|
print(f"Response: {json.dumps(result, indent=2)}")
|
|
|
|
if "result" in result:
|
|
print("✓ Echo tool works!")
|
|
return True
|
|
else:
|
|
print("✗ Echo tool failed")
|
|
return False
|
|
|
|
|
|
def test_weather_tool():
|
|
"""Test weather tool."""
|
|
print("\nTesting weather tool...")
|
|
|
|
request = {
|
|
"jsonrpc": "2.0",
|
|
"method": "tools/call",
|
|
"params": {
|
|
"name": "weather",
|
|
"arguments": {
|
|
"location": "San Francisco, CA"
|
|
}
|
|
},
|
|
"id": 3
|
|
}
|
|
|
|
response = requests.post(MCP_URL, json=request)
|
|
response.raise_for_status()
|
|
|
|
result = response.json()
|
|
print(f"Response: {json.dumps(result, indent=2)}")
|
|
|
|
if "result" in result:
|
|
print("✓ Weather tool works!")
|
|
return True
|
|
else:
|
|
print("✗ Weather tool failed")
|
|
return False
|
|
|
|
|
|
def test_health():
|
|
"""Test health endpoint."""
|
|
print("\nTesting health endpoint...")
|
|
|
|
response = requests.get("http://localhost:8000/health")
|
|
response.raise_for_status()
|
|
|
|
result = response.json()
|
|
print(f"Health: {json.dumps(result, indent=2)}")
|
|
|
|
return True
|
|
|
|
|
|
if __name__ == "__main__":
|
|
print("=" * 50)
|
|
print("MCP Server Test Suite")
|
|
print("=" * 50)
|
|
|
|
try:
|
|
# Test health first
|
|
test_health()
|
|
|
|
# Test tools/list
|
|
if not test_tools_list():
|
|
print("\n✗ tools/list test failed")
|
|
exit(1)
|
|
|
|
# Test echo tool
|
|
if not test_echo_tool():
|
|
print("\n✗ Echo tool test failed")
|
|
exit(1)
|
|
|
|
# Test weather tool
|
|
if not test_weather_tool():
|
|
print("\n✗ Weather tool test failed")
|
|
exit(1)
|
|
|
|
print("\n" + "=" * 50)
|
|
print("✓ All tests passed!")
|
|
print("=" * 50)
|
|
|
|
except requests.exceptions.ConnectionError:
|
|
print("\n✗ Cannot connect to MCP server")
|
|
print("Make sure the server is running:")
|
|
print(" cd home-voice-agent/mcp-server")
|
|
print(" python server/mcp_server.py")
|
|
exit(1)
|
|
except Exception as e:
|
|
print(f"\n✗ Test failed: {e}")
|
|
exit(1)
|