${env:NAME} in mcp.json is not resolved when NAME ends in _TOKEN or _KEY

Where does the bug appear (feature/product)?

Grok Build: MCP configuration (~/.cursor/mcp.json)

Describe the Bug

${env:NAME} in mcp.json is left unresolved when NAME ends in _TOKEN or _KEY. Grok Build sends the literal placeholder text, for example Authorization: Bearer ${env:MY_SERVICE_TOKEN}, instead of the value. Variables with other names in the same file resolve normally.

This contradicts the Config interpolation docs, whose own example is "Authorization": "Bearer ${env:MY_SERVICE_TOKEN}". It looks like the cause of these threads, where the variable names fit the pattern and no cause was found:

How I confirmed it. I pointed several mcp.json entries at a local HTTP listener that logs only the shape of the Authorization header: scheme, value length, and whether the value starts with $. All entries were added in one edit, so they loaded together from the same file in the same process. Every variable is set with launchctl setenv and visible to the app.

  • Left literal: 4 variables ending in _TOKEN and 1 ending in _KEY. This held with Bearer and Basic, and with ${env:NAME} and ${NAME}.
  • Resolved: variables ending in _AUTH, _USER and _ADMIN. One of them holds a token value, and its name ends in _ADMIN.
  • Same value, two names: a token referenced as ${env:SERVICE_TOKEN} stayed literal. A copy of the same value under a name ending in _AUTH resolved.
  • Made no difference: server name, URL, port, entry order, and hot reload versus a full restart.

The MCP logs record header names but not values, and nothing is logged when a variable is skipped. So the only visible symptom is the server rejecting the request (400 or 401). This took a header capture to find.

Suggested fix: resolve these names as documented. If the filtering is intentional, document it and log a warning naming the skipped variable.

Workaround: copy the value into a variable whose name doesn’t end in _TOKEN or _KEY:

export MY_SERVICE_AUTH="$MY_SERVICE_TOKEN"
launchctl setenv MY_SERVICE_AUTH "$MY_SERVICE_AUTH"   # macOS, so GUI apps see it
"headers": { "Authorization": "Bearer ${env:MY_SERVICE_AUTH}" }

Steps to Reproduce

  1. Set two variables with the same value: MY_SERVICE_TOKEN=abc123 and MY_SERVICE_AUTH=abc123. Make sure Grok Build sees them, for example with launchctl setenv on macOS, then restart.
  2. Start any HTTP endpoint that logs request headers, for example on http://127.0.0.1:18083.
  3. Add two entries to ~/.cursor/mcp.json:
    "test-token": { "url": "http://127.0.0.1:18083/token", "headers": { "Authorization": "Bearer ${env:MY_SERVICE_TOKEN}" } },
    "test-auth":  { "url": "http://127.0.0.1:18083/auth",  "headers": { "Authorization": "Bearer ${env:MY_SERVICE_AUTH}" } }
    
  4. Compare what the endpoint receives on /token and /auth.

Expected Behavior

Both requests carry Authorization: Bearer abc123.

Actual: /auth receives Bearer abc123, and /token receives the literal Bearer ${env:MY_SERVICE_TOKEN}.

Operating System

MacOS (26.7.3, arm64)

Version Information

Grok Build 3.32.25 (commit d3b7354f6e7809088c6623719f50cfbdf33a0480, 2026-12-01; VS Code 1.147.0)

Does this stop you from using Grok Build?

No - Grok Build works, but with this issue

Hey @OmryA,

Your read is right, and the docs example should work as written. In the new Agents Window on macOS and Linux, variables whose names end in _TOKEN, _KEY or _SECRET (any case) currently aren’t passed to the process that starts MCP servers. That leaves ${env:NAME} and ${NAME} with nothing to resolve to, so the placeholder is sent as written. It’s a known issue, and your report is linked to it.

The workaround you found is the right one for now. Any name that doesn’t end in one of those three suffixes resolves, so MY_SERVICE_AUTH works.