#!/usr/bin/env python3
"""
Setup script for Claude Code MCP integration
"""
import json
import os
import shutil
from pathlib import Path
def setup_mcp_config():
"""Set up MCP configuration for Claude Code"""
# Possible Claude Desktop config locations
config_locations = [
"~/Library/Application Support/Claude/claude_desktop_config.json", # macOS
"~/.config/claude/claude_desktop_config.json", # Linux
"%APPDATA%/Claude/claude_desktop_config.json" # Windows
]
current_dir = Path(__file__).parent
our_config_file = current_dir / "claude_desktop_config.json"
mcp_server_path = current_dir / "mcp_server.py"
print("š§ Setting up Claude Code MCP integration...")
print(f"š Project directory: {current_dir}")
print(f"š¤ MCP server: {mcp_server_path}")
# Read our configuration
with open(our_config_file, 'r') as f:
our_config = json.load(f)
# Update the path to be absolute
our_config["mcpServers"]["gemini-collaboration"]["args"][0] = str(mcp_server_path)
# Try to find and update Claude Desktop config
for location in config_locations:
config_path = Path(location).expanduser()
if config_path.exists():
print(f"š Found Claude config at: {config_path}")
# Backup existing config
backup_path = config_path.with_suffix('.json.backup')
shutil.copy2(config_path, backup_path)
print(f"š¾ Backed up existing config to: {backup_path}")
# Read existing config
try:
with open(config_path, 'r') as f:
existing_config = json.load(f)
except json.JSONDecodeError:
existing_config = {}
# Merge our MCP server config
if "mcpServers" not in existing_config:
existing_config["mcpServers"] = {}
existing_config["mcpServers"]["gemini-collaboration"] = our_config["mcpServers"]["gemini-collaboration"]
# Write updated config
with open(config_path, 'w') as f:
json.dump(existing_config, f, indent=2)
print("ā
Updated Claude Desktop configuration")
print("\nš Next steps:")
print("1. Restart Claude Desktop application")
print("2. Start the collaborative server:")
print(f" cd {current_dir}")
print(" source venv/bin/activate")
print(" python tools/mcp/collaborative-server.py")
print("3. In Claude Desktop, you should see these new tools:")
print(" - start_gemini_collaboration")
print(" - consult_gemini")
print(" - get_collaboration_history")
return True
# If no config found, create instructions
print("ā Claude Desktop config not found at standard locations")
print("\nš Manual setup instructions:")
print("1. Find your Claude Desktop config file location")
print("2. Add this to your config:")
print(json.dumps(our_config, indent=2))
print("3. Restart Claude Desktop")
return False
if __name__ == "__main__":
setup_mcp_config()