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

**URL:** <https://forum.cursor.com/t/env-name-in-mcp-json-is-not-resolved-when-name-ends-in-token-or-key/179948>\
**Category:** Bug Reports\
**Tags:** mcp, docs\
**Created:** [December 3, 2026, 11:52pm UTC](https://forum.cursor.com/t/env-name-in-mcp-json-is-not-resolved-when-name-ends-in-token-or-key/179948 "2026-12-03T23:52:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![OmryA](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/omrya/32/110667_2.png) [@OmryA](https://forum.cursor.com/u/OmryA)\
**Post date:** [December 3, 2026, 11:52pm UTC](https://forum.cursor.com/t/env-name-in-mcp-json-is-not-resolved-when-name-ends-in-token-or-key/179948/1 "2026-12-03T23:52:18Z")

</div>

## 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](https://cursor.com/docs/context/mcp) 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](https://forum.cursor.com/t/config-interpolation-env-name-not-working-in-headers-for-remote-mcp-servers/156069) (`MY_API_KEY`, auto-closed)
- [GitHub MCP failing to start](https://forum.cursor.com/t/github-mcp-failing-to-start/153617) (`CURSOR_GITHUB_TOKEN`, “Authorization header is badly formatted”)
- [Secure secret handing for MCPs](https://forum.cursor.com/t/secure-secret-handing-for-mcps/155638) (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 `_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`:

```bash
export MY_SERVICE_AUTH="$MY_SERVICE_TOKEN"
launchctl setenv MY_SERVICE_AUTH "$MY_SERVICE_AUTH" # macOS, so GUI apps see it

```

```json
"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`:

```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

---

<div class="post-metadata">

**Author:** ![FarhanZ](https://avatars.discourse-cdn.com/v4/letter/f/c37758/32.png) [@FarhanZ](https://forum.cursor.com/u/FarhanZ)\
**Post date:** [December 4, 2026, 3:19am UTC](https://forum.cursor.com/t/env-name-in-mcp-json-is-not-resolved-when-name-ends-in-token-or-key/179948/7 "2026-12-04T03:19:34Z")

</div>

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.
