Cursor-agent launch-scoped MCP env/config overrides for stdio servers

,

Where does the bug appear (feature/product)?

Cursor CLI

Describe the Bug

I’m building a terminal-based integration that launches cursor-agent inside an xterm/PTY-style terminal and provides an initial prompt. The integration also runs a local MCP-compatible service and needs to pass short-lived, per-launch values to a configured stdio MCP server before the first model turn.

Concretely, the wrapper can set environment variables on the cursor-agent process it starts, but those values do not appear to be a reliable way to configure the stdio MCP subprocess that Cursor starts from ~/.cursor/mcp.json. The current workaround is to temporarily write launch-specific values into the global Cursor MCP config under mcpServers.<server>.env, keep them there while the Cursor session is alive, and then clean them up later.

That workaround is fragile for two reasons:

  • It requires mutating a global user config file for something that is really scoped to one cursor-agent invocation.
  • It can require writing short-lived local auth/session values to disk, even though those values only need to exist for the current launch.

Why prompt-based setup is not enough

MCP server startup and tool discovery happen before the model reads the initial prompt. If the MCP subprocess was not started with the needed env/config, the tools are either missing or are connected to the wrong/default mode before the agent can do anything.

Steps to Reproduce

On cursor-agent 2026.05.28-a70ca7c:

  • cursor-agent --help exposes --approve-mcps, --workspace, and --plugin-dir, but I do not see a launch-scoped MCP config/env override.
  • cursor-agent mcp --help exposes login, list, list-tools, enable, and disable, but no way to pass per-launch env for a configured stdio MCP server.
  • Setting environment variables on the wrapper-launched cursor-agent process is not enough for the stdio MCP subprocess in this integration.

Expected Behavior

Please add one of these Cursor CLI mechanisms for stdio MCP servers:

  1. A launch-scoped MCP config overlay, for example:

    cursor-agent \
      --mcp-config-json '{"mcpServers":{"my-server":{"env":{"LOCAL_MCP_URL":"...","LOCAL_MCP_TOKEN":"..."}}}}' \
      --approve-mcps "...prompt..."
    
    

Per-server env override flags, for example:

cursor-agent
–mcp-env my-server:LOCAL_MCP_URL=…
–mcp-env my-server:LOCAL_MCP_TOKEN=…
–approve-mcps “…prompt…”

A documented env var such as CURSOR_MCP_CONFIG_CONTENT / CURSOR_MCP_CONFIG_OVERLAY that is applied only to the current launch.

Alternatively, a documented way for stdio MCP subprocesses to inherit selected environment variables from the cursor-agent process, or for ${env:NAME} values in mcp.json to resolve against the launch environment consistently in CLI mode.

Operating System

MacOS

Version Information

cursor-agent 2026.05.28-a70ca7c

Does this stop you from using Cursor

No - Cursor works, but with this issue