test_todoist_mcp.py•3.26 kB
#!/usr/bin/env python3
"""
Test script for Todoist MCP Server
This script verifies that the server can be imported and initialized correctly.
"""
import sys
import os
def test_imports():
"""Test that all required packages can be imported."""
print("Testing imports...")
try:
import mcp
print("✅ MCP package imported successfully")
except ImportError as e:
print(f"❌ Failed to import MCP: {e}")
print(" Install with: pip install mcp")
return False
try:
import httpx
print("✅ httpx package imported successfully")
except ImportError as e:
print(f"❌ Failed to import httpx: {e}")
print(" Install with: pip install httpx")
return False
try:
import pydantic
print("✅ Pydantic package imported successfully")
except ImportError as e:
print(f"❌ Failed to import pydantic: {e}")
print(" Install with: pip install pydantic")
return False
return True
def test_server_import():
"""Test that the Todoist MCP server can be imported."""
print("\nTesting Todoist MCP server import...")
try:
import todoist_mcp
print("✅ Todoist MCP server imported successfully")
return True
except ImportError as e:
print(f"❌ Failed to import Todoist MCP server: {e}")
print(" Make sure todoist_mcp.py is in the current directory or Python path")
return False
except Exception as e:
print(f"❌ Error importing Todoist MCP server: {e}")
return False
def test_api_token():
"""Check if API token is configured."""
print("\nChecking API token configuration...")
token = os.environ.get('TODOIST_API_TOKEN')
if token:
# Mask the token for security
masked_token = token[:8] + "..." + token[-4:] if len(token) > 12 else "***"
print(f"✅ API token found in environment: {masked_token}")
return True
else:
print("⚠️ No API token found in environment")
print(" Set with: export TODOIST_API_TOKEN='your_token_here'")
print(" Get your token from: https://todoist.com/prefs/integrations")
return False
def main():
"""Run all tests."""
print("=" * 50)
print("Todoist MCP Server Test Suite")
print("=" * 50)
all_passed = True
# Test imports
if not test_imports():
all_passed = False
# Test server import
if not test_server_import():
all_passed = False
# Test API token
test_api_token() # This is a warning, not a failure
print("\n" + "=" * 50)
if all_passed:
print("✅ All tests passed! The server is ready to use.")
print("\nNext steps:")
print("1. Set your API token: export TODOIST_API_TOKEN='your_token'")
print("2. Configure Claude Desktop with the path to todoist_mcp.py")
print("3. Restart Claude Desktop to load the MCP server")
else:
print("❌ Some tests failed. Please fix the issues above.")
print("\nInstall all dependencies with:")
print(" pip install -r requirements.txt")
print("=" * 50)
if __name__ == "__main__":
main()