From 4265b95f3e7680dcc1ed5319d470b94b2f50dfd0 Mon Sep 17 00:00:00 2001 From: rUv Date: Tue, 15 Jul 2025 14:44:42 +0000 Subject: [PATCH] fix: correct claude-flow init configuration placement (fixes #276) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Move mcpServers from ~/.claude/settings.json to project-scoped .mcp.json - Add enabledMcpjsonServers to settings.json for proper MCP authorization - Move features and performance settings to claude-flow.config.json - Update templates, help text, and gitignore for new file structure - Fix Claude Code startup errors and enable MCP server functionality šŸ¤– Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../simple-commands/init/gitignore-updater.js | 3 +- src/cli/simple-commands/init/help.js | 5 ++- src/cli/simple-commands/init/index.js | 43 ++++++++++++++++--- .../init/templates/enhanced-templates.js | 36 +++------------- .../init/templates/settings.json | 38 ++-------------- 5 files changed, 50 insertions(+), 75 deletions(-) diff --git a/src/cli/simple-commands/init/gitignore-updater.js b/src/cli/simple-commands/init/gitignore-updater.js index 872b59b9cd..641c26cd41 100644 --- a/src/cli/simple-commands/init/gitignore-updater.js +++ b/src/cli/simple-commands/init/gitignore-updater.js @@ -11,7 +11,8 @@ import { existsSync, readTextFile, writeTextFile } from '../../node-compat.js'; const CLAUDE_FLOW_GITIGNORE_ENTRIES = ` # Claude Flow generated files .claude/settings.local.json -.claude/mcp.json +.mcp.json +claude-flow.config.json .swarm/ .hive-mind/ memory/claude-flow-data.json diff --git a/src/cli/simple-commands/init/help.js b/src/cli/simple-commands/init/help.js index a3e8a2bf67..6cc6e86a9d 100644 --- a/src/cli/simple-commands/init/help.js +++ b/src/cli/simple-commands/init/help.js @@ -58,9 +58,10 @@ export function showInitHelp() { console.log(' claude-flow init --list-backups # Show available backups'); console.log(); console.log('What gets created:'); - console.log(' • .claude/settings.json - Global configuration with hooks and features'); + console.log(' • .claude/settings.json - Claude Code configuration with hooks'); console.log(' • .claude/settings.local.json - Pre-approved MCP permissions (no prompts!)'); - console.log(' • .claude/mcp.json - MCP server configuration for easy setup'); + console.log(' • .mcp.json - Project-scoped MCP server configuration'); + console.log(' • claude-flow.config.json - Claude Flow features and performance settings'); console.log(' • .claude/commands/ directory with 20+ Claude Code slash commands'); console.log(' • CLAUDE.md with project instructions (v2.0.0 enhanced by default)'); console.log(' • memory/ directory for persistent context storage'); diff --git a/src/cli/simple-commands/init/index.js b/src/cli/simple-commands/init/index.js index 9761da9801..f94ca8ab93 100644 --- a/src/cli/simple-commands/init/index.js +++ b/src/cli/simple-commands/init/index.js @@ -988,7 +988,7 @@ async function enhancedClaudeFlowInit(flags, subArgs = []) { try { // Check existing files const existingFiles = []; - const filesToCheck = ['CLAUDE.md', '.claude/settings.json']; + const filesToCheck = ['CLAUDE.md', '.claude/settings.json', '.mcp.json', 'claude-flow.config.json']; for (const file of filesToCheck) { if (existsSync(`${workingDir}/${file}`)) { @@ -1047,7 +1047,7 @@ async function enhancedClaudeFlowInit(flags, subArgs = []) { console.log('[DRY RUN] Would create .claude/settings.local.json with default MCP permissions'); } - // Create mcp.json for easy MCP server configuration + // Create .mcp.json at project root for MCP server configuration const mcpConfig = { "mcpServers": { "claude-flow": { @@ -1064,10 +1064,39 @@ async function enhancedClaudeFlowInit(flags, subArgs = []) { }; if (!dryRun) { - await Deno.writeTextFile(`${claudeDir}/mcp.json`, JSON.stringify(mcpConfig, null, 2)); - printSuccess('āœ“ Created .claude/mcp.json for MCP server configuration'); + await Deno.writeTextFile(`${workingDir}/.mcp.json`, JSON.stringify(mcpConfig, null, 2)); + printSuccess('āœ“ Created .mcp.json at project root for MCP server configuration'); } else { - console.log('[DRY RUN] Would create .claude/mcp.json for MCP server configuration'); + console.log('[DRY RUN] Would create .mcp.json at project root for MCP server configuration'); + } + + // Create claude-flow.config.json for Claude Flow specific settings + const claudeFlowConfig = { + "features": { + "autoTopologySelection": true, + "parallelExecution": true, + "neuralTraining": true, + "bottleneckAnalysis": true, + "smartAutoSpawning": true, + "selfHealingWorkflows": true, + "crossSessionMemory": true, + "githubIntegration": true + }, + "performance": { + "maxAgents": 10, + "defaultTopology": "hierarchical", + "executionStrategy": "parallel", + "tokenOptimization": true, + "cacheEnabled": true, + "telemetryLevel": "detailed" + } + }; + + if (!dryRun) { + await Deno.writeTextFile(`${workingDir}/claude-flow.config.json`, JSON.stringify(claudeFlowConfig, null, 2)); + printSuccess('āœ“ Created claude-flow.config.json for Claude Flow settings'); + } else { + console.log('[DRY RUN] Would create claude-flow.config.json for Claude Flow settings'); } // Create command documentation @@ -1214,7 +1243,7 @@ ${commands.map(cmd => `- [${cmd}](./${cmd}.md)`).join('\n')} console.log('\n šŸ“‹ To add MCP servers manually:'); console.log(' claude mcp add claude-flow npx claude-flow@alpha mcp start'); console.log(' claude mcp add ruv-swarm npx ruv-swarm@latest mcp start'); - console.log('\n šŸ’” Or copy .claude/mcp.json to your Claude Desktop config directory'); + console.log('\n šŸ’” MCP servers are defined in .mcp.json (project scope)'); } } else if (!dryRun && !isClaudeCodeInstalled()) { console.log('\nāš ļø Claude Code CLI not detected!'); @@ -1223,7 +1252,7 @@ ${commands.map(cmd => `- [${cmd}](./${cmd}.md)`).join('\n')} console.log('\n šŸ“‹ After installing, add MCP servers:'); console.log(' claude mcp add claude-flow npx claude-flow@alpha mcp start'); console.log(' claude mcp add ruv-swarm npx ruv-swarm@latest mcp start'); - console.log('\n šŸ’” Or copy .claude/mcp.json to your Claude Desktop config directory'); + console.log('\n šŸ’” MCP servers are defined in .mcp.json (project scope)'); } // Final instructions diff --git a/src/cli/simple-commands/init/templates/enhanced-templates.js b/src/cli/simple-commands/init/templates/enhanced-templates.js index 503df94d2b..44b5c36a60 100644 --- a/src/cli/simple-commands/init/templates/enhanced-templates.js +++ b/src/cli/simple-commands/init/templates/enhanced-templates.js @@ -1259,6 +1259,10 @@ function createEnhancedSettingsJsonFallback() { "Bash(eval *)" ] }, + enabledMcpjsonServers: [ + "claude-flow", + "ruv-swarm" + ], hooks: { PreToolUse: [ { @@ -1311,36 +1315,6 @@ function createEnhancedSettingsJsonFallback() { } ] }, - mcpServers: { - "claude-flow": { - command: "npx", - args: ["claude-flow", "mcp", "start"], - env: { - CLAUDE_FLOW_HOOKS_ENABLED: "true", - CLAUDE_FLOW_TELEMETRY_ENABLED: "true", - CLAUDE_FLOW_REMOTE_READY: "true", - CLAUDE_FLOW_GITHUB_INTEGRATION: "true" - } - } - }, - includeCoAuthoredBy: true, - features: { - autoTopologySelection: true, - parallelExecution: true, - neuralTraining: true, - bottleneckAnalysis: true, - smartAutoSpawning: true, - selfHealingWorkflows: true, - crossSessionMemory: true, - githubIntegration: true - }, - performance: { - maxAgents: 10, - defaultTopology: "hierarchical", - executionStrategy: "parallel", - tokenOptimization: true, - cacheEnabled: true, - telemetryLevel: "detailed" - } + includeCoAuthoredBy: true }, null, 2); } \ No newline at end of file diff --git a/src/cli/simple-commands/init/templates/settings.json b/src/cli/simple-commands/init/templates/settings.json index b496cc6e4c..73865e5597 100644 --- a/src/cli/simple-commands/init/templates/settings.json +++ b/src/cli/simple-commands/init/templates/settings.json @@ -85,39 +85,9 @@ } ] }, - "mcpServers": { - "claude-flow": { - "command": "npx", - "args": [ - "claude-flow", - "mcp", - "start" - ], - "env": { - "CLAUDE_FLOW_HOOKS_ENABLED": "true", - "CLAUDE_FLOW_TELEMETRY_ENABLED": "true", - "CLAUDE_FLOW_REMOTE_READY": "true", - "CLAUDE_FLOW_GITHUB_INTEGRATION": "true" - } - } - }, "includeCoAuthoredBy": true, - "features": { - "autoTopologySelection": true, - "parallelExecution": true, - "neuralTraining": true, - "bottleneckAnalysis": true, - "smartAutoSpawning": true, - "selfHealingWorkflows": true, - "crossSessionMemory": true, - "githubIntegration": true - }, - "performance": { - "maxAgents": 10, - "defaultTopology": "hierarchical", - "executionStrategy": "parallel", - "tokenOptimization": true, - "cacheEnabled": true, - "telemetryLevel": "detailed" - } + "enabledMcpjsonServers": [ + "claude-flow", + "ruv-swarm" + ] } \ No newline at end of file