claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] Inconsistent Behavior Between CLI and VS Code Extension with Enterprise MCP Configuration

Open cjpeterein opened this issue 2 months ago • 8 comments

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

The Claude Code VS Code extension crashes with exit code 1 when /etc/claude-code/managed-mcp.json exists, while the Claude CLI handles the same configuration without issues. This behavior is undocumented and creates an inconsistent user experience across Claude Code implementations.

What Should Happen?

Based on the MCP documentation, enterprise MCP configuration should have "highest precedence" but should not prevent Claude Code from starting. Both CLI and VS Code extension should handle enterprise MCP configuration consistently.

Error Messages/Logs

2025-11-18 22:35:04.070 [info] From claude: You cannot dynamically configure your MCP configuration when an enterprise MCP config is present
2025-11-18 22:35:04.076 [info] From claude: Claude Code process exited with code 1
2025-11-18 22:35:04.076 [error] Error from Claude (on channel kgdqeltnvdl): Error: Claude Code process exited with code 1

Steps to Reproduce

Reproducible Test Case

#!/bin/bash
# Test script to reproduce the issue

echo "Setting up enterprise MCP config..."
sudo mkdir -p /etc/claude-code
sudo tee /etc/claude-code/managed-mcp.json > /dev/null <<'EOF'
{
    "mcpServers": {
        "test-server": {
            "type": "stdio",
            "command": "echo",
            "args": ["test"]
        }
    }
}
EOF

echo "Adding user MCP server..."
claude mcp add --transport stdio test-user-server -- echo test-user

echo "Testing CLI..."
if claude mcp list &>/dev/null; then
    echo "✓ CLI works with enterprise config present"
else
    echo "✗ CLI fails with enterprise config present"
fi

echo ""
echo "Testing VS Code extension..."
echo "1. Open VS Code"
echo "2. Try to use Claude Code extension"
echo "3. Check if extension starts or crashes"
echo ""
echo "Expected: Both should work"
echo "Actual: VS Code extension crashes, CLI works"

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.0.45 (Claude Code)

Platform

AWS Bedrock

Operating System

Ubuntu/Debian Linux

Terminal/Shell

Other

Additional Information

No response

cjpeterein avatar Nov 18 '25 23:11 cjpeterein

Found 1 possible duplicate issue:

  1. https://github.com/anthropics/claude-code/issues/3098

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

github-actions[bot] avatar Nov 18 '25 23:11 github-actions[bot]

The documentation says "The managed-mcp.json file uses the same format as a standard .mcp.json file." I have verified that when this code is in the /<project>/.mcp.json file, the MCP server is configured and listed when 'claude mcp list' is run, and that the Claude Code extension for VS Code works.

{
    "mcpServers": {
        "test-server": {
            "type": "stdio",
            "command": "echo",
            "args": ["test"]
        }
    }
}

When the same code is in C:\ProgramData\ClaudeCode\managed-mcp.json, the MCP server is still configured and is listed when 'claude mcp list' is run, but the VS Code extension fails with this message: Error: Claude Code process exited with code 1

In the VS Code output, I see this, as noted in the OP:

2025-11-19 11:04:57.827 [info] From claude: You cannot dynamically configure your MCP configuration when an enterprise MCP config is present
2025-11-19 11:04:57.854 [info] From claude: Claude Code process exited with code 1
2025-11-19 11:04:57.854 [info] Closing Claude on channel: 2m8nergyf1j
2025-11-19 11:04:57.858 [error] Error from Claude (on channel 2m8nergyf1j): Error: Claude Code process exited with code 1

dkbush avatar Nov 19 '25 16:11 dkbush

We are running into the same issues (but on macOS) and as far as I can tell this stopped working after 2.0.37

Image

In 2.0.37

2025-11-20 15:37:18.905 [info] From claude: [DEBUG] [LSP MANAGER] initializeLspServerManager() called
[DEBUG] [LSP MANAGER] Created manager instance, state=pending
[DEBUG] [LSP MANAGER] Starting async initialization (generation 1)

2025-11-20 15:37:18.905 [info] From claude: [DEBUG] [LSP SERVER MANAGER] initialize() called
[DEBUG] [LSP SERVER MANAGER] Calling getAllLspServers()

