UNPKG

claude-agents-power

Version:

Unleash the power of 100+ specialized Claude agents for your development team via MCP

1,215 lines (1,155 loc) β€’ 78.8 kB
#!/usr/bin/env node import { Server } from '@modelcontextprotocol/sdk/server/index.js'; import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'; import { CallToolRequestSchema, ListToolsRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, } from '@modelcontextprotocol/sdk/types.js'; import { Command } from 'commander'; import { ProjectAnalyzer } from './projectAnalyzer.js'; import { AgentManager } from './agentManager.js'; import { initializeAnalytics, trackEvent, AnalyticsEvents, shutdown as shutdownAnalytics } from './analytics.js'; import path from 'path'; import { fileURLToPath } from 'url'; import { dirname } from 'path'; import fs from 'fs'; import os from 'os'; import dotenv from 'dotenv'; import { AgentDownloader } from './agentDownloader.js'; import { AIAnalysisService } from './aiAnalysisService.js'; // ES module compatibility const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); // Load environment variables from .env file dotenv.config(); // Get version from package.json const packageJsonPath = path.join(__dirname, '../package.json'); let version = '1.6.0'; // fallback version try { const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')); version = packageJson.version; } catch (error) { console.error('[MCP Sub-Agents] Could not read package.json version:', error); } // Check for slash commands flags first (manual parsing to avoid commander issues) const hasInstallSlashCommands = process.argv.includes('--install-slash-commands'); const hasUninstallSlashCommands = process.argv.includes('--uninstall-slash-commands'); const hasAgentDownload = process.argv.includes('--agent-download'); // Parse CLI arguments using commander const program = new Command() .name('claude-agents-power') .option('--transport <stdio>', 'transport type', 'stdio') .option('--debug', 'enable debug logging') .option('--install', 'install MCP configuration to Claude Desktop') .option('--install-slash-commands', 'install slash commands to Claude Code') .option('--uninstall-slash-commands', 'uninstall slash commands from Claude Code') .option('--agent-download', 'download recommended agents for current project') .option('--target-dir <dir>', 'target directory for agent files (default: "./agents")') .option('--claude-md <path>', 'path to CLAUDE.md file (default: "./CLAUDE.md")') .option('--format <format>', 'agent file format: md, yaml, json (default: "md")') .option('--language <lang>', 'preferred language: en, ko, ja, zh (default: "en")') .option('--limit <n>', 'maximum number of agents to download (default: 10)') .option('--dry-run', 'preview recommendations without downloading') .option('--overwrite', 'overwrite existing agent files') .allowUnknownOption() // let MCP Inspector / other wrappers pass through extra flags .parse(process.argv); const cliOptions = program.opts(); // Override with manual parsing results if (hasInstallSlashCommands) { cliOptions.installSlashCommands = true; } if (hasUninstallSlashCommands) { cliOptions.uninstallSlashCommands = true; } if (hasAgentDownload) { cliOptions.agentDownload = true; } // Handle --install flag if (cliOptions.install) { console.log('πŸš€ Claude Agents Power MCP Installer\n'); // Get Claude Desktop config path const configPaths = [ path.join(os.homedir(), 'Library', 'Application Support', 'Claude', 'claude_desktop_config.json'), path.join(os.homedir(), '.config', 'claude', 'claude_desktop_config.json'), path.join(os.homedir(), 'AppData', 'Roaming', 'Claude', 'claude_desktop_config.json') ]; let configPath = null; for (const p of configPaths) { if (fs.existsSync(p)) { configPath = p; break; } } if (!configPath) { // Try to find Claude config directory const configDirs = [ path.join(os.homedir(), 'Library', 'Application Support', 'Claude'), path.join(os.homedir(), '.config', 'claude'), path.join(os.homedir(), 'AppData', 'Roaming', 'Claude') ]; for (const dir of configDirs) { if (fs.existsSync(dir)) { configPath = path.join(dir, 'claude_desktop_config.json'); break; } } } if (!configPath) { console.error('❌ Could not find Claude Desktop configuration directory'); console.log('\nPlease create the config file manually at one of these locations:'); configPaths.forEach(p => console.log(` - ${p}`)); process.exit(1); } console.log(`πŸ“ Found Claude config at: ${configPath}`); // Read existing config or create new one let config = { mcpServers: {} }; if (fs.existsSync(configPath)) { try { const content = fs.readFileSync(configPath, 'utf8'); config = JSON.parse(content); if (!config.mcpServers) { config.mcpServers = {}; } } catch (error) { console.error('⚠️ Error reading existing config, will create new one'); } } // Check if already installed if (config.mcpServers['claude-agents-power']) { console.log('βœ… claude-agents-power is already configured in Claude Desktop'); console.log('\nTo update, remove the existing entry and run this installer again.'); process.exit(0); } // Add claude-agents-power to config config.mcpServers['claude-agents-power'] = { command: 'npx', args: ['claude-agents-power'] }; // Write config try { // Create directory if it doesn't exist const dir = path.dirname(configPath); if (!fs.existsSync(dir)) { fs.mkdirSync(dir, { recursive: true }); } fs.writeFileSync(configPath, JSON.stringify(config, null, 2)); console.log('βœ… Successfully added claude-agents-power to Claude Desktop configuration'); console.log('\nπŸ“ Next steps:'); console.log('1. Restart Claude Desktop'); console.log('2. Look for MCP tools starting with "mcp__claude-agents-power__"'); console.log('\n🎯 Example usage in Claude:'); console.log(' "claude-agents-powerλ₯Ό μ΄μš©ν•΄μ„œ 이 ν”„λ‘œμ νŠΈλ₯Ό μœ„ν•œ μΆ”μ²œ 및 agents/*.md νŒŒμΌμ„ λ‹€μš΄λ‘œλ“œ ν•΄μ€˜"'); } catch (error) { console.error('❌ Error writing configuration:', error.message); console.log('\nPlease add this to your claude_desktop_config.json manually:'); console.log(JSON.stringify({ mcpServers: { 'claude-agents-power': { command: 'npx', args: ['claude-agents-power'] } } }, null, 2)); process.exit(1); } process.exit(0); } // Handle --install-slash-commands flag if (cliOptions.installSlashCommands) { console.log('πŸš€ Claude Agents Power - Slash Commands Installer\n'); try { const claudeDir = path.join(os.homedir(), '.claude'); const commandsDir = path.join(claudeDir, 'commands'); const sourceDir = path.join(__dirname, '../claude-slash-commands'); // Create directories if they don't exist if (!fs.existsSync(claudeDir)) { fs.mkdirSync(claudeDir, { recursive: true }); console.log(`πŸ“ Created: ${claudeDir}`); } if (!fs.existsSync(commandsDir)) { fs.mkdirSync(commandsDir, { recursive: true }); console.log(`πŸ“ Created: ${commandsDir}`); } // Copy command files console.log('πŸ“‹ Installing slash commands...'); const commandFiles = fs.readdirSync(sourceDir); for (const file of commandFiles) { if (file.endsWith('.md')) { const sourcePath = path.join(sourceDir, file); const targetPath = path.join(commandsDir, file); fs.copyFileSync(sourcePath, targetPath); console.log(` βœ… Installed: ${file}`); } } // Create README const readmeContent = `# Claude Agents Power - Slash Commands Available commands: - /agents:load - Load and display available agents - /agents:search - Search agents by skills or keywords - /agents:suggest - Get intelligent agent recommendations - /agents:version - Check system version and status Generated by claude-agents-power v${version} `; fs.writeFileSync(path.join(commandsDir, 'README.md'), readmeContent); console.log('\nβœ… Slash commands installed successfully!'); console.log('\nAvailable commands in Claude Code:'); console.log(' /agents:load - Load and display available agents'); console.log(' /agents:search - Search agents by skills or keywords'); console.log(' /agents:suggest - Get intelligent agent recommendations'); console.log(' /agents:version - Check system version and status'); console.log('\nπŸ’‘ Try "/agents:load" in Claude Code to get started!'); } catch (error) { console.error('❌ Installation failed:', error); process.exit(1); } process.exit(0); } // Handle --uninstall-slash-commands flag if (cliOptions.uninstallSlashCommands) { console.log('πŸ—‘οΈ Uninstalling claude-agents-power slash commands...\n'); try { const commandsDir = path.join(os.homedir(), '.claude', 'commands'); if (fs.existsSync(commandsDir)) { const files = fs.readdirSync(commandsDir); const agentCommandFiles = files.filter(file => file.startsWith('agents-') && file.endsWith('.md')); for (const file of agentCommandFiles) { const filePath = path.join(commandsDir, file); fs.unlinkSync(filePath); console.log(` πŸ—‘οΈ Removed: ${file}`); } // Remove README if it exists const readmePath = path.join(commandsDir, 'README.md'); if (fs.existsSync(readmePath)) { fs.unlinkSync(readmePath); console.log(' πŸ—‘οΈ Removed: README.md'); } console.log('\nβœ… Slash commands uninstalled successfully!'); } else { console.log('No slash commands found to uninstall.'); } } catch (error) { console.error('❌ Uninstallation failed:', error); process.exit(1); } process.exit(0); } // Handle --agent-download flag if (cliOptions.agentDownload) { console.log('πŸ€– Claude Agents Power - Agent Downloader\n'); try { const downloader = new AgentDownloader(); const options = { targetDir: cliOptions.targetDir || './agents', claudeMdPath: cliOptions.claudeMd || './CLAUDE.md', format: cliOptions.format || 'md', language: cliOptions.language || 'en', limit: cliOptions.limit ? parseInt(cliOptions.limit) : 10, dryRun: cliOptions.dryRun || false, overwrite: cliOptions.overwrite || false }; console.log('πŸ” Analyzing project...'); const result = await downloader.downloadAgents(options); // Display enhanced AI analysis results console.log('\n🧠 AI-Powered Project Analysis Results:'); console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'); console.log(`πŸ“Š Project Type: ${result.analysis.projectType}`); console.log(`πŸ› οΈ Technologies: ${result.analysis.technologies.join(', ') || 'None detected'}`); console.log(`πŸ“š Frameworks: ${result.analysis.frameworks.join(', ') || 'None detected'}`); console.log(`πŸ“ˆ Complexity: ${result.analysis.complexity}/10`); console.log(`πŸš€ Development Phase: ${result.analysis.phase}`); console.log(`πŸ‘₯ Recommended Team Size: ${result.analysis.teamSize} agents`); if (result.analysis.description) { console.log(`πŸ“ Description: ${result.analysis.description}`); } // Display quality indicators if (result.analysis.qualityIndicators) { console.log('\nπŸ“‹ Quality Assessment:'); const qi = result.analysis.qualityIndicators; console.log(` ${qi.hasTests ? 'βœ…' : '❌'} Automated Testing`); console.log(` ${qi.hasDocumentation ? 'βœ…' : '❌'} Documentation`); console.log(` ${qi.hasCI ? 'βœ…' : 'βœ…'} CI/CD Pipeline`); console.log(` ${qi.hasLinting ? 'βœ…' : '❌'} Code Quality Tools`); console.log(` πŸ“Š Code Complexity: ${qi.codeComplexity}`); } // Display architectural patterns if available if (result.analysis.architecturalPatterns && result.analysis.architecturalPatterns.length > 0) { console.log(`\nπŸ—οΈ Architectural Patterns: ${result.analysis.architecturalPatterns.join(', ')}`); } // Display development practices if available if (result.analysis.developmentPractices && result.analysis.developmentPractices.length > 0) { console.log(`\nβš™οΈ Development Practices: ${result.analysis.developmentPractices.join(', ')}`); } console.log('\nπŸ† AI-Generated Recommendations:'); console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'); result.recommendations.forEach((rec, index) => { const icon = rec.priority === 'essential' ? '⭐' : rec.priority === 'recommended' ? 'πŸ”§' : 'πŸ’‘'; console.log(`${index + 1}. ${icon} ${rec.name} (${rec.relevanceScore}% match)`); console.log(` └─ ${rec.reasoning}`); // Display specific tasks if available if (rec.specificTasks && rec.specificTasks.length > 0) { console.log(` 🎯 Key Tasks: ${rec.specificTasks.slice(0, 2).join(', ')}${rec.specificTasks.length > 2 ? '...' : ''}`); } // Display integration points if available if (rec.integrationPoints && rec.integrationPoints.length > 0) { console.log(` πŸ”— Integrations: ${rec.integrationPoints.slice(0, 2).join(', ')}${rec.integrationPoints.length > 2 ? '...' : ''}`); } }); if (options.dryRun) { console.log('\nπŸ’‘ This was an AI-powered dry run analysis. Use without --dry-run to download agents.'); console.log('\n🧠 AI Analysis Features Used:'); console.log(' β€’ Intelligent project structure analysis'); console.log(' β€’ Context-aware agent recommendations'); console.log(' β€’ Dynamic priority assignment'); console.log(' β€’ Task-specific role matching'); } else if (result.downloaded && result.downloaded.length > 0) { console.log('\nπŸ“₯ Downloaded AI-Recommended Agents:'); console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'); result.downloaded.forEach(filePath => { const fileName = path.basename(filePath); const fileSize = fs.statSync(filePath).size; const fileSizeKB = (fileSize / 1024).toFixed(1); console.log(`βœ… ${fileName.padEnd(25)} (${fileSizeKB}KB)`); }); console.log('\nπŸ“Š AI-Powered Summary:'); console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'); console.log(`βœ… ${result.downloaded.length} agents intelligently selected and downloaded`); console.log(`πŸ“ Files saved to: ${options.targetDir}`); console.log(`πŸ“‹ Enhanced README.md created with AI analysis insights`); console.log(`🧠 AI Features: Dynamic analysis, context-aware recommendations, smart prioritization`); console.log(`πŸ’‘ Next: Try using your AI-recommended agents in your development workflow`); } } catch (error) { console.error('❌ Agent download failed:', error); process.exit(1); } process.exit(0); } // Debug logging function const debug = (...args) => { if (cliOptions.debug) { console.error('[MCP Sub-Agents DEBUG]', ...args); } }; // Validate transport option const allowedTransports = ['stdio']; if (!allowedTransports.includes(cliOptions.transport)) { console.error(`Invalid --transport value: '${cliOptions.transport}'. Must be: stdio.`); process.exit(1); } // Transport configuration const TRANSPORT_TYPE = 'stdio'; // Function to create a new server instance with all tools registered function createServerInstance() { const server = new Server({ name: 'claude-agents-power-mcp-server', version: version, }, { capabilities: { tools: {}, resources: {}, }, }); return server; } // Initialize analytics initializeAnalytics(); trackEvent(AnalyticsEvents.SERVER_STARTED, { debug_mode: cliOptions.debug, transport: cliOptions.transport, }); // Initialize managers // Support both development and production paths const isDevelopment = process.env.NODE_ENV === 'development'; // Try multiple possible agent paths let agentsPath; const possiblePaths = [ // Development path path.join(__dirname, '../../claude/agents'), // Production NPM global install path.join(__dirname, '../claude/agents'), // Alternative production path path.resolve(process.cwd(), 'claude/agents'), // NPM package structure path.join(__dirname, '..', '..', 'claude', 'agents'), ]; // Find the first existing path agentsPath = possiblePaths.find(p => { const exists = existsSync(p); if (cliOptions.debug) { console.error(`[MCP Sub-Agents DEBUG] Checking path: ${p} - ${exists ? 'EXISTS' : 'NOT FOUND'}`); } return exists; }) || possiblePaths[0]; debug(`Current working directory: ${process.cwd()}`); debug(`__dirname: ${__dirname}`); debug(`Loading agents from: ${agentsPath}`); // Check if agents directory exists import { existsSync } from 'fs'; if (cliOptions.debug && existsSync(agentsPath)) { debug(`Agents directory exists: ${agentsPath}`); const { readdirSync } = await import('fs'); const files = readdirSync(agentsPath); debug(`Found ${files.length} files in agents directory`); } else if (cliOptions.debug) { debug(`ERROR: Agents directory not found: ${agentsPath}`); } const projectAnalyzer = new ProjectAnalyzer(); const agentManager = new AgentManager(agentsPath, { owner: 'baryonlabs', repo: 'claude-sub-agent-contents', branch: 'main', path: 'claude/agents' }, cliOptions.debug || false); const aiAnalysisService = new AIAnalysisService(); // Function to setup tools for a server instance function setupTools(server, projectAnalyzer, agentManager, aiAnalysisService) { // Define resources server.setRequestHandler(ListResourcesRequestSchema, async () => { return { resources: [ { uri: 'mcp://claude-agents-power/how-it-works', name: 'MCP λ™μž‘ 원리', description: 'Claude Agents Power MCP μ„œλ²„μ˜ λ™μž‘ 원리와 ꡬ쑰 μ„€λͺ…', mimeType: 'text/markdown', }, { uri: 'mcp://claude-agents-power/tool-guide', name: '도ꡬ μ‚¬μš© κ°€μ΄λ“œ', description: 'ν†΅ν•©λœ 3개 λ„κ΅¬μ˜ μ‚¬μš© 방법과 예제', mimeType: 'text/markdown', }, { uri: 'mcp://claude-agents-power/agent-structure', name: 'μ—μ΄μ „νŠΈ ꡬ쑰', description: 'μ—μ΄μ „νŠΈ 파일 ꡬ쑰와 λ‹€κ΅­μ–΄ 지원 μ„€λͺ…', mimeType: 'text/markdown', }, ], }; }); server.setRequestHandler(ReadResourceRequestSchema, async (request) => { const { uri } = request.params; switch (uri) { case 'mcp://claude-agents-power/how-it-works': return { contents: [ { uri, mimeType: 'text/markdown', text: `# Claude Agents Power MCP μ„œλ²„ λ™μž‘ 원리 ## κ°œμš” Claude Agents PowerλŠ” Model Context Protocol(MCP)을 μ‚¬μš©ν•˜μ—¬ 100개 μ΄μƒμ˜ μ „λ¬Έ μ—μ΄μ „νŠΈλ₯Ό Claudeμ—μ„œ μ‚¬μš©ν•  수 있게 ν•΄μ£ΌλŠ” μ„œλ²„μž…λ‹ˆλ‹€. ## MCP (Model Context Protocol) λž€? MCPλŠ” Claude와 같은 LLM이 μ™ΈλΆ€ 도ꡬ와 λ¦¬μ†ŒμŠ€μ— μ ‘κ·Όν•  수 있게 ν•΄μ£ΌλŠ” ν‘œμ€€ ν”„λ‘œν† μ½œμž…λ‹ˆλ‹€. ### μ£Όμš” ꡬ성 μš”μ†Œ: 1. **Tools (도ꡬ)**: Claudeκ°€ μ‹€ν–‰ν•  수 μžˆλŠ” ν•¨μˆ˜λ“€ 2. **Resources (λ¦¬μ†ŒμŠ€)**: Claudeκ°€ 읽을 수 μžˆλŠ” λ¬Έμ„œλ‚˜ 데이터 3. **Prompts (ν”„λ‘¬ν”„νŠΈ)**: 미리 μ •μ˜λœ ν”„λ‘¬ν”„νŠΈ ν…œν”Œλ¦Ώ ## μ„œλ²„ μ•„ν‚€ν…μ²˜ ### 1. μ—μ΄μ „νŠΈ λ§€λ‹ˆμ € (AgentManager) - μ—μ΄μ „νŠΈ 파일 λ‘œλ”© 및 캐싱 - λ‹€κ΅­μ–΄ 지원 (en, ko, ja, zh) - GitHubμ—μ„œ μ—μ΄μ „νŠΈ 동적 λ‘œλ”© ### 2. ν”„λ‘œμ νŠΈ 뢄석기 (ProjectAnalyzer) - ν”„λ‘œμ νŠΈ ꡬ쑰 뢄석 - μ ν•©ν•œ μ—μ΄μ „νŠΈ μΆ”μ²œ - ν‚€μ›Œλ“œ 기반 λ§€μΉ­ ### 3. 톡합 도ꡬ μ‹œμŠ€ν…œ κΈ°μ‘΄ 8개 도ꡬλ₯Ό 3개둜 톡합: - \`analyze-project\`: ν”„λ‘œμ νŠΈ 뢄석 - \`agents\`: μ—μ΄μ „νŠΈ 검색/λͺ©λ‘/상세/μΆ”μ²œ - \`manage-agents\`: μ„€μΉ˜/톡계/μƒˆλ‘œκ³ μΉ¨ ## 데이터 흐름 \`\`\` Claude Desktop β†’ MCP Protocol β†’ Agent Manager β†’ Local Files ↓ GitHub Repository (fallback) \`\`\` ## μ—μ΄μ „νŠΈ λ‘œλ”© κ³Όμ • 1. **μ‹œμž‘μ‹œ**: \`claude/agents/{μ–Έμ–΄}/\` λ””λ ‰ν† λ¦¬μ—μ„œ μ—μ΄μ „νŠΈ λ‘œλ“œ 2. **μš”μ²­μ‹œ**: μΊμ‹œμ—μ„œ λΉ λ₯Έ 검색 3. **λ―Έλ°œκ²¬μ‹œ**: GitHubμ—μ„œ 동적 λ‹€μš΄λ‘œλ“œ 4. **μ„€μΉ˜**: ν”„λ‘œμ νŠΈ 디렉토리에 μ—μ΄μ „νŠΈ 파일 볡사 ## μ„±λŠ₯ μ΅œμ ν™” - λ©”λͺ¨λ¦¬ μΊμ‹±μœΌλ‘œ λΉ λ₯Έ 응닡 - YAML frontmatter νŒŒμ‹±μœΌλ‘œ 메타데이터 μΆ”μΆœ - 언어별 ν‚€ λ§€ν•‘μœΌλ‘œ 효율적인 검색 `, }, ], }; case 'mcp://claude-agents-power/tool-guide': return { contents: [ { uri, mimeType: 'text/markdown', text: `# 도ꡬ μ‚¬μš© κ°€μ΄λ“œ ## ν†΅ν•©λœ 3개 도ꡬ μ‚¬μš©λ²• ### 1. analyze-project ν”„λ‘œμ νŠΈ 디렉토리λ₯Ό λΆ„μ„ν•˜μ—¬ μ ν•©ν•œ μ—μ΄μ „νŠΈλ₯Ό μΆ”μ²œν•©λ‹ˆλ‹€. **μ‚¬μš©λ²•:** \`\`\`json { "tool": "analyze-project", "arguments": { "projectPath": "/path/to/project" } } \`\`\` ### 2. agents μ—μ΄μ „νŠΈ κ΄€λ ¨ λͺ¨λ“  μž‘μ—…μ„ μ²˜λ¦¬ν•˜λŠ” 톡합 λ„κ΅¬μž…λ‹ˆλ‹€. #### 2.1 검색 (search) \`\`\`json { "tool": "agents", "arguments": { "action": "search", "query": "frontend", "language": "en" } } \`\`\` #### 2.2 λͺ©λ‘ 쑰회 (list) \`\`\`json { "tool": "agents", "arguments": { "action": "list", "language": "ko", "category": "development" } } \`\`\` #### 2.3 상세 정보 (details) \`\`\`json { "tool": "agents", "arguments": { "action": "details", "query": "frontend-developer", "language": "en" } } \`\`\` #### 2.4 μΆ”μ²œ (recommend) \`\`\`json { "tool": "agents", "arguments": { "action": "recommend", "keywords": ["react", "typescript", "ui"] } } \`\`\` #### 2.5 검색 (μžλ™ Issue 생성) \`\`\`json { "tool": "agents", "arguments": { "action": "search", "query": "blockchain-architect", "language": "en", "autoCreateIssue": true, "issueBody": "We need a blockchain architect for smart contract development" } } \`\`\` #### 2.6 μš”μ²­ (request) \`\`\`json { "tool": "agents", "arguments": { "action": "request", "query": "ai-ethics-officer", "language": "en", "issueBody": "Need an AI ethics specialist for responsible AI development" } } \`\`\` ### 3. manage-agents μ—μ΄μ „νŠΈ 관리 μž‘μ—…μ„ μ²˜λ¦¬ν•©λ‹ˆλ‹€. #### 3.1 μ„€μΉ˜ (install) \`\`\`json { "tool": "manage-agents", "arguments": { "action": "install", "agentNames": ["frontend-developer", "backend-engineer"], "targetPath": "/path/to/project", "language": "en" } } \`\`\` #### 3.2 톡계 (stats) \`\`\`json { "tool": "manage-agents", "arguments": { "action": "stats", "limit": 10 } } \`\`\` #### 3.3 μƒˆλ‘œκ³ μΉ¨ (refresh) \`\`\`json { "tool": "manage-agents", "arguments": { "action": "refresh" } } \`\`\` ## μ–Έμ–΄ 지원 - \`en\`: English - \`ko\`: ν•œκ΅­μ–΄ - \`ja\`: ζ—₯本θͺž - \`zh\`: δΈ­ζ–‡ ## μΉ΄ν…Œκ³ λ¦¬ - development, data, design, management - marketing, operations, hr, finance - legal, research, healthcare, education - media, manufacturing, other `, }, ], }; case 'mcp://claude-agents-power/agent-structure': return { contents: [ { uri, mimeType: 'text/markdown', text: `# μ—μ΄μ „νŠΈ ꡬ쑰 ## 파일 ꡬ쑰 \`\`\` claude/agents/ β”œβ”€β”€ en/ # μ˜μ–΄ μ—μ΄μ „νŠΈ β”‚ β”œβ”€β”€ frontend-developer.md β”‚ β”œβ”€β”€ backend-engineer.md β”‚ └── ... β”œβ”€β”€ ko/ # ν•œκ΅­μ–΄ μ—μ΄μ „νŠΈ β”‚ β”œβ”€β”€ frontend-developer.md β”‚ β”œβ”€β”€ backend-engineer.md β”‚ └── ... β”œβ”€β”€ ja/ # 일본어 μ—μ΄μ „νŠΈ └── zh/ # 쀑ꡭ어 μ—μ΄μ „νŠΈ \`\`\` ## μ—μ΄μ „νŠΈ 파일 ν˜•μ‹ 각 μ—μ΄μ „νŠΈ νŒŒμΌμ€ YAML frontmatter와 Markdown μ½˜ν…μΈ λ‘œ κ΅¬μ„±λ©λ‹ˆλ‹€: \`\`\`markdown --- name: frontend-developer description: UI/UX implementation specialist with React, Vue, and modern web technologies expertise. tools: Read, Write, Edit, MultiEdit, Bash, WebSearch --- You are a frontend engineer specializing in modern web applications. Focus areas: - Build responsive and accessible interfaces - Implement state management solutions - Optimize performance and bundle sizes - Ensure cross-browser compatibility - Write maintainable component architectures Key practices: - Follow semantic HTML standards - Implement WCAG accessibility guidelines - Use modern CSS features (Grid, Flexbox) - Optimize for Core Web Vitals - Write comprehensive tests \`\`\` ## 메타데이터 ν•„λ“œ ### name (ν•„μˆ˜) μ—μ΄μ „νŠΈμ˜ 고유 μ‹λ³„μžμž…λ‹ˆλ‹€. 파일λͺ…κ³Ό μΌμΉ˜ν•΄μ•Ό ν•©λ‹ˆλ‹€. ### description (ν•„μˆ˜) μ—μ΄μ „νŠΈμ˜ μ—­ν• κ³Ό 전문성을 μ„€λͺ…ν•©λ‹ˆλ‹€. 검색에 μ‚¬μš©λ©λ‹ˆλ‹€. ### tools (ν•„μˆ˜) μ—μ΄μ „νŠΈκ°€ μ‚¬μš©ν•  수 μžˆλŠ” 도ꡬ λͺ©λ‘μž…λ‹ˆλ‹€. **μ‚¬μš© κ°€λŠ₯ν•œ 도ꡬ:** - Read, Write, Edit, MultiEdit - Bash, Grep, Glob - WebSearch, WebFetch - TodoWrite, Task - NotebookRead, NotebookEdit ## λ‹€κ΅­μ–΄ 지원 ### 언어별 ν‚€ λ§€ν•‘ - μ˜μ–΄: \`agent-name\` - 기타 μ–Έμ–΄: \`agent-name-{μ–Έμ–΄μ½”λ“œ}\` 예: - \`frontend-developer\` (μ˜μ–΄) - \`frontend-developer-ko\` (ν•œκ΅­μ–΄) - \`frontend-developer-ja\` (일본어) ### μ–Έμ–΄ 감지 1. μš”μ²­λœ 언어에 λ”°λ₯Έ μ—μ΄μ „νŠΈ 검색 2. ν•΄λ‹Ή μ–Έμ–΄κ°€ μ—†μœΌλ©΄ μ˜μ–΄ 버전 μ‚¬μš© 3. λͺ¨λ‘ μ—†μœΌλ©΄ GitHubμ—μ„œ λ‹€μš΄λ‘œλ“œ μ‹œλ„ ## μ—μ΄μ „νŠΈ ν’ˆμ§ˆ κΈ°μ€€ ### ν•„μˆ˜ μš”μ†Œ 1. λͺ…ν™•ν•œ μ—­ν•  μ •μ˜ 2. ꡬ체적인 μ±…μž„ λ²”μœ„ 3. μ‹€μš©μ μΈ κ°€μ΄λ“œλΌμΈ 4. 도ꡬ μ μ ˆν•œ 선택 ### ꢌμž₯ ꡬ쑰 1. μ—­ν•  μ†Œκ°œ 2. 핡심 ν™œλ™/μ±…μž„ 3. μ£Όμš” κ΄€ν–‰ 4. ν’ˆμ§ˆ κΈ°μ€€ 5. ν˜‘μ—… 방식 ## μ—μ΄μ „νŠΈ 생성 κ°€μ΄λ“œ μƒˆ μ—μ΄μ „νŠΈλ₯Ό λ§Œλ“€ λ•Œ: 1. κΈ°μ‘΄ μ—μ΄μ „νŠΈ μ°Έκ³  2. μΌκ΄€λœ ν˜•μ‹ μœ μ§€ 3. 언어별 λ²ˆμ—­ 제곡 4. μ μ ˆν•œ 도ꡬ 선택 5. ꡬ체적이고 μ‹€μš©μ μΈ λ‚΄μš© μž‘μ„± `, }, ], }; default: throw new Error(`Unknown resource: ${uri}`); } }); // Define tools server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ { name: 'analyze-project', description: 'Analyze a project directory and recommend suitable sub-agents', inputSchema: { type: 'object', properties: { projectPath: { type: 'string', description: 'Path to the project directory to analyze', }, }, required: ['projectPath'], }, }, { name: 'ai-analyze-project', description: 'Perform AI-powered comprehensive project analysis and agent recommendations', inputSchema: { type: 'object', properties: { claudeMdPath: { type: 'string', description: 'Path to CLAUDE.md file or project description', }, projectPath: { type: 'string', description: 'Optional path to project root directory (defaults to CLAUDE.md directory)', }, generateRecommendations: { type: 'boolean', description: 'Whether to generate agent recommendations', default: true, }, maxRecommendations: { type: 'number', description: 'Maximum number of agent recommendations to return', default: 10, }, }, required: ['claudeMdPath'], }, }, { name: 'agent-download', description: 'AI-powered agent downloader - analyze project and download recommended agents', inputSchema: { type: 'object', properties: { targetDir: { type: 'string', description: 'Target directory for agent files', default: './.claude/agents', }, claudeMdPath: { type: 'string', description: 'Path to CLAUDE.md file', default: './CLAUDE.md', }, format: { type: 'string', enum: ['md', 'yaml', 'json'], description: 'Agent file format', default: 'md', }, language: { type: 'string', enum: ['en', 'ko', 'ja', 'zh'], description: 'Preferred language for agents', default: 'en', }, limit: { type: 'number', description: 'Maximum number of agents to download', default: 10, minimum: 1, maximum: 20, }, dryRun: { type: 'boolean', description: 'Preview recommendations without downloading', default: false, }, overwrite: { type: 'boolean', description: 'Overwrite existing agent files', default: false, }, }, }, }, { name: 'agents', description: 'Search, list, get details, recommend agents, or request new ones', inputSchema: { type: 'object', properties: { action: { type: 'string', description: 'Action to perform', enum: ['search', 'list', 'details', 'recommend', 'request'], }, query: { type: 'string', description: 'Search query (for search action) or agent name (for details action)', }, keywords: { type: 'array', items: { type: 'string' }, description: 'Keywords for recommendation (for recommend action)', }, language: { type: 'string', description: 'Language preference', enum: ['en', 'ko', 'ja', 'zh'], default: 'en', }, category: { type: 'string', description: 'Filter by category (for list action)', enum: ['development', 'data', 'design', 'management', 'marketing', 'operations', 'hr', 'finance', 'legal', 'research', 'healthcare', 'education', 'media', 'manufacturing', 'other'], }, autoCreateIssue: { type: 'boolean', description: 'Auto-create GitHub issue if no agents found (for search action)', default: false, }, issueBody: { type: 'string', description: 'Additional details for the issue (when autoCreateIssue is true)', }, }, required: ['action'], }, }, { name: 'manage-agents', description: 'Install agents, get stats, or refresh from GitHub', inputSchema: { type: 'object', properties: { action: { type: 'string', description: 'Management action to perform', enum: ['install', 'stats', 'refresh', 'version'], }, agentNames: { type: 'array', items: { type: 'string' }, description: 'Agent names to install (for install action)', }, targetPath: { type: 'string', description: 'Target directory for installation (for install action)', }, language: { type: 'string', description: 'Language preference for agents', enum: ['en', 'ko', 'ja', 'zh'], default: 'en', }, limit: { type: 'number', description: 'Number of top agents to show in stats', default: 10, }, }, required: ['action'], }, }, ], }; }); // Handle tool calls server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; // Track tool usage trackEvent(AnalyticsEvents.TOOL_CALLED, { tool_name: name, args_provided: Object.keys(args || {}), }); switch (name) { case 'analyze-project': { const { projectPath } = args; const analysis = await projectAnalyzer.analyzeProject(projectPath); // Track project analysis trackEvent(AnalyticsEvents.PROJECT_ANALYZED, { project_types: analysis.projectType, technologies: analysis.technologies, recommended_count: analysis.recommendedAgents.length, confidence: analysis.confidence, }); return { content: [ { type: 'text', text: JSON.stringify({ success: true, analysis, message: `Analyzed project at ${projectPath}. Found ${analysis.projectType.length} project types and recommended ${analysis.recommendedAgents.length} agents.`, }, null, 2), }, ], }; } case 'ai-analyze-project': { const { claudeMdPath, projectPath, generateRecommendations = true, maxRecommendations = 10 } = args; try { // Perform AI-powered project analysis const analysis = await aiAnalysisService.analyzeProject(claudeMdPath, projectPath); let recommendations = []; if (generateRecommendations) { const allRecommendations = await aiAnalysisService.generateRecommendations(analysis); recommendations = allRecommendations.slice(0, maxRecommendations); } // Track AI analysis event trackEvent(AnalyticsEvents.PROJECT_ANALYZED, { project_types: analysis.projectType, technologies: analysis.technologies, recommended_count: recommendations.length, confidence: analysis.complexity / 10, // Normalize complexity as confidence ai_powered: true, }); return { content: [ { type: 'text', text: JSON.stringify({ success: true, analysis: { projectType: analysis.projectType, technologies: analysis.technologies, frameworks: analysis.frameworks, complexity: analysis.complexity, phase: analysis.phase, teamSize: analysis.teamSize, description: analysis.description, goals: analysis.goals, requirements: analysis.requirements, architecturalPatterns: analysis.architecturalPatterns, developmentPractices: analysis.developmentPractices, qualityIndicators: analysis.qualityIndicators, }, recommendations: recommendations.map(rec => ({ name: rec.name, description: rec.description, relevanceScore: rec.relevanceScore, reasoning: rec.reasoning, category: rec.category, priority: rec.priority, tools: rec.tools, specificTasks: rec.specificTasks, integrationPoints: rec.integrationPoints, })), message: `AI analysis completed for ${path.basename(claudeMdPath)}. Project type: ${analysis.projectType}, Complexity: ${analysis.complexity}/10, Recommended ${recommendations.length} agents.`, aiFeatures: { intelligentAnalysis: 'Comprehensive project understanding using AI reasoning', contextAwareRecommendations: 'Agent suggestions based on project context and requirements', dynamicPrioritization: 'Smart priority assignment based on project needs', taskSpecificMatching: 'Agents matched to specific tasks and integration points' } }, null, 2), }, ], }; } catch (error) { return { content: [ { type: 'text', text: JSON.stringify({ success: false, error: `AI analysis failed: ${error instanceof Error ? error.message : String(error)}`, suggestion: 'Please check the CLAUDE.md file path and project structure', }, null, 2), }, ], }; } } case 'agent-download': { const { targetDir = './.claude/agents', claudeMdPath = './CLAUDE.md', format = 'md', language = 'en', limit = 10, dryRun = false, overwrite = false } = args; try { const downloader = new AgentDownloader(); const options = { targetDir, claudeMdPath, format, language, limit, dryRun, overwrite }; const result = await downloader.downloadAgents(options); // Track agent download event trackEvent(AnalyticsEvents.PROJECT_ANALYZED, { project_types: result.analysis.projectType, technologies: result.analysis.technologies, recommended_count: result.recommendations.length, confidence: result.analysis.complexity / 10, ai_powered: true, dry_run: dryRun, downloaded_count: result.downloaded?.length || 0, }); return { content: [ { type: 'text', text: JSON.stringify({ success: true, dryRun, analysis: { projectType: result.analysis.projectType, technologies: result.analysis.technologies, frameworks: result.analysis.frameworks, complexity: result.analysis.complexity, phase: result.analysis.phase, teamSize: result.analysis.teamSize, description: result.analysis.description, qualityIndicators: result.analysis.qualityIndicators, architecturalPatterns: result.analysis.architecturalPatterns, developmentPractices: result.analysis.developmentPractices, }, recommendations: result.recommendations.map(rec => ({ name: rec.name, description: rec.description, relevanceScore: rec.relevanceScore, reasoning: rec.reasoning, category: rec.category, priority: rec.priority, tools: rec.tools, specificTasks: rec.specificTasks, integrationPoints: rec.integrationPoints, })), downloaded: result.downloaded || [], message: dryRun ? `AI analysis preview completed. Found ${result.recommendations.length} recommended agents for your ${result.analysis.projectType} project.` : `Successfully downloaded ${result.downloaded?.length || 0} AI-recommended agents to ${targetDir}.`, aiFeatures: { intelligentAnalysis: 'Comprehensive project understanding using AI reasoning', contextAwareRecommendations: 'Agent suggestions based on project context and requirements', dynamicPrioritization: 'Smart priority assignment based on project needs', taskSpecificMatching: 'Agents matched to specific tasks and integration points', automaticDownload: 'Seamless agent file creation with enhanced documentation' } }, null, 2), }, ], }; } catch (error) { return { content: [ { type: 'text', text: JSON.stringify({ success: false, error: `Agent download failed: ${error instanceof Error ? error.message : String(error)}`, suggestion: 'Please check the CLAUDE.md file path and ensure write permissions for the target directory', }, null, 2), }, ], }; } } case 'agents': { const { action, query, keywords, language = 'en', category, autoCreateIssue = false, issueBody } = args; switch (action) { case 'search': { if (!query) { return { content: [ { type: 'text', text: JSON.stringify({ success: false, error: 'Query is required for search action', }, null, 2), }, ], }; } const agents = agentManager.searchAgents(query); const filteredAgents = agents.filter(agent => !language || agent.language === language); // Track search event trackEvent(AnalyticsEvents.AGENT_SEARCHED, { query, language, found_count: filteredAgents.length, auto_create_issue: autoCreateIssue, }); // Auto-create issue if no agents found and autoCreateIssue is true if (filteredAgents.length === 0 && autoCreateIssue) { const githubToken = process.env.GITHUB_TOKEN; if (!githubToken) { // Generate GitHub issue creation URL with pre-filled content const issueTitle = encodeURIComponent(`[Agent Request] ${query} - New agent needed`); const issueBodyContent = encodeURIComponent(`## Agent Request **Role Name**: ${query} **Language**: ${language} ## Description ${issueBody || 'A new agent is needed for this role.'} ## Use Cases - [Please describe specific use cases] ## Required Tools - [List required tools like Read, Write, Edit, etc.] ## Additional Details - No existing agents found matching: "${query}" - Please consider adding this agent to help users with this use case.`); const createIssueUrl = `https://github.com/hongsw/claude-agents-power-mcp-server/issues/new?title=${issueTitle}&body=${issueBodyContent}&labels=agent-request`; return { content: [ { type: 'text', text: JSON.stringify({ success: false, error: 'No agents found. GitHub token not configured for auto-issue creation.', suggestion: 'Click the link below to create an issue manually:', createIssueUrl, message: `πŸ” No agents found for "${query}"\n\nπŸ“ You can create an issue manually by clicking this link:\n${createIssueUrl}\n\nπŸ’‘ Or set GITHUB_TOKEN environment variable for automatic issue creation.`, }, null, 2), }, ], }; } try { const issueTitle = `[Agent Request] ${query} - New agent needed`; const issueBodyContent = `## Agent Request **Role Name**: ${query} **Language**: ${language} ## Description ${issueBody || 'A new age