cursor-delegate-mcp 2.2.1 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,68 @@ All notable changes to this project are documented here. The format follows
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [2.4.0] - 2026-10-05
10
+
11
+ ### Added
12
+
13
+ - `effectiveEffort` in the delegate result: the current value of each option recognized as
14
+ effort, keyed by option id, as the agent reported it when the prompt went out. It is
15
+ present even when `effort` is omitted, because the model then runs at the level Cursor
16
+ saved for it, and absent when no reply confirmed a value. Read from replies the bridge
17
+ already receives, so it adds no ACP requests.
18
+ - `doctor` with `deep: true` reports each `currentModelOptions` entry's `name`, ACP
19
+ `category` and `currentValue` when the agent sends them as strings. The id and values
20
+ alone could not show that grok-4.7's `reasoning_effort` is its effort setting, or which
21
+ level Cursor had saved for it.
22
+
23
+ ### Fixed
24
+
25
+ - `effort` reaches a model that advertises it under an unfamiliar id. An option the agent
26
+ marks with ACP's `thought_level` category counts as effort whatever its id or name, and
27
+ the fallback for agents that send no category also knows `reasoning_effort` and names
28
+ containing "effort". grok-4.7 declares `reasoning_effort` ("Effort"), which was missed, so
29
+ `effort: "high"` failed with `invalid-effort` claiming the model had no effort setting.
30
+ - `invalid-effort` no longer says `Accepted: none` when no option is recognized as effort.
31
+ Missing an option is not proof the model has none, so the error lists the options the
32
+ model advertised, with their names, categories and values.
33
+
34
+ ### Security
35
+
36
+ - Lockfile bump of `hono` to 4.13.7, clearing a moderate audit advisory.
37
+
38
+ ### Internal
39
+
40
+ - Lockfile bumps of `@modelcontextprotocol/sdk` to 1.30.1 and the dev dependency
41
+ `@types/node` to 26.6.3.
42
+
43
+ ## [2.3.0] - 2026-09-06
44
+
45
+ ### Fixed
46
+
47
+ - JSON that is not an object is ignored on the ACP stream. `null` threw in the frame
48
+ reader — an uncaught exception that took down the server — and arrays or primitives
49
+ counted as activity, holding the idle guard open the way a launcher banner used to.
50
+ - Malformed tool `content` blocks are dropped and reported once in `protocolWarnings`.
51
+ A null block, a block with no string `type`, or a `diff` whose `path` is missing or
52
+ not a string threw in the update handler or recorded a non-path in `touchedFiles`.
53
+ - `cursor/update_todos` sent as a JSON-RPC notification is merged and not answered. A
54
+ reply to a notification is invalid JSON-RPC and aborted the turn.
55
+ - An image `contextFile` that cannot be read is skipped with a warning. A permission
56
+ error or a locked file used to fail the whole delegation after the other attachments
57
+ were already accepted.
58
+ - The Codex plugin `interface` drops `supportURL`. Codex's validator rejects unknown
59
+ keys, so a listing that kept that field would not validate.
60
+
61
+ ### Changed
62
+
63
+ - README usage copy names the Cursor Models pool and links Cursor's usage-limits help
64
+ instead of calling the allowance generous enough that most people never hit it.
65
+
66
+ ### Internal
67
+
68
+ - The production `npm audit` CI step retries three times with a five-minute timeout, so
69
+ a registry blip no longer fails the whole test workflow.
70
+
9
71
  ## [2.2.1] - 2026-09-04
10
72
 
11
73
  ### Changed
package/README.md CHANGED
@@ -32,7 +32,7 @@ Composer 2.5 is built for throughput on multi-file edits. The whole delegation i
32
32
 
33
33
  ## 🔋 Your limits stop being the bottleneck
34
34
 
