claude-memory/graph/fixes/mcp-manager-was-writing-to-wrong-config-path-claudemcpjson-i-b3c2d4.md

59 lines
2.3 KiB
Markdown

---
id: b3c2d454-3b8e-4d3d-b24c-6241f12d03e6
type: fix
title: "MCP manager was writing to wrong config path - ~/.claude/.mcp.json instead of project .mcp.json"
tags: [mcp, claude-code, mcp-manager, fix, configuration]
importance: 0.9
confidence: 0.8
created: "2026-02-20T03:52:57.247423+00:00"
updated: "2026-03-02T02:14:29.434717+00:00"
relations:
- target: 6665d42a-0c52-4684-999b-bf8982439069
type: RELATED_TO
direction: incoming
strength: 0.8
edge_id: c5f3eaf4-f2d6-453f-b51e-e8f24217bb91
- target: 967ad46d-ba89-4207-b870-db4b8558f2bb
type: RELATED_TO
direction: incoming
strength: 0.6
edge_id: e5ad2593-dfdc-480f-ac61-6f12405ce71c
- target: d746c584-c625-4710-b2a7-bba205e2e92d
type: RELATED_TO
direction: incoming
strength: 0.85
edge_id: 94d49cef-b3c7-4721-a856-2bfc3158d323
---
## Problem
The mcp-manager skill's `mcp_control.py` was reading/writing `~/.claude/.mcp.json`, but Claude Code does NOT read that file. Claude Code reads MCP config from two locations:
1. **Global**: `~/.claude.json``mcpServers` key (always-on MCPs like cognitive-memory)
2. **Project**: `<project-root>/.mcp.json``mcpServers` key (on-demand MCPs)
This meant n8n-mcp was correctly configured in `~/.claude/.mcp.json` but never loaded by Claude Code, even after multiple session restarts.
## Root Cause
The original mcp_control.py had hardcoded:
```python
MCP_CONFIG = CLAUDE_DIR / ".mcp.json" # ~/.claude/.mcp.json - WRONG
```
## Fix
1. Updated `mcp_control.py` to auto-detect project root via `git rev-parse --show-toplevel` and write to `<project-root>/.mcp.json`
2. Added `GLOBAL_CONFIG` constant pointing to `~/.claude.json` for reference
3. Cleaned up stale MCP registry (removed Daniel Miessler's MCPs: httpx, naabu, apify, brightdata, Ref, stripe, content, daemon, Foundry)
4. Added `n8n-mcp` to the registry
5. Updated SKILL.md to document correct config locations
6. Also found the project-level `.mcp.json` at `/mnt/NV2/Development/claude-home/.mcp.json` had `"mcpServers": {}` which was overriding global config
## Key Lesson
Claude Code MCP config hierarchy:
- `~/.claude.json` → global, always loaded
- `<project>/.mcp.json` → project-specific, merged with global
- `~/.claude/.mcp.json` → NOT USED by Claude Code (was a mistake)