cursor-delegate-mcp 2.9.0 → 2.11.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,72 @@ All notable changes to this project are documented here. The format follows
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [2.11.0] - 2026-11-23
10
+
11
+ ### Added
12
+
13
+ - `doctor` reports `client.protocolVersion`: `2026-07-28`, or the 2025-era revision the host
14
+ negotiated.
15
+
16
+ ### Changed
17
+
18
+ - MCP SDK v2 (`@modelcontextprotocol/server` 2.4.0): the server takes 2025-era and 2026-07-28
19
+ hosts. The runtime dependencies are this package and `zod`.
20
+ - A delegation returns once cursor-agent has exited, about 0.1 s after the turn ends. A host that
21
+ closes stdin on the result, as a one-shot run does, exits the server, which on Windows left a
22
+ cursor-agent still being killed running.
23
+
24
+ ### Fixed
25
+
26
+ - An agent whose exit is not seen after the kill is killed once more, by the delegation and by
27
+ server shutdown. A delegation that still sees no exit says so in `protocolWarnings` or its
28
+ error.
29
+ - `cancel` reports `not-running` for a turn that has ended while its agent is being stopped, and
30
+ leaves its result alone. `force` leaves a turn that ends during its grace to that turn's own
31
+ teardown.
32
+ - `doctor` on a 2025-era connection reports the identity and revision from `initialize`, even
33
+ when a request carries per-request envelope keys.
34
+ - On Windows, quotes and empty arguments in `ACP_AGENT_ARGS` reach cursor-agent when
35
+ `cursor-agent.cmd` forwards to its `.ps1` through Windows PowerShell 5.1.
36
+ - The Claude plugin manifest names its image `icon`, the field Anthropic's plugin directory reads.
37
+
38
+ ## [2.10.0] - 2026-11-22
39
+
40
+ ### Changed
41
+
42
+ - On Windows, `cursor-agent` starts without cmd.exe. `cursor-agent.cmd` (and its copy `agent.cmd`)
43
+ only forwards to `cursor-agent.ps1`, which the bridge now runs through `powershell.exe -File`, so
44
+ `!`, `%VAR%`, `^` and quotes in `ACP_AGENT_ARGS` reach the agent unchanged.
45
+
46
+ ### Fixed
47
+
48
+ - Progress lines and stall errors name the command or path of the last tool call, which
49
+ cursor-agent sends on the `tool_call_update`, capped at 200 characters.
50
+ - Windows launch:
51
+ - A launcher path or `ACP_AGENT_ARGS` argument with spaces arrives whole, including a quoted
52
+ section inside an argument (`--log-file="C:\a b\x.log"`).
53
+ - A `.ps1` `ACP_AGENT_COMMAND` runs through PowerShell instead of opening with its file
54
+ association.
55
+ - A Store app execution alias on `PATH`, such as `pwsh`, is found.
56
+ - Node 24 prints no DEP0190 deprecation warning.
57
+ - `doctor` reports the agent's version for a launcher prefix such as `node index.js acp`, and for a
58
+ `.ps1` launcher.
59
+ - `doctor` stops its version probe and handshake when the host aborts and returns once they have
60
+ exited. A server shutdown stops them too.
61
+ - `cancel`:
62
+ - a cancel during session setup keeps the prompt from being sent;
63
+ - `force` kills only the turns running when it arrived, not a resume that started during its
64
+ grace;
65
+ - a blank `sessionId` is rejected, and surrounding whitespace is trimmed.
66
+ - On SIGHUP (a closed terminal) the server stops its agents before exiting. The stdin close that
67
+ follows a hangup does not cut that wait short.
68
+ - The SessionStart hook sends npm's output to stderr, keeping the install summary out of the
69
+ session context.
70
+
71
+ ### Internal
72
+
73
+ - Lockfile: hono 4.13.18.
74
+
9
75
  ## [2.9.0] - 2026-11-22
10
76
 
11
77
  ### Fixed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cursor-delegate-mcp",
3
- "version": "2.9.0",
3
+ "version": "2.11.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.",
@@ -57,10 +57,11 @@
57
57
  "typecheck": "tsc -p tsconfig.json"
58
58
  },
59
59
  "dependencies": {
60
- "@modelcontextprotocol/sdk": "^1.23.0",
60
+ "@modelcontextprotocol/server": "^2.4.0",
61
61
  "zod": "^4.6.5"
62
62
  },
63
63
  "devDependencies": {
64
+ "@modelcontextprotocol/client": "^2.4.0",
64
65
  "@types/node": "^26.1.1",
65
66
  "typescript": "^7.0.2"
66
67
  }
package/src/acp-client.js CHANGED
@@ -3,14 +3,14 @@ import { EventEmitter } from "node:events";
3
3
  import { StringDecoder } from "node:string_decoder";
4
4
  import { JsonRpcPeer } from "./jsonrpc.js";
5
5
  import { createRequestRouter } from "./request-router.js";