35
- Composer and Grok run on their **own usage allowance** on every Cursor plan — separate from the API-priced main quota, and generous enough that most people never reach the ceiling. Your Claude or Codex subscription spends tokens only on the brief and the review, so the 5-hour window and weekly limits go a lot further. Paying per token on API? That grind moves onto Cursor capacity you already have.
35
+ Composer and Grok draw from the **Cursor Models usage pool**, separate from third-party model usage on [supported Cursor plans](https://cursor.com/help/models-and-usage/usage-limits). Your Claude or Codex subscription handles the brief and review while Cursor runs the implementation. If you pay per token on API, implementation moves onto the Cursor capacity you already have.
36
36
 
37
37
  ![You and your agent plan and review; the MCP delegate tool hands the brief to cursor-agent (Composer 2.5), which implements and edits your workspace; a clean result comes back with what changed, which files, and the plan, for your agent to review](assets/flow.png)
38
38
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cursor-delegate-mcp",
3
- "version": "2.2.1",
3
+ "version": "2.4.0",
4
4
  "mcpName": "io.github.andreilungeanu/cursor-delegate-mcp",
5
5
  "type": "module",
6
6
  "description": "Delegate multi-file coding work from Claude Code, Codex, Copilot, or any MCP client to Cursor's CLI agent — structured results, plan mode, and changed files.",
package/src/acp-client.js CHANGED
@@ -97,7 +97,12 @@ export class AcpClient extends EventEmitter {
97
97
  this.child.once("close", emitExit);
98
98
  this.router = null;
99
99
  this.peer = new JsonRpcPeer(this.child.stdout, this.child.stdin, {
100
- onNotification: (method, params) => { if (method === "session/update") this.emit("update", params); },
100
+ onNotification: (method, params) => {
101
+ if (method === "session/update") this.emit("update", params);
102
+ else if (method === "cursor/update_todos") {
103
+ Promise.resolve(this.router?.(undefined, method, params)).catch(() => {});
104
+ }
105
+ },
101
106
  // The router is async and its result discarded, so a throw from its own catch would reject
102
107
  // unobserved and exit the process. Promise.resolve covers a sync router in tests.
103
108
  onRequest: (id, method, params) => {
package/src/delegate.js CHANGED
@@ -12,7 +12,7 @@ import { normalizeAgentReportedFiles } from "./agent-reported-files.js";
12
12
  import { makeTurnState } from "./turn-state.js";
13
13
  import { makeError } from "./errors.js";
14
14
  import { PLAN_PRIORITIES, PLAN_STATUSES, TODO_STATUSES } from "./acp-enums.js";
15
- import { optionsFrom, resolveEffort, unsupportedWarning } from "./model-options.js";
15
+ import { effortSettings, optionsFrom, resolveEffort, unsupportedWarning } from "./model-options.js";
16
16
  import { transcriptFrames } from "./jsonrpc.js";
17
17
 
18
18
  export const DEFAULT_MODEL = "composer-2.5";
@@ -125,7 +125,11 @@ async function buildContextBlocks(contextFiles, workspace, client, warnings) {
125
125
  warnings.push(`contextFile ${entry} skipped: ${Math.round(stat.size / 1024)}KB exceeds the ${MAX_IMAGE_BYTES / 1024 / 1024}MB image limit`);
126
126
  continue;
127
127
  }
128
- blocks.push({ type: "image", mimeType, data: (await readFile(canonical)).toString("base64") });
128
+ try {
129
+ blocks.push({ type: "image", mimeType, data: (await readFile(canonical)).toString("base64") });
130
+ } catch (err) {
131
+ warnings.push(`contextFile ${entry} skipped: could not read image (${err?.code || "read failed"})`);
132
+ }
129
133
  continue;
130
134
  }
131
135
  blocks.push({ type: "resource_link", uri: pathToFileURL(canonical).href, name: path.basename(canonical) });
@@ -226,11 +230,13 @@ async function applyEffort(client, sessionId, model, value, modelOptions) {
226
230
  + " the selected model did not report a usable effort option list."
227
231
  );
228
232
  }
229
- if (resolved.status === "unsupported") {
233
+ if (resolved.status === "unrecognized") {
230
234
  throw makeError(
231
235
  "invalid-effort",
232
- `Model ${JSON.stringify(model)} does not advertise configurable effort.`
233
- + ` Accepted: none. Omit effort; do not send ${JSON.stringify("none")}.`
236
+ `Model ${JSON.stringify(model)} advertised no option the bridge recognizes as effort.`
237
+ + ` Advertised: ${JSON.stringify(resolved.advertised)}.`
238
+ + ` If none of these is an effort setting, omit effort; do not send ${JSON.stringify("none")}.`
239
+ + " If one is, the bridge failed to recognize it — report that rather than retrying."
234
240
  );
235
241
  }
236
242
  if (resolved.status === "invalid") {
@@ -434,7 +440,13 @@ export async function runDelegate({
434
440
  // is an uncaught exception — the whole server, not this one turn — and it also stops the
435
441
  // reply on the next line from being read, so the turn hangs to its cap.
436
442
  for (const c of Array.isArray(up.content) ? up.content : []) {
437
- if (c.type === "diff" && c.path) {
443
+ if (!c || typeof c !== "object" || Array.isArray(c) || typeof c.type !== "string"
444
+ || (c.type === "diff" && (typeof c.path !== "string" || !c.path))) {
445
+ const warning = "malformed tool content dropped: expected content blocks with string diff paths";
446
+ if (!frameWarnings.includes(warning)) frameWarnings.push(warning);
447
+ continue;
448
+ }
449
+ if (c.type === "diff") {
438
450
  state.touched.add(c.path);
439
451
  try { onProgress?.("editing " + c.path); } catch {}
440
452
  }
@@ -446,6 +458,7 @@ export async function runDelegate({
446
458
  let resumeError;
447
459
  const unsupportedOptions = [];
448
460
  let servedModel;
461
+ let effectiveEffort;
449
462
  const contextWarnings = [];
450
463
  try {
451
464
  const res = await supervisor.supervise(async () => {
@@ -463,6 +476,11 @@ export async function runDelegate({
463
476
  // (same model twice running) hits this.
464
477
  const openedOnModel = client.sessionModels?.currentModelId === model;
465
478
  if (!openedOnModel) await client.setModel(sessionId, model);
479
+ // The selected model's options as the agent last reported them, read for effectiveEffort.
480
+ // After a switch the opening snapshot describes the model we left, so it is dropped. A set
481
+ // that succeeds replaces the snapshot with its reply, which may carry none, and then nothing
482
+ // is known; a refused set changed nothing, so the snapshot stands.
483
+ let observedOptions = openedOnModel ? client.configOptions : undefined;
466
484
  // fast is an instruction, not a probe. Cursor persists the tier, and persists it per model —
467
485
  // both measured: one fast:true turn leaves the next fresh session reporting fast=true, and a
468
486
  // set_model to another model reports that model's own tier. So the opening snapshot only
@@ -477,6 +495,7 @@ export async function runDelegate({
477
495
  const fastResult = await applyConfig(client, sessionId, "fast", fast);
478
496
  if (fastResult.unsupported && fast) unsupportedOptions.push({ arg: "fast" });
479
497
  else servedModel = servedModelFrom(fastResult.res) ?? servedModel;
498
+ if (!fastResult.unsupported) observedOptions = optionsFrom(fastResult.res);
480
499
  modelOptions = optionsFrom(fastResult.res);
481
500
  }
482
501
  // A model that refuses fast leaves no list. Re-asserting the model just set is inert, and
@@ -484,18 +503,26 @@ export async function runDelegate({
484
503
  if (modelOptions === undefined && effort !== undefined) {
485
504
  const reasserted = await applyConfig(client, sessionId, "model", model);
486
505
  modelOptions = optionsFrom(reasserted.res);
506
+ if (!reasserted.unsupported) observedOptions = modelOptions;
487
507
  servedModel = servedModelFrom(reasserted.res) ?? servedModel;
488
508
  }
489
509
  if (effort !== undefined) {
490
510
  const r = await applyEffort(client, sessionId, model, effort, modelOptions);
511
+ observedOptions = optionsFrom(r);
491
512
  servedModel = servedModelFrom(r) ?? servedModel;
492
513
  }
493
514
  if (context !== undefined) {
494
515
  const r = await applyConfig(client, sessionId, "context", context);
495
516
  if (r.unsupported) unsupportedOptions.push({ arg: "context" });
496
- else servedModel = servedModelFrom(r.res) ?? servedModel;
517
+ else {
518
+ observedOptions = optionsFrom(r.res);
519
+ servedModel = servedModelFrom(r.res) ?? servedModel;
520
+ }
497
521
  }
498
522
  await client.setMode(sessionId, mode);
523
+ // What the agent reported in force as the prompt goes out — never the requested value
524
+ // standing in for a reply that did not confirm it.
525
+ effectiveEffort = effortSettings(observedOptions);
499
526
  // Everything a session/load replay may have written belongs to the previous turn.
500
527
  state.reset();
501
528
  supervisor.promptStarted();
@@ -556,6 +583,9 @@ export async function runDelegate({
556
583
  // Only when the agent served a different model than asked — e.g. "default" routing to a
557
584
  // concrete id, or a cross-model resume. Silence means the request was honored.
558
585
  if (servedModel !== undefined && servedModel !== model) out.effectiveModel = servedModel;
586
+ // Unlike effectiveModel, present whenever known: an omitted effort runs at whatever Cursor
587
+ // saved for the model, and this is the only place the caller can see what that was.
588
+ if (effectiveEffort !== undefined) out.effectiveEffort = effectiveEffort;
559
589
  if (stopReason !== undefined) out.stopReason = stopReason;
560
590
  // sessionTitle stays out of the result: it is a live label (progress) and a forensic one
561
591
  // (timeout errors), not a fact about the finished turn.
package/src/doctor.js CHANGED
@@ -4,7 +4,7 @@ import { AcpClient } from "./acp-client.js";
4
4
  import { resolveAcpSpawn } from "./spawn.js";
5
5
  import { DETACHED, treeKill } from "./proc.js";
6
6
  import { readPackageVersion } from "./version.js";
7
- import { allowedValues } from "./model-options.js";
7
+ import { describeOptions } from "./model-options.js";
8
8
 
9
9
  const HANDSHAKE_TIMEOUT_MS = 15_000;
10
10
  const VERSION_PROBE_TIMEOUT_MS = 10_000;
@@ -98,10 +98,9 @@ async function runDeepHandshake({ spawnSpec, clientFactory, workspace, timeoutMs
98
98
  details.currentModel = client.sessionModels?.currentModelId ?? null;
99
99
  details.modes = (client.sessionModes?.availableModes ?? []).map((m) => m?.id).filter(Boolean);
100
100
  // session/new already returned these. currentModel only — any other model needs a set_model
101
- // first, which this handshake does not send.
102
- details.currentModelOptions = (client.configOptions ?? [])
103
- .filter((o) => typeof o?.id === "string" && o.id !== "model" && o.id !== "mode")
104
- .map((o) => ({ id: o.id, values: allowedValues(o) }));
101
+ // first, which this handshake does not send. name and category are what tell an effort
102
+ // option apart when its id is unfamiliar; currentValue is the level saved for the model.
103
+ details.currentModelOptions = describeOptions(client.configOptions);
105
104
  })();
106
105
  const timeout = new Promise((_, reject) => {
107
106
  timer = setTimeout(() => {
package/src/jsonrpc.js CHANGED
@@ -88,6 +88,7 @@ export class JsonRpcPeer {
88
88
  if (!line.trim()) return;
89
89
  let msg;
90
90
  try { msg = JSON.parse(line); } catch { return; }
91
+ if (msg === null || typeof msg !== "object" || Array.isArray(msg)) return;
91
92
  // Only a parsed frame counts. A blank line, a launcher banner or anything else the agent
92
93
  // prints is not the protocol advancing, and treating it as such is what let a chatty
93
94
  // launcher hold the idle guard open and made "Last ACP frame Ns ago" report a stderr byte.
@@ -1,14 +1,21 @@
1
1
  // Config option ids differ per model, and a model rejects any id it does not declare. The set is
2
2
  // knowable only once a model is selected, from the configOptions the agent echoes back.
3
3
 
4
- // Mirrors cursor-agent's own classifier.
5
- const THOUGHT_LEVEL_IDS = new Set(["thinking", "reasoning", "effort", "thought_level"]);
4
+ // ACP marks a thought/reasoning level selector with category "thought_level" — grok-4.7 declares
5
+ // reasoning_effort ("Effort") that way. Categories are optional in ACP, so the ids and names
6
+ // below still classify options from an agent that sends none. A match only nominates an option:
7
+ // the requested value must still appear exactly among the values it advertises.
8
+ const THOUGHT_LEVEL_IDS = new Set(["thinking", "reasoning", "effort", "reasoning_effort", "thought_level"]);
9
+ // Never an effort setting, and doctor reports them as currentModel and modes, so a list of what a
10
+ // model offers leaves them out.
11
+ const SELECTOR_IDS = new Set(["model", "mode"]);
6
12
 
7
13
  export function isThoughtLevel(opt) {
14
+ if (opt?.category === "thought_level") return true;
8
15
  const id = typeof opt?.id === "string" ? opt.id.toLowerCase() : "";
9
16
  if (THOUGHT_LEVEL_IDS.has(id)) return true;
10
17
  const name = typeof opt?.name === "string" ? opt.name.toLowerCase() : "";
11
- return /thinking|reasoning|thought/.test(name);
18
+ return /thinking|reasoning|thought|effort/.test(name);
12
19
  }
13
20
 
14
21
  export function optionsFrom(res) {
@@ -21,15 +28,43 @@ export function allowedValues(opt) {
21
28
  .filter((v) => typeof v === "string");
22
29
  }
23
30
 
31
+ // What a model offers besides the model and mode selectors, as doctor reports it and as an
32
+ // unrecognized effort names it. Optional metadata appears only when the agent sent a string.
33
+ export function describeOptions(options) {
34
+ return (Array.isArray(options) ? options : [])
35
+ .filter((o) => typeof o?.id === "string" && !SELECTOR_IDS.has(o.id))
36
+ .map((o) => ({
37
+ id: o.id,
38
+ ...(typeof o.name === "string" ? { name: o.name } : {}),
39
+ ...(typeof o.category === "string" ? { category: o.category } : {}),
40
+ values: allowedValues(o),
41
+ ...(typeof o.currentValue === "string" ? { currentValue: o.currentValue } : {}),
42
+ }));
43
+ }
44
+
45
+ // The current value of every recognized effort option, keyed by id. All of them rather than one
46
+ // picked: a model can declare a thinking toggle beside a level, and either alone can mislead.
47
+ // Undefined when no recognized option reports a string value.
48
+ export function effortSettings(options) {
49
+ const settings = {};
50
+ for (const o of Array.isArray(options) ? options : []) {
51
+ if (isThoughtLevel(o) && typeof o?.id === "string" && typeof o.currentValue === "string") {
52
+ settings[o.id] = o.currentValue;
53
+ }
54
+ }
55
+ return Object.keys(settings).length > 0 ? settings : undefined;
56
+ }
57
+
24
58
  // Resolve only values the selected model advertised. This keeps future vocabularies working
25
59
  // without aliases or a ranking table: xhigh, extra-high, max and ultra are just exact tokens.
26
- // A reported config list with no thought-level option is authoritative (unsupported); no list,
27
- // an empty list, or a thought-level option with no usable id/values is not.
60
+ // No list, an empty list, or a thought-level option with no usable id/values is unavailable. A
61
+ // list with nothing classified as thought-level is unrecognized — not proof the model has no
62
+ // effort setting: categories are optional and ids get renamed, so the caller is shown the list.
28
63
  export function resolveEffort(options, value) {
29
64
  if (!Array.isArray(options) || options.length === 0) return { status: "unavailable" };
30
65
 
31
66
  const candidates = options.filter(isThoughtLevel);
32
- if (candidates.length === 0) return { status: "unsupported", accepted: [] };
67
+ if (candidates.length === 0) return { status: "unrecognized", advertised: describeOptions(options) };
33
68
 
34
69
  const usable = candidates.filter((o) => typeof o?.id === "string");
35
70
  const accepted = [...new Set(usable.flatMap(allowedValues))];
@@ -41,6 +41,7 @@ export function createRequestRouter({ respond, respondError, onCreatePlan, onTod
41
41
  if (method === "cursor/update_todos") {
42
42
  onTodos?.({ todos: params?.todos, merge: params?.merge, toolCallId: params?.toolCallId });
43
43
  log({ method, params });
44
+ if (id == null) return;
44
45
  // The documented response is {outcome:{outcome:"accepted", todos}}; the bare {} we
45
46
  // have always sent is accepted by cursor-agent, so it stays until that changes.
46
47
  return respond(id, {});
@@ -53,7 +54,7 @@ export function createRequestRouter({ respond, respondError, onCreatePlan, onTod
53
54
  } catch (err) {
54
55
  // -32603, not -32000: ACP assigns -32000 to auth_required, and a bug on this side
55
56
  // reported as "authenticate" sends the agent down a recovery path that cannot work.
56
- return respondError(id, -32603, `Router error: ${err?.message || err}`);
57
+ if (id != null) return respondError(id, -32603, `Router error: ${err?.message || err}`);
57
58
  }
58
59
  };
59
60
  }
package/src/server.js CHANGED
@@ -85,6 +85,7 @@ export const delegateOutputShape = {
85
85
  result: z.string(),
86
86
  resultSource: z.enum(["pre-tool-fallback", "none"]).optional(),
87
87
  effectiveModel: z.string().optional(),
88
+ effectiveEffort: z.record(z.string()).optional(),
88
89
  stopReason: z.string().optional(),
89
90
  sessionId: z.string(),
90
91
  filesReportedByEditTools: z.array(z.string()).optional(),
@@ -122,7 +123,13 @@ export const doctorHandshakeShape = {
122
123
  currentModel: z.unknown().optional(),
123
124
  modes: z.array(z.unknown()).optional(),
124
125
  // Built here rather than relayed, so it gets a real type where its neighbours get z.unknown().
125
- currentModelOptions: z.array(z.object({ id: z.string(), values: z.array(z.string()) })).optional(),
126
+ currentModelOptions: z.array(z.object({
127
+ id: z.string(),
128
+ name: z.string().optional(),
129
+ category: z.string().optional(),
130
+ values: z.array(z.string()),
131
+ currentValue: z.string().optional(),
132
+ })).optional(),
126
133
  };
127
134
 
128
135
  export const doctorAgentShape = {