claude-code - 💡(How to fix) Fix [BUG] User-scoped MCP servers in .claude.json never launch when using CLAUDE_CONFIG_DIR [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#48448Fetched 2026-04-16 06:59:52
View on GitHub
Comments
2
Participants
2
Timeline
7
Reactions
0
Author
Timeline (top)
labeled ×3commented ×2closed ×1cross-referenced ×1

When using CLAUDE_CONFIG_DIR to point Claude Code at a non-default config directory (e.g., ~/.claude-jobb instead of ~/.claude), user-scoped MCP servers configured in the top-level mcpServers section of .claude.json are shown in /mcp but never actually launched. The process is never spawned — no connection attempt is made at all.

Root Cause

When using CLAUDE_CONFIG_DIR to point Claude Code at a non-default config directory (e.g., ~/.claude-jobb instead of ~/.claude), user-scoped MCP servers configured in the top-level mcpServers section of .claude.json are shown in /mcp but never actually launched. The process is never spawned — no connection attempt is made at all.

Fix Action

Workaround

Use a project-level .mcp.json file instead, and pre-approve it by manually adding the server name to enabledMcpjsonServers in the project entry within .claude.json:

  1. Create .mcp.json in the project root:

    {
      "mcpServers": {
        "my-mcp-server": {
          "command": "/absolute/path/to/mcp-server.sh",
          "args": []
        }
      }
    }
  2. In $CLAUDE_CONFIG_DIR/.claude.json, find the project entry and add:

    "enabledMcpjsonServers": ["my-mcp-server"]
  3. Restart Claude Code — the server connects successfully.

Code Example

#!/bin/bash
   export CLAUDE_CONFIG_DIR=~/.claude-alt
   claude "$@"

---

./claude-alt mcp add-json --scope user my-mcp-server \
     '{"type":"stdio","command":"/path/to/mcp-server.sh","args":[]}'

---

{
     "mcpServers": {
       "my-mcp-server": {
         "command": "/absolute/path/to/mcp-server.sh",
         "args": []
       }
     }
   }

---

"enabledMcpjsonServers": ["my-mcp-server"]
RAW_BUFFERClick to expand / collapse

Description

When using CLAUDE_CONFIG_DIR to point Claude Code at a non-default config directory (e.g., ~/.claude-jobb instead of ~/.claude), user-scoped MCP servers configured in the top-level mcpServers section of .claude.json are shown in /mcp but never actually launched. The process is never spawned — no connection attempt is made at all.

Steps to reproduce

  1. Create a wrapper script that uses a custom config directory:

    #!/bin/bash
    export CLAUDE_CONFIG_DIR=~/.claude-alt
    claude "$@"
  2. Add an MCP server via the wrapper:

    ./claude-alt mcp add-json --scope user my-mcp-server \
      '{"type":"stdio","command":"/path/to/mcp-server.sh","args":[]}'
  3. Verify it's stored in ~/.claude-alt/.claude.json under the top-level mcpServers key.

  4. Start a session with the wrapper and run /mcp.

  5. The server shows up in the list but status is failed. Pressing r to reconnect says "Failed to reconnect".

  6. The MCP server process is never spawned (verified by wrapping the command in a debug script that logs to /tmp — no log file is created).

Additional observations

  • claude mcp add-json --scope user also silently drops the cwd field from the JSON config.
  • Plugin-provided MCP servers (e.g., from marketplace plugins) work fine in the same session.
  • The same MCP server works perfectly when tested manually from the terminal.

Workaround

Use a project-level .mcp.json file instead, and pre-approve it by manually adding the server name to enabledMcpjsonServers in the project entry within .claude.json:

  1. Create .mcp.json in the project root:

    {
      "mcpServers": {
        "my-mcp-server": {
          "command": "/absolute/path/to/mcp-server.sh",
          "args": []
        }
      }
    }
  2. In $CLAUDE_CONFIG_DIR/.claude.json, find the project entry and add:

    "enabledMcpjsonServers": ["my-mcp-server"]
  3. Restart Claude Code — the server connects successfully.

Environment

  • Claude Code version: 2.1.109
  • OS: macOS (Darwin 25.4.0, arm64)
  • Shell: zsh
  • Use case: Separating work and personal Claude Code configurations via CLAUDE_CONFIG_DIR

Related issues

  • #4938 — Multiple mcpServers sections silently override each other
  • #15797 — MCP configuration file location detection issues
  • #5037 — MCP servers in .claude/.mcp.json not loading properly

extent analysis

TL;DR

The issue can be worked around by using a project-level .mcp.json file instead of the top-level mcpServers section in .claude.json for user-scoped MCP servers when using a non-default config directory.

Guidance

  • When using a custom CLAUDE_CONFIG_DIR, consider using project-level .mcp.json files for user-scoped MCP servers to avoid launch issues.
  • Verify that the MCP server is correctly configured in the .mcp.json file and that its name is added to enabledMcpjsonServers in the project entry of .claude.json.
  • Ensure the command path in the .mcp.json file is absolute to avoid any resolution issues.
  • If issues persist, check related issues (#4938, #15797, #5037) for potential configuration conflicts or detection problems.

Example

// Example .mcp.json file
{
  "mcpServers": {
    "my-mcp-server": {
      "command": "/absolute/path/to/mcp-server.sh",
      "args": []
    }
  }
}

Notes

  • This workaround may not address the root cause of the issue but provides a functional alternative for managing MCP servers with non-default config directories.
  • Be aware of potential configuration overrides or detection issues as noted in related problems.

Recommendation

Apply workaround: Using a project-level .mcp.json file is a viable alternative for configuring user-scoped MCP servers when the default approach fails due to non-standard config directory usage.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING