Reuben_OS / test_claude_desktop.py
Reubencf's picture
First Push
8af739b
raw
history blame
4.32 kB
"""
Diagnostic script for Claude Desktop MCP integration
Run this to check if everything is set up correctly
"""
import os
import sys
import json
import subprocess
def check_python():
"""Check Python installation"""
print("1. Checking Python installation...")
try:
result = subprocess.run([sys.executable, "--version"], capture_output=True, text=True)
print(f" [OK] Python found: {result.stdout.strip()}")
print(f" Path: {sys.executable}")
return True
except Exception as e:
print(f" [FAIL] Python check failed: {e}")
return False
def check_dependencies():
"""Check required packages"""
print("\n2. Checking dependencies...")
required = ["fastmcp", "PyPDF2", "python-docx", "dotenv"]
missing = []
for package in required:
try:
__import__(package.replace("-", "_"))
print(f" [OK] {package} installed")
except ImportError:
print(f" [FAIL] {package} missing")
missing.append(package)
if missing:
print(f"\n Install missing packages with: pip install {' '.join(missing)}")
return False
return True
def check_claude_config():
"""Check Claude Desktop configuration"""
print("\n3. Checking Claude Desktop config...")
config_path = os.path.expandvars(r"%APPDATA%\Claude\claude_desktop_config.json")
if not os.path.exists(config_path):
print(f" [FAIL] Config file not found at: {config_path}")
return False
try:
with open(config_path, 'r') as f:
config = json.load(f)
if "mcpServers" in config and "exam-hub" in config["mcpServers"]:
print(f" [OK] exam-hub MCP server configured")
server_config = config["mcpServers"]["exam-hub"]
print(f" Command: {server_config.get('command', 'Not set')}")
print(f" Args: {server_config.get('args', [])}")
return True
else:
print(" [FAIL] exam-hub MCP server not configured")
return False
except Exception as e:
print(f" [FAIL] Error reading config: {e}")
return False
def check_mcp_server():
"""Check if MCP server can start"""
print("\n4. Testing MCP server...")
server_path = r"E:\mpc-hackathon\backend\mcp_server_wrapper.py"
if not os.path.exists(server_path):
print(f" [FAIL] Server script not found at: {server_path}")
return False
try:
# Change to backend directory
os.chdir(r"E:\mpc-hackathon\backend")
# Try importing the module
sys.path.insert(0, r"E:\mpc-hackathon\backend")
import mcp_server
print(" [OK] MCP server module can be imported")
# Check if data directories exist
data_dir = r"E:\mpc-hackathon\data"
docs_dir = os.path.join(data_dir, "documents")
if os.path.exists(docs_dir):
print(f" [OK] Documents directory exists: {docs_dir}")
else:
print(f" [WARN] Documents directory missing: {docs_dir}")
os.makedirs(docs_dir, exist_ok=True)
print(f" [OK] Created documents directory")
return True
except Exception as e:
print(f" [FAIL] MCP server test failed: {e}")
return False
def main():
print("=" * 50)
print("Claude Desktop MCP Integration Diagnostic")
print("=" * 50)
results = []
results.append(check_python())
results.append(check_dependencies())
results.append(check_claude_config())
results.append(check_mcp_server())
print("\n" + "=" * 50)
if all(results):
print("[SUCCESS] All checks passed!")
print("\nNext steps:")
print("1. Restart Claude Desktop completely")
print("2. Open a new conversation")
print("3. Test with: 'What tools are available from exam-hub?'")
else:
print("[WARN]️ Some checks failed. Please fix the issues above.")
print("\nTroubleshooting:")
print("1. Make sure Python is in your PATH")
print("2. Install missing dependencies")
print("3. Check the config file path")
print("4. Ensure all paths are correct")
print("\n" + "=" * 50)
input("Press Enter to exit...")
if __name__ == "__main__":
main()