Skip to content

Commit 809a2c8

Browse files
Tian JiangTian Jiang
authored andcommitted
fix(cursor): materialize project MCP config
1 parent 0903561 commit 809a2c8

3 files changed

Lines changed: 374 additions & 151 deletions

File tree

docs/cursor-cli.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ If no boundary is detected, extraction raises `ValueError("No Cursor CLI respons
7474
By default, CAO launches Cursor CLI with the following flags to skip the interactive dialogs that would otherwise block headless orchestration:
7575

7676
- `--force` — auto-approves every tool call (Bash, file writes, etc.).
77-
- `--approve-mcps` — pre-approves MCP servers declared via `--plugin-dir`.
77+
- `--approve-mcps` — pre-approves MCP servers declared in the worker's
78+
project-local `.cursor/mcp.json`.
7879

7980
`--trust` is **not** passed because Cursor CLI v2026+ rejects it in interactive REPL mode with `Error: --trust can only be used with --print/headless mode`. The CAO launch flow already confirms workspace trust, and the interactive REPL has no per-directory trust dialog for `--trust` to skip.
8081

@@ -88,15 +89,15 @@ When launched with an agent profile (e.g., `--agents code_supervisor`), CAO:
8889

8990
1. Loads the profile from the agent store (`~/.aws/cli-agent-orchestrator/agent-store`).
9091
2. Honors the profile's `model` field by passing `--model <id>` at launch (overridable via the constructor).
91-
3. For MCP servers: writes a synthetic Cursor plugin manifest under `~/.aws/cli-agent-orchestrator/tmp/<tid>-cursor-plugins/plugin.json` and passes the directory via `--plugin-dir`. The manifest's `mcpServers` map carries the `CAO_TERMINAL_ID` env var so MCP tools can identify the current terminal for handoff/assign operations. `--approve-mcps` is added so the REPL does not block on a per-server approval dialog.
92+
3. For MCP servers: writes the documented project-local config at `<worker-cwd>/.cursor/mcp.json` immediately before launch. CAO merges the profile's non-conflicting servers, forwards `CAO_TERMINAL_ID` in their environment, and restores the original config during cleanup only if it remains unchanged. `--approve-mcps` is added so the REPL does not block on a per-server approval dialog. Existing server-name collisions fail closed rather than being overwritten.
9293
4. **Does not** pass the profile body via `--system-prompt` in v2026.06.15: the backend rejects every request that carries a `--system-prompt <file>` payload with `[invalid_argument] unknown option '--system-prompt'` regardless of the file's contents (the bug is reproducible with a 3-character file). The CAO role context still reaches the agent via the `cao-mcp-server` MCP tool's handoff/assign payloads, so the agent has the right capabilities and the right inbox tools; only the role body is not pre-loaded as a system prompt. The preserved `_write_system_prompt_file` helper is ready to re-enable this path when Cursor ships a fixed client.
9394

9495
### Launch Command
9596

9697
The provider builds the command via `_build_cursor_command()`. The provider prefers the unambiguous `cursor-agent` alias (which only the Cursor CLI ships) and falls back to the documented primary `agent` name when only that is installed. When `agent` is selected the provider runs an `agent --version` probe to confirm the resolved binary is the Cursor CLI (a number of unrelated tools also install an `agent` binary on `$PATH`).
9798

9899
```
99-
cursor-agent --force [--model <id>] [--plugin-dir <path> --approve-mcps]
100+
cursor-agent --force [--model <id>] [--approve-mcps]
100101
```
101102

102103
The `--print` flag is intentionally **not** passed: CAO drives the interactive REPL so the inbox service can stream follow-up prompts via MCP handoff. Print mode is a one-shot CLI flag that exits after the first response and is therefore incompatible with multi-turn CAO sessions.
@@ -202,8 +203,8 @@ If the supervisor completes the analysis work itself, the per-directory lock or
202203
- If the dialog still appears, verify the `agent` (or `cursor-agent`) version supports `--force` (`agent --help`).
203204

204205
2. **MCP Approval Dialog Blocking**
205-
- The provider launches with `--approve-mcps` when the profile declares `mcpServers`, and the MCP servers are written into a `--plugin-dir` manifest.
206-
- If MCP servers still prompt, check the synthesised `plugin.json` under `~/.aws/cli-agent-orchestrator/tmp/<tid>-cursor-plugins/`.
206+
- The provider launches with `--approve-mcps` when the profile declares `mcpServers`, and writes the servers into `<worker-cwd>/.cursor/mcp.json` before Cursor starts.
207+
- If MCP servers still prompt or are absent, inspect that project-local config and run `cursor-agent mcp list` from the same worker directory. Do not add CAO's per-terminal MCP server to `~/.cursor/mcp.json`: that would expose it to unrelated Cursor sessions.
207208

208209
3. **Authentication Issues**
209210
```bash

0 commit comments

Comments
 (0)