test_claude_desktop_config.pyโข3 kB
#!/usr/bin/env python3
"""
Test script to verify the exact Claude Desktop configuration works
"""
import subprocess
import sys
import os
def test_claude_desktop_command():
"""Test the exact command that Claude Desktop will use"""
print("๐งช Testing Claude Desktop MCP configuration...")
# Change to the project directory
os.chdir("/Users/chris/enterprise/O-RLY-Book-Generator")
# The exact command from Claude Desktop config
cmd = [
"uv", "run",
"--with", "fastmcp",
"--with", "pillow",
"--with", "fonttools",
"--with", "requests",
"python", "-c",
"from orly_generator.models import generate_image; print('โ
All imports successful')"
]
try:
result = subprocess.run(cmd, capture_output=True, text=True, timeout=30)
if result.returncode == 0:
print("โ
Claude Desktop command works!")
print(f" Output: {result.stdout.strip()}")
return True
else:
print("โ Claude Desktop command failed!")
print(f" Error: {result.stderr}")
return False
except subprocess.TimeoutExpired:
print("โ Command timed out")
return False
except Exception as e:
print(f"โ Error running command: {e}")
return False
def test_server_startup():
"""Test that the server can start with the exact command"""
print("\n๐ Testing MCP server startup...")
# Test import of the server module
cmd = [
"uv", "run",
"--with", "fastmcp",
"--with", "pillow",
"--with", "fonttools",
"--with", "requests",
"python", "-c",
"""
import sys
sys.path.insert(0, '/Users/chris/enterprise/O-RLY-Book-Generator')
try:
from orly_mcp.server import app
print('โ
MCP server can be imported')
except Exception as e:
print(f'โ Server import failed: {e}')
sys.exit(1)
"""
]
try:
result = subprocess.run(cmd, capture_output=True, text=True, timeout=30)
if result.returncode == 0:
print("โ
MCP server startup test passed!")
print(f" Output: {result.stdout.strip()}")
return True
else:
print("โ MCP server startup failed!")
print(f" Error: {result.stderr}")
return False
except Exception as e:
print(f"โ Error testing server: {e}")
return False
if __name__ == "__main__":
print("๐ฏ Testing Claude Desktop MCP configuration...")
test1 = test_claude_desktop_command()
test2 = test_server_startup()
if test1 and test2:
print("\n๐ All tests passed! Claude Desktop configuration is ready!")
print("\n๐ Next steps:")
print("1. Restart Claude Desktop")
print("2. Ask Claude to generate an O'RLY book cover!")
else:
print("\nโ Some tests failed. Check the configuration.")
sys.exit(1)