ENABLE_CLAUDEAI_MCP_SERVERS env var is not read (v2.1.49)

Resolved 💬 2 comments Opened Mar 11, 2026 by dorn Closed Apr 9, 2026

Bug Description

The ENABLE_CLAUDEAI_MCP_SERVERS environment variable is intended to disable cloud-injected MCP servers from Claude.ai account settings when running Claude Code CLI. However, the env var is never actually read — the check passes void 0 (undefined) instead of reading process.env.ENABLE_CLAUDEAI_MCP_SERVERS.

Steps to Reproduce

  1. Configure an MCP server in your Claude.ai account settings (e.g., via integrations)
  2. Set export ENABLE_CLAUDEAI_MCP_SERVERS=false before launching claude
  3. Start Claude Code — the cloud-configured MCP server still connects

Root Cause

In cli.js (minified), the claudeai-mcp initialization function checks the feature gate tengu_claudeai_mcp_connectors, then is supposed to check the env var:

// Gate check (works correctly)
let A = t2($c9); // tengu_claudeai_mcp_connectors
if (!A) return C("[claudeai-mcp] Disabled via gate"), ...;

// Env var check (BROKEN — passes undefined instead of the env var)
if (E2(void 0)) return C("[claudeai-mcp] Disabled via env var"), ...;

E2(void 0) always returns false because the function's first line is:

function E2(A) {
  if (A === void 0) return !1; // undefined → false → never disabled
  ...
}

The fix is to pass the actual env var:

if (E2(process.env.ENABLE_CLAUDEAI_MCP_SERVERS)) return ...;

Use Case

This matters for users who configure MCP servers in their Claude.ai account for the web UI but want Claude Code CLI instances to use separate, locally-configured MCP servers with different identities. Without the env var working, the cloud-injected MCP server connects in addition to (or instead of) the local one, using the wrong identity.

Environment

  • Claude Code version: 2.1.49
  • Platform: Windows (MINGW64/Git Bash)

Workaround

Manually patching cli.js line 1939: replace E2(void 0) with E2(process.env.ENABLE_CLAUDEAI_MCP_SERVERS) in the claudeai-mcp context.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