Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ build/
*.egg-info/
.coverage
htmlcov/
docs/cloud-agents-openapi.yaml
docs/cloud-agents-openapi*.yaml
docs/openapi-headers.txt
examples/resolved/

Expand Down
6 changes: 5 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# AGENTS.md

Dev repo for `cursor-cloud-mcp`: stdio MCP server (Python 3.12+) for Cursor Cloud Agents v1. `src/cursor_cloud_mcp/` is the server; `server.py` only wires the 19 tools, logic lives in `sessions.py` (mutations), `stream.py`/`supervision.py` (stream replay, activity), `catalog.py`+`validation.py` (model/repo checks), `client.py`, `journal.py` (local model journal, the only disk state), `usage.py` (usage + journal models), `environments.py` (environments, pools, active build), `present.py`/`models.py`/`shapes.py`, `artifacts.py`, `budget.py`, `config.py`, `errors.py`, `redaction.py`, `fixture.py`. `skills/cursor-agents/` is the public agent skill (generic only: no user-specific models, names or paths; private notes go in its git-ignored `references/field-notes.md`); `tests/test_skill.py` checks its script and tool names.
Dev repo for `cursor-cloud-mcp`: stdio MCP server (Python 3.12+) for Cursor Cloud Agents v1. `src/cursor_cloud_mcp/` is the server; `server.py` only wires the 20 tools, logic lives in `sessions.py` (mutations), `stream.py`/`supervision.py` (stream replay, activity), `catalog.py`+`validation.py` (model/repo checks), `client.py`, `journal.py` (local model journal, the only disk state), `usage.py` (usage + journal models), `environments.py` (environments, pools, active build), `projects.py` (read-only Projects), `present.py`/`models.py`/`shapes.py`, `artifacts.py`, `budget.py`, `config.py`, `errors.py`, `redaction.py`, `fixture.py`. `skills/cursor-agents/` is the public agent skill (generic only: no user-specific models, names or paths; private notes go in its git-ignored `references/field-notes.md`); `tests/test_skill.py` checks its script and tool names.

## Commands (uv only)