2025-11-20 15:37:18.912 [info] From claude: [DEBUG] Found 0 plugins (0 enabled, 0 disabled)

2025-11-20 15:37:18.913 [info] From claude: [DEBUG] Found 0 plugins (0 enabled, 0 disabled)

2025-11-20 15:37:18.914 [info] From claude: [DEBUG] Total LSP servers loaded: 0

2025-11-20 15:37:18.914 [info] From claude: [DEBUG] Total LSP servers loaded: 0

2025-11-20 15:37:18.915 [info] From claude: [DEBUG] [LSP SERVER MANAGER] getAllLspServers returned 0 server(s)
[DEBUG] LSP manager initialized with 0 servers

2025-11-20 15:37:18.915 [info] From claude: [DEBUG] [LSP SERVER MANAGER] getAllLspServers returned 0 server(s)
[DEBUG] LSP manager initialized with 0 servers

in 2.0.42 and later (up until 2.0.47)

2025-11-20 15:41:55.333 [info] From claude: 2025-11-20T14:41:55.333Z [DEBUG] [LSP MANAGER] Created manager instance, state=pending
2025-11-20T14:41:55.333Z [DEBUG] [LSP MANAGER] Starting async initialization (generation 1)
2025-11-20T14:41:55.333Z [DEBUG] [LSP SERVER MANAGER] initialize() called
2025-11-20T14:41:55.333Z [DEBUG] [LSP SERVER MANAGER] Calling getAllLspServers()

2025-11-20 15:41:55.338 [info] From claude: You cannot dynamically configure your MCP configuration when an enterprise MCP config is present
2025-11-20 15:41:55.341 [info] From claude: 2025-11-20T14:41:55.340Z [DEBUG] Found 0 plugins (0 enabled, 0 disabled)

2025-11-20 15:41:55.342 [info] From claude: 2025-11-20T14:41:55.342Z [DEBUG] Total LSP servers loaded: 0

2025-11-20 15:41:55.344 [info] From claude: Claude Code process exited with code 1
2025-11-20 15:41:55.344 [info] Closing Claude on channel: iz9cduv1c1h
2025-11-20 15:41:55.345 [error] Error from Claude (on channel iz9cduv1c1h): Error: Claude Code process exited with code 1

The useTerminal option works with all versions just to be clear

An interesting note is that it seems that the extension is actually continuing after the error when looking at the logs but the channel for the client is dead so you can't communicate with it

tcvall86 avatar Nov 20 '25 14:11 tcvall86

Can confirm that this got fixed when I switched back to version 2.0.52

mrafayaleem avatar Nov 25 '25 00:11 mrafayaleem

Hmm @mrafayaleem when I try I still run into the same issue both with 2.0.52 and 2.0.53

2025-11-25 09:04:17.105 [info] Launching Claude on channel: 10y8fehx5rj
2025-11-25 09:04:17.105 [info] Spawning Claude with SDK query function - cwd: /Users/thomas.cannervall/Documents, permission mode: default, version: 2.0.53, /Users/thomas.cannervall/.vscode/extensions/anthropic.claude-code-2.0.53-darwin-arm64/resources/native-binary/claude, resume: undefined
2025-11-25 09:04:17.105 [info] From claude: Spawning Claude Code native binary: /Users/thomas.cannervall/.vscode/extensions/anthropic.claude-code-2.0.53-darwin-arm64/resources/native-binary/claude --output-format stream-json --verbose --input-format stream-json --append-system-prompt 
2025-11-25 09:04:17.517 [info] From claude: 2025-11-25T08:04:17.517Z [DEBUG] [LSP MANAGER] Created manager instance, state=pending
2025-11-25T08:04:17.517Z [DEBUG] [LSP MANAGER] Starting async initialization (generation 1)

2025-11-25 09:04:17.517 [info] From claude: 2025-11-25T08:04:17.517Z [DEBUG] [LSP SERVER MANAGER] initialize() called
2025-11-25T08:04:17.517Z [DEBUG] [LSP SERVER MANAGER] Calling getAllLspServers()

2025-11-25 09:04:17.521 [info] From claude: 2025-11-25T08:04:17.521Z [DEBUG] Found 0 plugins (0 enabled, 0 disabled)

