Resolve local environment variables in MCP server definitions

I am using cursor-agent cli version 2025.10.22-f894c2.

in mcp.json of the project i define my custom mcp server (stdio) and trying to pass my env variable

```
“custom-mcp”: {
“command”: “custom”,
“args”: [ “mcp”, “start” ],
“env”: {
“INTERNAL_TOKEN”: “${env:INTERNAL_TOKEN}”
}
},
```

while executing tools from this mcp server - token is not passed and I get auth error.

What i am doing wrong?

PS: I’ve tried both “INTERNAL_TOKEN”: “${env:INTERNAL_TOKEN}” and “INTERNAL_TOKEN”: “${INTERNAL_TOKEN}”
Does not work

3 Likes

Bumping this up.

The cursor cli doesn’t interpolate env vars as described in the documentation (eg. "API_KEY": "${env:API_KEY}").

cursor-agent –version: 2025.11.25-d5b3271

mcp.json
{
"mcpServers": {
"my-mcp-server": {
"type": "stdio",
"command": "uv",
"args": [
"run",
"--with=mcp",
"--directory=...",
"mcp",
"run",
"stdio_runner.py:server"
],
"env": {
"MCP_WS_URL": "${env:MCP_WS_URL}",
"RUN_SESSION_ID": "${env:RUN_SESSION_ID}",
"RUN_PROJECT_ID": "${env:RUN_PROJECT_ID}"
}
}
}
}

The stdio_runner.py sees unexpanded literals:
DEBUG Environment snapshot | {'MCP_WS_URL': '${env:MCP_WS_URL}', 'RUN_PROJECT_ID': '${env:RUN_PROJECT_ID}', ...}

Any help?
Thanks!

2 Likes

This is still broken as of 2026.01.02-80e4d9b. Means I am having to wrap all my MCP server commands I put in mcp.json with wrappers which source environment variables another way. Currently I am running the agent headless in a container, passing in my MCP authentication tokens via environment variables at container execution time. The CURSOR_API_KEY is interpolated up by the agent but not for defined MCP servers.

I seem to still be running into this. Any further updates or suggestions?