Expand All @@ -21,6 +21,10 @@ Dev repo for `cursor-cloud-mcp`: stdio MCP server (Python 3.12+) for Cursor Clou
- Single version source: `__version__` in `src/cursor_cloud_mcp/__init__.py`. Release tag must be exactly `v<version>` (`release.yml` enforces it, publishes via Trusted Publishing).
- Tool errors must be pure JSON: raise `failure(ErrorCode, ...)` (becomes `ToolFailure`); only SDK-level arg rejection stays plain text. Never emit `null` fields in views (`present.py` omits).
- Pre-send guards live in code, not the API: `starting_ref` is a branch name or full SHA (SHA accepted live 2026-10-19), `model_id`/`reasoning_level`/`model_params` checked against the cached catalog (`catalog.py`), `workOnCurrentBranch` forced `false`, follow-ups refused on archived/unknown-status agents.
- Key types: `crsr_` (Cursor dashboard, "legacy" on a unified Cursor and Grok account) and `grok_`. Seen on one account: 2026-11-10 `grok_` refused on environments (400 "Blocked by privacy setting", rendered `PERMISSION`), pools and secrets, `crsr_` accepted; 2026-11-12 environments accepted for `grok_` again, pools (403) and secrets (403 `key_not_supported`, in the spec) still refused. `POST /v1/agents` was refused on 2026-11-10 with both key types, then on 2026-11-12 and 2026-11-16 with the `crsr_` key (`QUOTA`, 400 `usage_limit_exceeded`, prepaid balance), so `smoke_live.py` stops at creation (9/11 before its free Projects check was added); cause not established, neither the spec nor the pricing pages mention it, a Cursor ticket is open. 2026-11-16: both key types read Projects (200). Zero tokens in usage means "not recorded" (`no_usage_recorded`), never free.
- From the November 9, 2026 spec, tested against the spec only (no real run yet): `delivery="steer"` (202 `steered`/`queued`, never resent), per-run `envVars`, run status `WAITING_FOR_BACKGROUND_WORK`.
- November 25, 2026 spec: only `files` (beta) on `POST /v1/projects`, not wired. `cursor-sdk` 1.5.0 sends `x-cursor-sdk-shell-tool-call-delta: true` on the run stream (not in the spec): Cursor then adds `interaction_update` events of type `shell-tool-call-delta` (checked live 2026-11-25). Wired opt-in as `cursor_read_run_events(include_shell_output=true)` (`stream.SHELL_DELTA_HEADER`); other `interaction_update` types stay ignored.
- From the November 16, 2026 spec: Projects (a coordinator agent, listed by `GET /v1/agents`; `coordinator_agent_id` is the caller's own, equal to `project_id` only for a Project they own). Only the reads are wired, as `cursor_list_projects`. `POST /v1/projects`, `PATCH`, archive and unarchive are left out on purpose: paid, unverifiable while creation answers `QUOTA`, and a coordinator starts agents outside this server's cost guards. Ask before adding them. `cursor_archive_agent`/`cursor_delete_agent` on a coordinator's id act on it (spec: that archives the Project): never try them on a Project to keep. Agent rows (`cursor_list_agents`, `cursor_get_agent`, `cursor_supervise`) carry `coordinator_of_project` for such an agent: a marker only, no refusal, from a `GET /v1/projects` cached 60 s (`client.project_coordinators`, best effort). The shared test `Router` answers that read with an empty page and does not record it unless built with `stub_projects=False`. `docs/cloud-agents-openapi.yaml` and `.previous.yaml` are git-ignored local copies: keep the old one before replacing it, to get a real diff.
- API limits encoded in behavior (don't "fix" by simplifying): `FINISHED` ≠ job done, `updatedAt` frozen while `RUNNING`, no name/status filter server-side (`name` = local scan ≤5 pages, `next_cursor` must round-trip unchanged), artifact list often empty (result must come from `cursor_get_run`), stream has no tail marker (full replay walk, budgets ≤95s so client timeout must be ~100s).

## Tests
Expand Down
22 changes: 20 additions & 2 deletions AGENT_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,23 @@

Instructions for an agent that must install or use this MCP server. Read this file in full before acting. The details of the API contract are in `docs/api-contract.md`.

This server is local, over stdio. It exposes nineteen tools for the Cursor Cloud Agents v1 REST API. It is used to create a Cloud session, choose the model and the reasoning level, send a command, read the result, then archive or delete the session. It is not an orchestration platform. The package is published on PyPI as `cursor-cloud-mcp`.
This server is local, over stdio. It exposes twenty tools for the Cursor Cloud Agents v1 REST API. It is used to create a Cloud session, choose the model and the reasoning level, send a command, read the result, then archive or delete the session. It is not an orchestration platform. The package is published on PyPI as `cursor-cloud-mcp`.

## Migration 0.6 → 0.7

From the Cursor spec of November 9, 2026 and real reads of November 10. "Not verified live" means the request shape is tested against the spec only: no real run could be created that day.

- `cursor_create_run(delivery="steer")` adds a prompt to the run in progress instead of being refused with `AGENT_BUSY`. It takes only `prompt` and `images`. The result carries `delivery`: `steered` (`run_id` is the running run, no new run) or `queued` (the prompt is the agent's next follow-up, no `run_id`: re-read `cursor_get_agent`). Never send a steer twice, also after `MUTATION_OUTCOME_UNKNOWN`: a delivered steer creates no run, so look for the prompt in the run's events or the conversation instead. `PERMISSION` with `remote_code: feature_unavailable` means the account does not have it: `replace_active=true` remains. Not verified live beyond the API's body validation. **`run_id` and `status` of `cursor_create_run` are now optional**: both are absent on a queued steer.
- `cursor_create_run` takes `env_vars` and `forward_env`, for that run only. Not verified live.
- `WAITING_FOR_BACKGROUND_WORK` is a known, non-terminal run status (it was reported with `status_known: false`). Not observed live.
- `cursor_get_usage`: a run whose token counts are all zero carries `no_usage_recorded: true`; `runs_without_usage` counts them and `warnings` says the zeros are not a cost of zero. `cursor_supervise(usage=true)` gives an agent with such an ended run `no_usage_recorded: true` (a run still in progress is not counted; `charged_cents` is then shown only if something was charged), and `summary.no_usage_recorded` lists those agents, for which the total is a lower bound. Seen live: agents created on a unified Cursor and Grok account reported zero tokens after minutes of work.
- `cursor_list_models`: `default_max_mode: true` when the catalog flags the default variant Max Mode, and with `model_id`, `max_mode_variants`. A creation or follow-up whose effective selection is such a variant returns `model.max_mode: true` and a warning. The flag is not written to the local journal, so `model` read back later does not carry it; its `params` do.
- `cursor_get_account` adds `api_key_type` (`crsr`, `grok` or `other`, from the configured key's prefix) and `notes`.
- `cursor_list_environments` takes the API's filters: `query`, `owner`, `named`, `repositories`. They are refused with `environment_id`.
- `cursor_list_projects` (read-only, from the spec of November 16, 2026): the Projects you own or joined, one page at a time, and with `project_id` one Project plus the agents its coordinator started. A Project is a coordinator agent. `coordinator_agent_id` is your own coordinator in it, an ordinary agent: for a Project you own it equals `project_id`; for one you joined, `project_id` is the owner's coordinator, not yours, and `coordinator_agent_id` may be absent (only the owned case was seen). Read live on November 16 with a `crsr_` and a `grok_` key, on the account's own Project: the list, the Project, and `cursor_get_agent` and `cursor_get_run` on its coordinator. From the spec only, not seen: the rows of `agents` (the account's only Project has none), and the stream of a coordinator run (`cursor_read_run_events` on its last run answered `STREAM_EXPIRED`, as an old run does). `cursor_create_run` on a coordinator is not refused locally (`IDLE`, `work_on_current_branch` false) and would be a paid run: not tried. **`cursor_archive_agent` and `cursor_delete_agent` on your coordinator act on it, and per the spec a Project is `ARCHIVED` once its owner's coordinator is stopped: not tried, do not use them on a Project to keep.** To keep a cleanup of idle agents from archiving a Project by accident, the rows of `cursor_list_agents`, `cursor_get_agent` and `cursor_supervise` carry `coordinator_of_project` (the Project's id) when the agent is your coordinator in a Project. It is only a marker: nothing is refused, and the rows are unmarked when the Projects list cannot be read (Projects turned off, service-account key, an error). It costs one `GET /v1/projects` (up to five pages of 100), cached for 60 seconds, errors included. Seen live on November 16 with both key types, in all three tools. No tool creates, renames or archives a Project as such.
- Cursor's "Blocked by privacy setting" refusal is now `PERMISSION`, with a `recovery` saying the arguments are not the cause; it used to read "Parameters rejected.". Seen live on `cursor_list_environments` with a `grok_` key, while a `crsr_` key of the same account was accepted. Two days later (November 12) the same call answered `200` with the `grok_` key; the classification stays in case the refusal returns.
- Environment variable names containing `CURSOR_SANDBOX` (any letter case) are refused locally, as the spec now says.
- `cursor_read_run_events` takes `include_shell_output` (default false): `shell_output` events carry what a shell command prints while it runs (seen live on November 25, 2026; see the tool notes below).

## Migration 0.5 → 0.6

Expand Down Expand Up @@ -31,6 +47,7 @@ This server is local, over stdio. It exposes nineteen tools for the Cursor Cloud
- `cursor_get_run(activity)` returns the last events observed during the read (`activity.last_events`, the true end of the stream only when `complete` is true). A stream that ends on an `error` event no longer loses the summary: it is returned with `stream_error: true` and `complete: false` (the error event stays in `last_events`) and is never cached — previously the call returned `activity_error: UPSTREAM` and no summary.
- The last tool call of the summary is clipped wider (2000 characters).
- `cursor_read_run_events` takes `tool_output_limit` (default 500, max 4000): tool args/results are clipped head + tail with a `…[clipped]…` marker, the total staying within the limit. `tool_args_omitted` / `tool_result_omitted` report a field Cursor itself omitted upstream because of its size (not recoverable by raising the limit); a local clip never sets them. A global cap on rendered tool text sets `truncated`, and `last_event_id` stays on the last event actually returned. In `tail` mode the cap bounds the returned window from its oldest side (the newest events are kept) and still sets `truncated`.
- `cursor_read_run_events(include_shell_output=true)` adds `shell_output` events: what a shell command prints while it runs (`call_id`, `stdout`, `stderr`), consecutive chunks of one command merged into one event that keeps the newest output within `tool_output_limit` (`clipped` marks a cut start). Works in both modes (`after_event_id` and `tail`). It sends the request header `x-cursor-sdk-shell-tool-call-delta: true`, as `cursor-sdk` 1.5.0 does; the header is not in the OpenAPI. Checked live on November 25, 2026: replayed with the header, one command gave 16 `shell-tool-call-delta` updates; without it, none, everything else identical. The finished `tool_call` still carries the whole output; the deltas show it before the command ends. Off by default: a chatty command makes the replay longer.
- `cursor_supervise` rows carry `git` (the agent's current pushed state, `scope=agent_current_state`) and stay light: `last_events` is stripped like the other heavy fields; `stream_error` and `complete` remain on the activity. `cursor_list_runs` items also carry `git`.
- `cursor_create_agent(on_conflict="reuse")`, with a caller-supplied `agent_id`: on `409 agent_id_conflict`, the existing agent is returned with `reused: true` and its observed `latest_run_id` (`run_id` and `run_status` absent). No run is sent and the prompt is not applied. A failed re-read stays an `AGENT_ID_CONFLICT` error whose `recovery` says to retry the same call; the default `on_conflict="error"` is unchanged.

Expand Down Expand Up @@ -243,7 +260,7 @@ What the API does not tell you, measured on October 6, 2026. These are API limit
- `FINISHED` means the agent ended its turn, not that its job is done. Jobs it started in the background may have been killed or may still be running.
- A `RUNNING` run keeps `updated_at` at its creation time, even after hours: it is not a liveness signal.
- An `ERROR` run carries no cause: neither `error` nor `result`.
- A run in progress cannot receive a message: a follow-up answers `AGENT_BUSY`.
- A run in progress refuses an ordinary follow-up (`AGENT_BUSY`). Since November 2026 the API takes a steer instead (`delivery="steer"`), where the account has it.
- The stream can only be replayed from its start.

What to use instead:
Expand All @@ -253,6 +270,7 @@ cursor_supervise(name="runner") every runner, latest run, one ca
cursor_supervise(name="runner", activity=true) + last_event_at, idle_seconds, background tasks (about 30-60 s)
cursor_get_run(agent_id, run_id, activity=true) detail of one run: last text, last tool call, background tasks
cursor_read_run_events(..., tail=20) the last 20 events
cursor_create_run(..., delivery="steer") add a message to the run in progress, cancelling nothing
cursor_create_run(..., replace_active=true) redirect a runner: stop its run, then follow up
```

Expand Down
Loading
Loading