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:
- Config interpolation ${env:NAME} not working in headers for remote MCP servers (
MY_API_KEY, auto-closed) - GitHub MCP failing to start (
CURSOR_GITHUB_TOKEN, “Authorization header is badly formatted”) - Secure secret handing for MCPs (the suggested
${env:GITHUB_TOKEN}hits this)
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
_TOKENand 1 ending in_KEY. This held withBearerandBasic, and with${env:NAME}and${NAME}. - Resolved: variables ending in
_AUTH,_USERand_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_AUTHresolved. - 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
- Set two variables with the same value:
MY_SERVICE_TOKEN=abc123andMY_SERVICE_AUTH=abc123. Make sure Grok Build sees them, for example withlaunchctl setenvon macOS, then restart. - Start any HTTP endpoint that logs request headers, for example on
http://127.0.0.1:18083. - 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}" } } - Compare what the endpoint receives on
/tokenand/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