ken-you-code
Version:
Connect your codebase to Kimi: Ultra-fast AI code analysis with Kimi-K2 model via MCP
66 lines (65 loc) • 2.39 kB
JavaScript
import { MCPSetup } from './setup.js';
import { spawn } from 'child_process';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
async function main() {
const args = process.argv.slice(2);
const command = args[0];
// Handle setup commands
if (command === 'setup' || command === 'configure') {
const setup = new MCPSetup();
await setup.setup();
return;
}
if (command === 'config' || command === 'show-config') {
const setup = new MCPSetup();
await setup.showConfig();
return;
}
if (command === 'help' || command === '--help' || command === '-h') {
console.log('🔧 Single Model Specialist MCP Server\n');
console.log('Usage:');
console.log(' # Option 1: Setup once (recommended)');
console.log(' npx single-model-mcp-server setup');
console.log(' claude mcp add single-model-specialist npx single-model-mcp-server');
console.log('');
console.log(' # Option 2: Pass API key directly');
console.log(' claude mcp add single-model-specialist npx single-model-mcp-server \\');
console.log(' -e OPENROUTER_API_KEY=sk-your-key-here');
console.log('');
console.log('Commands:');
console.log(' setup - Configure API keys and settings');
console.log(' config - Show current configuration');
console.log(' help - Show this help message');
console.log('');
console.log('Get your OpenRouter API key: https://openrouter.ai/keys');
return;
}
// Default: start MCP server
const serverPath = path.join(__dirname, 'server.js');
const server = spawn('node', [serverPath], {
stdio: 'inherit',
env: process.env,
});
server.on('error', (error) => {
console.error('Failed to start MCP server:', error.message);
process.exit(1);
});
server.on('exit', (code) => {
process.exit(code || 0);
});
// Handle graceful shutdown
process.on('SIGINT', () => {
server.kill('SIGINT');
});
process.on('SIGTERM', () => {
server.kill('SIGTERM');
});
}
main().catch((error) => {
console.error('Error:', error.message);
process.exit(1);
});