2025-11-25 09:04:17.521 [info] From claude: 2025-11-25T08:04:17.521Z [DEBUG] Found 0 plugins (0 enabled, 0 disabled)

2025-11-25 09:04:17.522 [info] From claude: You cannot dynamically configure your MCP configuration when an enterprise MCP config is present
2025-11-25 09:04:17.525 [info] From claude: 2025-11-25T08:04:17.525Z [DEBUG] Total LSP servers loaded: 0

2025-11-25 09:04:17.526 [info] From claude: 2025-11-25T08:04:17.526Z [DEBUG] [LSP SERVER MANAGER] getAllLspServers returned 0 server(s)
2025-11-25T08:04:17.526Z [DEBUG] LSP manager initialized with 0 servers

2025-11-25 09:04:17.527 [info] From claude: 2025-11-25T08:04:17.527Z [DEBUG] LSP server manager initialized successfully

2025-11-25 09:04:17.527 [info] From claude: 2025-11-25T08:04:17.527Z [DEBUG] LSP notification handlers registered successfully for all 0 server(s)

2025-11-25 09:04:17.529 [info] Closing Claude on channel: 10y8fehx5rj
2025-11-25 09:04:17.529 [error] Error from Claude (on channel 10y8fehx5rj): Error: Claude Code process exited with code 1

tcvall86 avatar Nov 25 '25 08:11 tcvall86

I see the same issue with version 2.0.55.

dkbush avatar Dec 02 '25 20:12 dkbush

Still and issue with 2.0.58 I am surprised anthropic makes no effort to fix this since the terminal is considered legacy.

tcvall86 avatar Dec 04 '25 08:12 tcvall86

Still exists with 2.0.60

mstruck avatar Dec 08 '25 18:12 mstruck

This seems to work now again in 2.0.73 atleast, unsure in which version this got fixed

2025-12-18T06:50:59.557Z [DEBUG] [LSP MANAGER] Created manager instance, state=pending
2025-12-18T06:50:59.557Z [DEBUG] [LSP MANAGER] Starting async initialization (generation 1)

2025-12-18 07:50:59.558 [info] From claude: 2025-12-18T06:50:59.558Z [DEBUG] [LSP MANAGER] initializeLspServerManager() called

2025-12-18 07:50:59.558 [info] From claude: 2025-12-18T06:50:59.558Z [DEBUG] [LSP MANAGER] Created manager instance, state=pending
2025-12-18T06:50:59.558Z [DEBUG] [LSP MANAGER] Starting async initialization (generation 1)

2025-12-18 07:50:59.559 [info] From claude: 2025-12-18T06:50:59.559Z [ERROR] Failed to save config with lock: Error: Lock file is already being held

.
.
.

2025-12-18 07:50:59.560 [info] From claude: 2025-12-18T06:50:59.560Z [DEBUG] LSP server manager initialized successfully

2025-12-18 07:50:59.560 [info] From claude: 2025-12-18T06:50:59.560Z [DEBUG] LSP notification handlers registered successfully for all 0 server(s)

2025-12-18 07:50:59.560 [info] From claude: 2025-12-18T06:50:59.560Z [DEBUG] LSP server manager initialized successfully
2025-12-18T06:50:59.560Z [DEBUG] LSP notification handlers registered successfully for all 0 server(s)

tcvall86 avatar Dec 18 '25 06:12 tcvall86

I ran the test I used above with v2.0.72, and the VSCode extension does not crash. Yesterday, I was testing with v2.0.65 and it was crashing. Here's a snippet from the logs using v2.0.72:

2025-12-18 15:04:55.473 [info] From claude: 2025-12-18T20:04:55.474Z [DEBUG] [LSP MANAGER] initializeLspServerManager() called 2025-12-18T20:04:55.474Z [DEBUG] [LSP MANAGER] Created manager instance, state=pending

2025-12-18 15:04:55.474 [info] From claude: 2025-12-18T20:04:55.474Z [DEBUG] [LSP MANAGER] Starting async initialization (generation 1)

2025-12-18 15:04:55.481 [info] From claude: 2025-12-18T20:04:55.480Z [DEBUG] LSP server manager initialized successfully 2025-12-18T20:04:55.480Z [DEBUG] LSP notification handlers registered successfully for all 0 server(s)

dkbush avatar Dec 18 '25 20:12 dkbush