Skip to content

Commit ea6e22c

Browse files
committed
Fix Claude Code MCP server configuration approach
Replace incorrect mcp.json configuration with proper CLI-based setup using activation scripts. This ensures MCP servers are configured as user-scoped (global) and safely preserves Claude's existing configuration data.
1 parent 3c1a6d8 commit ea6e22c

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

common/claude-code/default.nix

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
# Create and manage ~/.claude directory
1919
home.file.".claude/settings.json".source = ./settings.json;
2020
home.file.".claude/CLAUDE.md".source = ./CLAUDE.md;
21-
home.file.".claude/.mcp.json".source = ./mcp.json;
2221

2322

2423
# Combine local commands with linear commands
@@ -54,4 +53,21 @@
5453
fi
5554
'';
5655

56+
# Setup MCP servers after Claude Code is installed
57+
home.activation.setupMcpServers = lib.hm.dag.entryAfter ["installClaudeCode"] ''
58+
PATH="${pkgs.nodejs_22}/bin:$PATH"
59+
export NPM_CONFIG_PREFIX="$HOME/.npm-global"
60+
61+
# Only add if not already configured
62+
if ! claude mcp list | grep -q "context7"; then
63+
echo "Configuring MCP servers..."
64+
claude mcp add --scope user context7 npx -y @context-labs/context7-server
65+
claude mcp add --scope user code-reasoning npx -y @mettamatt/code-reasoning
66+
claude mcp add --scope user sequential-thinking npx -y @modelcontextprotocol/server-sequential-thinking
67+
echo "MCP servers configured successfully"
68+
else
69+
echo "MCP servers already configured"
70+
fi
71+
'';
72+
5773
}

common/claude-code/mcp.json

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)