We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/stefanspycher/anki-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
test_server.pyβ’3.42 KiB
#!/usr/bin/env python3
"""
Test script for the Anki MCP Server.
Verifies that all components are working correctly.
"""
import asyncio
import sys
from datetime import datetime
try:
import mcp_server
except ImportError as e:
print(f"β Failed to import mcp_server: {e}")
print("Make sure you're running from the project directory with venv activated")
sys.exit(1)
async def test_anki_connection():
"""Test AnkiConnect connection."""
print("π Testing AnkiConnect connection...")
try:
result = await mcp_server.anki_connect_request('version')
print(f"β AnkiConnect connected: version {result}")
return True
except Exception as e:
print(f"β AnkiConnect connection failed: {e}")
print(" Make sure Anki is running with AnkiConnect add-on installed")
return False
async def test_server_architecture():
"""Test MCP server architecture."""
print("\nποΈ Testing server architecture...")
# Check if old AI dependencies are removed
try:
import google.generativeai
print("β οΈ Warning: google.generativeai still installed (but not used)")
except ImportError:
print("β No AI dependencies - clean data-only server")
# Test that server is configured as data bridge
print("β Server configured as data bridge - Claude handles all analysis")
print("β No external AI service dependencies")
print("β Focused on providing structured Anki data")
async def test_mcp_tools():
"""Test MCP tools registration."""
print("\nπ οΈ Testing MCP tools...")
try:
# Import the decorated functions to trigger registration
from mcp_server import handle_list_tools, call_tool
print("β MCP tools registered successfully")
print("β Server ready for Claude Desktop integration")
return True
except Exception as e:
print(f"β MCP tools registration failed: {e}")
return False
async def main():
"""Run all tests."""
print("π Anki MCP Data Bridge Test Suite")
print("=" * 50)
print(f"π Test run: {datetime.now().isoformat()}")
print(f"π Python: {sys.version}")
print(f"π Working directory: {sys.path[0]}")
# Run tests
anki_ok = await test_anki_connection()
await test_server_architecture()
mcp_ok = await test_mcp_tools()
# Summary
print("\n" + "=" * 50)
if anki_ok and mcp_ok:
print("π All tests passed! MCP Data Bridge server is ready for Claude Desktop.")
print("\nNext steps:")
print("1. Configure Claude Desktop with the provided config")
print("2. Restart Claude Desktop")
print("3. Ask Claude to analyze your Anki data!")
print("\nπ‘ Architecture:")
print(" β’ Server provides structured Anki data access (read + write)")
print(" β’ Claude handles all AI analysis and decision making")
print(" β’ No external AI dependencies needed")
print(" β’ Comprehensive CRUD operations for Anki management")
print(" β’ Safe write operations with validation and confirmation")
else:
print("β οΈ Some tests failed. Check the errors above.")
print("\nCommon fixes:")
print("- Ensure Anki is running")
print("- Verify AnkiConnect add-on is installed")
print("- Check virtual environment is activated")
if __name__ == "__main__":
asyncio.run(main())