You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

109 lines
3.5 KiB

#!/usr/bin/env python3
"""
Post-installation script to automatically configure Kilocode MCP settings.
"""
import json
import os
import sys
from pathlib import Path
def get_kilocode_config_path():
"""Find the Kilocode MCP settings file."""
# Common paths for Kilocode/VSCodium
possible_paths = [
Path.home() / ".config/VSCodium/User/globalStorage/kilocode.kilo-code/settings/mcp_settings.json",
Path.home() / ".config/Code/User/globalStorage/kilocode.kilo-code/settings/mcp_settings.json",
Path.home() / "Library/Application Support/VSCodium/User/globalStorage/kilocode.kilo-code/settings/mcp_settings.json",
Path.home() / "Library/Application Support/Code/User/globalStorage/kilocode.kilo-code/settings/mcp_settings.json",
]
for path in possible_paths:
if path.exists():
return path
return None
def add_to_kilocode_config():
"""Add the image-recognition server to Kilocode's MCP settings."""
config_path = get_kilocode_config_path()
if not config_path:
print(" Kilocode MCP settings file not found.")
print(" You'll need to manually add the server configuration.")
print("\n Add this to your MCP settings:")
print(json.dumps({
"image-recognition": {
"command": "uvx",
"args": ["image-recognition-mcp"],
"env": {
"OPENAI_API_KEY": "your-openai-api-key-here"
}
}
}, indent=2))
return False
try:
# Read existing config
with open(config_path, 'r') as f:
config = json.load(f)
# Ensure mcpServers exists
if "mcpServers" not in config:
config["mcpServers"] = {}
# Check if already configured
if "image-recognition" in config["mcpServers"]:
print("✅ Image Recognition MCP server already configured in Kilocode")
return True
# Add our server
config["mcpServers"]["image-recognition"] = {
"command": "uvx",
"args": ["image-recognition-mcp"],
"env": {
"OPENAI_API_KEY": "your-openai-api-key-here"
}
}
# Backup original config
backup_path = config_path.with_suffix('.json.backup')
with open(backup_path, 'w') as f:
json.dump(config, f, indent=2)
# Write updated config
with open(config_path, 'w') as f:
json.dump(config, f, indent=2)
print("✅ Successfully added Image Recognition MCP server to Kilocode!")
print(f" Config file: {config_path}")
print(f" Backup saved: {backup_path}")
print("\n Remember to:")
print(" 1. Replace 'your-openai-api-key-here' with your actual OpenAI API key")
print(" 2. Restart Kilocode to load the new server")
return True
except Exception as e:
print(f"❌ Error updating Kilocode config: {e}")
return False
def main():
"""Main entry point for the installer."""
print("🚀 Image Recognition MCP Server - Post-Install Configuration")
print("=" * 60)
if add_to_kilocode_config():
print("\n✨ Installation complete!")
else:
print("\n Manual configuration required.")
print(" See PUBLISHING.md for instructions.")
return 0
if __name__ == "__main__":
sys.exit(main())