6
- import { commandExists, resolveAcpSpawn } from "./spawn.js";
6
+ import { commandExists, resolveAcpSpawn, spawnArgv } from "./spawn.js";
7
7
  import { DETACHED, isChildAlive, treeKill } from "./proc.js";
8
8
  import { VERSION } from "./version.js";
9
9
  import { makeError } from "./errors.js";
10
10
 
11
11
  const STDERR_CAP = 64 * 1024;
12
- // How long stop() waits for the child to actually exit after the kill is dispatched. SIGKILL and
13
- // taskkill /F land in milliseconds, so this only ever elapses when the kill did not work.
12
+ // How long stop() waits for the exit after the kill. SIGKILL and taskkill /F land in milliseconds,
13
+ // so this elapses only when the kill failed.
14
14
  const STOP_EXIT_TIMEOUT_MS = 2000;
15
15
 
16
16
  export class AcpClient extends EventEmitter {
@@ -34,12 +34,9 @@ export class AcpClient extends EventEmitter {
34
34
  this._stopping = null;
35
35
  }
36
36
 
37
- // stderr is captured but does not count as activity: the supervisor measures ACP frames, and
38
- // an agent writing diagnostics is not the same fact as a turn making progress.
39
- // The tail of stderr, which is what an exit error quotes. Kept as chunks and joined on read:
40
- // rebuilding a 64KB string per chunk was the whole cost of a noisy agent. A StringDecoder
41
- // holds partial UTF-8 across chunk boundaries, so a multi-byte character split by the pipe
42
- // does not land in the error message as a replacement char.
37
+ // The stderr tail an exit error quotes. Kept as chunks and joined on read, so a noisy agent costs
38
+ // a push per chunk; a StringDecoder keeps a multi-byte character split across reads intact.
39
+ // stderr is not ACP activity, so it does not feed the supervisor.
43
40
  get stderrBuffer() {
44
41
  const joined = this._stderrChunks.join("");
45
42
  return joined.length > STDERR_CAP ? joined.slice(-STDERR_CAP) : joined;
@@ -55,7 +52,8 @@ export class AcpClient extends EventEmitter {
55
52
  this._stderrLength = 0;
56
53
  const stderrDecoder = new StringDecoder("utf8");
57
54
  this._exitEmitted = false;
58
- this.child = spawn(command, args, { ...options, detached: DETACHED, stdio: ["pipe", "pipe", "pipe"] });
55
+ const argv = spawnArgv(command, args, opts);
56
+ this.child = spawn(argv.command, argv.args, { ...argv.options, detached: DETACHED, stdio: ["pipe", "pipe", "pipe"] });
59
57
  this.child.stderr.on("data", (chunk) => {
60
58
  const text = stderrDecoder.write(chunk);
61
59
  if (text) {
@@ -66,9 +64,8 @@ export class AcpClient extends EventEmitter {
66
64
  while (this._stderrChunks.length > 1 && this._stderrLength - this._stderrChunks[0].length >= STDERR_CAP) {
67
65
  this._stderrLength -= this._stderrChunks.shift().length;
68
66
  }
69
- // Whole-chunk drops leave a remainder when one pipe read is itself larger than the cap
70
- // (observed on GitHub Windows runners). Slice that first chunk so retained memory cannot
71
- // grow with the flood; the public tail is still exactly one cap on read.
67
+ // A single read larger than the cap (seen on GitHub Windows runners) is sliced too, so
68
+ // retained memory stays bounded.
72
69
  const overflow = this._stderrLength - STDERR_CAP;
73
70
  if (overflow > 0) {
74
71
  this._stderrChunks[0] = this._stderrChunks[0].slice(overflow);
@@ -77,9 +74,8 @@ export class AcpClient extends EventEmitter {
77
74
  }
78
75
  });
79
76
  this.child.stderr.on("error", () => {});
80
- // A supervisor trip writes session/cancel, which can land after the agent is already gone.
81
- // Without a handler that surfaces as an unhandled 'error' event on some platforms, taking
82
- // the whole MCP server down with it. stdout needs the same guard; readline adds none.
77
+ // session/cancel can be written after the agent is gone, and an unhandled pipe 'error' would
78
+ // take down the server. readline adds no handler on stdout either.
83
79
  this.child.stdin.on("error", () => {});
84
80
  this.child.stdout.on("error", () => {});
85
81
  const emitExit = (code, signal) => {
@@ -88,9 +84,8 @@ export class AcpClient extends EventEmitter {
88
84
  const stderr = this.stderrBuffer;
89
85
  const err = makeError(
90
86
  "agent-exit",
91
- // stderr kept whole. This is the one string that says why the agent died — the model
92
- // that was rejected, the quota that ran out, the login that expired — and the part that
93
- // names it can sit anywhere in it. The 64KB ring buffer above is the bound.
87
+ // stderr whole, bounded by the 64KB buffer: why the agent died (a rejected model, a spent
88
+ // quota, an expired login) can sit anywhere in it.
94
89
  `agent exited (code=${code}${signal ? ", signal=" + signal : ""})${stderr ? ": " + String(stderr) : ""}`
95
90
  );
96
91
  // exit + rejectAllPending both settle the same Promise.race; second rejection is intentional.
@@ -124,8 +119,6 @@ export class AcpClient extends EventEmitter {
124
119
  });
125
120
  return /** @type {Promise<void>} */ (new Promise((resolve, reject) => {
126
121
  this.child.once("error", (e) => {
127
- // Tagged like every other failure class so the caller gets
128
- // "delegate failed [spawn-failed]: ..." instead of the one untagged prose error.
129
122
  const err = makeError("spawn-failed", `Failed to spawn agent (${command}): ${e.message}. Install Cursor CLI and run 'cursor-agent login'.`);
130
123
  reject(err);
131
124
  });
@@ -133,8 +126,7 @@ export class AcpClient extends EventEmitter {
133
126
  }));
134
127
  }
135
128
 
136
- // Stashed so the unknown-model pre-flight and doctor --deep can read the agent's real
137
- // capability and model lists without paying for a second handshake.
129
+ // Stashed for the unknown-model check and doctor deep, so neither needs a second handshake.
138
130
  async initialize() {
139
131
  const res = await this.peer.request("initialize", { protocolVersion: 1, clientInfo: { name: "cursor-delegate-mcp", version: VERSION }, clientCapabilities: { _meta: { parameterizedModelPicker: true } } });
140
132
  this.protocolVersion = res?.protocolVersion;
@@ -153,7 +145,12 @@ export class AcpClient extends EventEmitter {
153
145
  setConfigOption(sessionId, configId, value) { return this.peer.request("session/set_config_option", { sessionId, configId, value: String(value) }); } // configId, not optionId; ACP wants a string value
154
146
  setMode(sessionId, modeId) { return this.peer.request("session/set_mode", { sessionId, modeId }); }
155
147
  prompt(sessionId, blocks) { return this.peer.request("session/prompt", { sessionId, prompt: blocks }); }
156
- cancel(sessionId) { this.peer.notify("session/cancel", { sessionId }); return Promise.resolve(); }
148
+ cancel(sessionId) {
149
+ // Recorded so runDelegate can hold back a prompt not yet sent.
150
+ this.cancelRequested = true;
151
+ this.peer.notify("session/cancel", { sessionId });
152
+ return Promise.resolve();
153
+ }
157
154
 
158
155
  getTranscript(n) { return this.peer ? this.peer.formatLog(n) : ""; }
159
156
 
@@ -179,8 +176,7 @@ export class AcpClient extends EventEmitter {
179
176
  return true;
180
177
  }
181
178
  const alive = isChildAlive(child);
182
- // Subscribed before the kill is dispatched. A child that dies immediately would otherwise
183
- // exit in the gap and leave this waiting on an event that has already fired.
179
+ // Subscribed before the kill, so an instant exit is not missed.
184
180
  const exited = alive
185
181
  ? /** @type {Promise<boolean>} */ (new Promise((resolve) => child.once("exit", () => resolve(true))))
186
182
  : Promise.resolve(true);
@@ -194,10 +190,8 @@ export class AcpClient extends EventEmitter {
194
190
  }));
195
191
  const observed = await Promise.race([exited, bounded]);
196
192
  clearTimeout(timer);
197
- // The exit handler rejects in-flight RPCs with stderr. Doing that here on a confirmed
198
- // exit would race it and the first settlement would drop the forensics. A stop that
199
- // did not see the child die never gets that handler, so settle those RPCs only when
200
- // the process is still alive and emitExit has not run.
193
+ // On an observed exit, emitExit rejects in-flight RPCs with stderr, and racing it here would
194
+ // drop that. Only a child still alive after the stop has its RPCs settled here.
201
195
  if (!observed && !this._exitEmitted && isChildAlive(child)) {
202
196
  try {
203
197
  this.peer?.rejectAllPending(makeError("agent-exit", "agent process did not exit after stop"));
package/src/acp-enums.js CHANGED
@@ -1,11 +1,6 @@
1
- // The value sets ACP allows for plan and todo fields, shared by the two layers that read them:
2
- // the sanitizers in delegate.js, which strip anything else off an agent frame, and the zod
3
- // schemas in server.js, which advertise them to hosts. A drift between the two would strip a
4
- // value the tool documents, or document one it strips.
5
- //
6
- // Plan status follows ACP v1 PlanEntryStatus (no cancelled). Todo status follows Cursor's
7
- // update_todos / create_plan todo arrays, which include cancelled. They stay separate
8
- // constants so they can diverge.
1
+ // Allowed plan and todo values, shared by delegate.js's sanitizers and server.js's schemas so the
2
+ // two cannot drift. Plan status follows ACP v1 PlanEntryStatus (no cancelled); todo status follows
3
+ // Cursor's update_todos and create_plan arrays, which include cancelled.
9
4
 
10
5
  export const PLAN_PRIORITIES = /** @type {const} */ (["high", "medium", "low"]);
11
6