cursor-delegate-mcp 3.0.0 → 3.0.1
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 +13 -0
- package/package.json +1 -1
- package/src/delegate.js +3 -2
- package/src/server.js +21 -10
- package/src/session-supervisor.js +1 -1
- package/src/tasks.js +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,19 @@ All notable changes to this project are documented here. The format follows
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [3.0.1] - 2026-11-23
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- A delegation stopped with TaskStop in Claude Code can be resumed: `resumeSessionId` takes the
|
|
14
|
+
task's server-side id, the only id Claude Code tells the model. `cancel` takes it too and
|
|
15
|
+
reaches only that task's turn.
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- The `aborted` error drops the last tool call, frame age, todos and edited files: no host
|
|
20
|
+
receives a response to a request it cancelled. The skill reference no longer lists `aborted`.
|
|
21
|
+
|
|
9
22
|
## [3.0.0] - 2026-11-23
|
|
10
23
|
|
|
11
24
|
`delegate` no longer holds your agent while Cursor works. In an interactive Claude Code CLI session
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cursor-delegate-mcp",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
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/delegate.js
CHANGED
|
@@ -269,7 +269,7 @@ export async function runDelegate({
|
|
|
269
269
|
// already fired. Throw, not supervisor.abort(): tripping before supervise() installs its reject
|
|
270
270
|
// settles the supervisor with nothing listening.
|
|
271
271
|
if (signal?.aborted) {
|
|
272
|
-
throw makeError("aborted", "delegation aborted by MCP host");
|
|
272
|
+
throw makeError("aborted", "delegation aborted by MCP host.");
|
|
273
273
|
}
|
|
274
274
|
// Before the spawn: validating later costs a process, a handshake and a billed turn.
|
|
275
275
|
assertWorkspace(workspace);
|
|
@@ -606,7 +606,8 @@ export async function runDelegate({
|
|
|
606
606
|
// A handshake timeout gets the forensics but not the long-command advice: no prompt was sent,
|
|
607
607
|
// so no shell command explains the silence.
|
|
608
608
|
const isStall = isTimeout || err?.reason === "handshake-timeout";
|
|
609
|
-
|
|
609
|
+
// Not on an abort: the SDK sends no response to a request its host cancelled.
|
|
610
|
+
if (isStall || err?.reason === "agent-exit") {
|
|
610
611
|
const age = fmtDuration(supervisor.msSinceActivity());
|
|
611
612
|
err.message += `\n\nLast ACP frame ${age} ago${state.lastToolLabel ? `; last tool call: ${state.lastToolLabel}` : ""}.`;
|
|
612
613
|
if (state.sessionTitle) err.message += ` The agent titled this turn ${JSON.stringify(state.sessionTitle)}.`;
|
package/src/server.js
CHANGED
|
@@ -158,7 +158,7 @@ export const doctorOutputShape = {
|
|
|
158
158
|
export const delegateInputSchema = z.object({
|
|
159
159
|
spec: z.string().trim().min(1, "spec must not be blank").describe("Task brief: goal, scope, fixed decisions quoted exactly, acceptance criteria. Sent as written. Point at files to read rather than pasting code, or attach them with contextFiles."),
|
|
160
160
|
mode: z.enum(["agent", "plan", "ask"]).default("agent").describe("agent implements; plan and ask are instructions to the agent, not limits."),
|
|
161
|
-
resumeSessionId: z.string().optional().describe("Continue an existing ACP session."),
|
|
161
|
+
resumeSessionId: z.string().optional().describe("Continue an existing ACP session. When delegate ran as an MCP task, its server-side task id works too."),
|
|
162
162
|
workspace: z.string().trim().min(1, "workspace must not be blank").describe("The agent's working directory, not a limit. Smallest directory holding the task's files; with no such directory the project root is the floor. Must already exist; never create one for the call."),
|
|
163
163
|
model: z.string().trim().min(1, "model must be a non-empty string").default(DEFAULT_MODEL).describe("Bare ACP family id, version included: composer-2.5, grok-4.5, claude-opus-5, gpt-5.6-sol. doctor deep:true lists every id."),
|
|
164
164
|
fast: z.boolean().default(false).describe("Fast tier; higher cost — only when the user asks."),
|
|
@@ -193,7 +193,7 @@ export function progressNotifier(ctx) {
|
|
|
193
193
|
* seenSessions?: Set<string>,
|
|
194
194
|
* signal?: AbortSignal,
|
|
195
195
|
* onProgress?: (message: string) => void,
|
|
196
|
-
* onPromptSent?: (sessionId: string) => void,
|
|
196
|
+
* onPromptSent?: (sessionId: string, handle: any) => void,
|
|
197
197
|
* onTurnEnd?: () => void,
|
|
198
198
|
* }} deps
|
|
199
199
|
* @returns {Promise<import("@modelcontextprotocol/server").CallToolResult>}
|
|
@@ -219,7 +219,7 @@ export async function runDelegateTool({
|
|
|
219
219
|
contextFiles,
|
|
220
220
|
onProgress,
|
|
221
221
|
signal,
|
|
222
|
-
onPromptSent,
|
|
222
|
+
onPromptSent: onPromptSent && ((sessionId) => onPromptSent(sessionId, handle)),
|
|
223
223
|
onClientReady: (client) => {
|
|
224
224
|
handle = { client, cancelRequested: false };
|
|
225
225
|
pending.add(handle);
|
|
@@ -282,6 +282,15 @@ export function buildServer({
|
|
|
282
282
|
}
|
|
283
283
|
);
|
|
284
284
|
if (servesTasks) registerTaskHandlers(server, tasks);
|
|
285
|
+
// A task id names its own run, which a later turn on the same session is not; a session id names
|
|
286
|
+
// every turn running on it.
|
|
287
|
+
/** @param {string} id */
|
|
288
|
+
const targetOf = (id) => {
|
|
289
|
+
const task = tasks.get(id);
|
|
290
|
+
if (!task?.sessionId) return { sessionId: id, handles: flights.get(id) };
|
|
291
|
+
const running = task.status === "working" && flights.get(task.sessionId)?.has(task.handle);
|
|
292
|
+
return { sessionId: task.sessionId, handles: new Set(running ? [task.handle] : []) };
|
|
293
|
+
};
|
|
285
294
|
|
|
286
295
|
server.registerTool(
|
|
287
296
|
"delegate",
|
|
@@ -298,8 +307,10 @@ export function buildServer({
|
|
|
298
307
|
},
|
|
299
308
|
},
|
|
300
309
|
async (args, ctx) => {
|
|
310
|
+
// Claude Code tells the model a task's id and never its session id, even after a stop.
|
|
311
|
+
const resumeSessionId = tasks.get(args.resumeSessionId)?.sessionId ?? args.resumeSessionId;
|
|
301
312
|
/** @param {Record<string, any>} [over] */
|
|
302
|
-
const run = (over) => runDelegateTool({ args, ctx, runDelegate, inFlight: flights, pending, seenSessions, ...over });
|
|
313
|
+
const run = (over) => runDelegateTool({ args: { ...args, resumeSessionId }, ctx, runDelegate, inFlight: flights, pending, seenSessions, ...over });
|
|
303
314
|
if (!servesTasks || !listsTasks(ctx)) return run();
|
|
304
315
|
return /** @type {any} */ (runAsTask({ run, signal: ctx?.mcpReq?.signal, notify: progressNotifier(ctx), store: tasks }));
|
|
305
316
|
}
|
|
@@ -312,7 +323,7 @@ export function buildServer({
|
|
|
312
323
|
"Best-effort cancel of an in-flight delegation by sessionId. session/cancel is advisory — the agent may finish the turn anyway, and the delegate result then carries cancelRequested. Status: cancelled, killed (agent process observed to exit), not-running (turn already ended, still resumable), not-found (id not in this process's recent session history).",
|
|
313
324
|
inputSchema: z.object({
|
|
314
325
|
// Blank is a malformed call, not a stale id.
|
|
315
|
-
sessionId: z.string().trim().min(1, "sessionId must not be blank"),
|
|
326
|
+
sessionId: z.string().trim().min(1, "sessionId must not be blank").describe("When delegate runs as an MCP task, its server-side task id works too."),
|
|
316
327
|
force: z.boolean().default(false).describe("Kill the agent process if the turn is still running after a short grace period."),
|
|
317
328
|
}),
|
|
318
329
|
annotations: {
|
|
@@ -323,16 +334,16 @@ export function buildServer({
|
|
|
323
334
|
openWorldHint: false,
|
|
324
335
|
},
|
|
325
336
|
},
|
|
326
|
-
async ({ sessionId, force }) => {
|
|
327
|
-
const handles =
|
|
337
|
+
async ({ sessionId: id, force }) => {
|
|
338
|
+
const { sessionId, handles } = targetOf(id);
|
|
328
339
|
if (!handles || handles.size === 0) {
|
|
329
340
|
// A finished session is still resumable; only an unknown id is not-found.
|
|
330
341
|
const known = seenSessions.has(sessionId);
|
|
331
342
|
return cancelResult(known ? "not-running" : "not-found", sessionId);
|
|
332
343
|
}
|
|
333
|
-
// Every turn
|
|
334
|
-
//
|
|
335
|
-
//
|
|
344
|
+
// Every turn the id names, taken now: a resume that registers during the grace or the kill is
|
|
345
|
+
// not swept in. An ended turn stays registered while its agent is stopped; its result is
|
|
346
|
+
// decided, so a cancel leaves it alone.
|
|
336
347
|
const targeted = [...handles].filter((handle) => !handle.ended);
|
|
337
348
|
if (targeted.length === 0) return cancelResult("not-running", sessionId);
|
|
338
349
|
for (const handle of targeted) handle.cancelRequested = true;
|
package/src/tasks.js
CHANGED
|
@@ -20,7 +20,7 @@ export function listsTasks(ctx) {
|
|
|
20
20
|
* @typedef {{
|
|
21
21
|
* taskId: string, status: "working" | "completed" | "failed" | "cancelled",
|
|
22
22
|
* createdAt: number, lastUpdatedAt: number, endedAt?: number, statusMessage?: string,
|
|
23
|
-
* sessionId?: string, turnEnded: boolean, ac: AbortController,
|
|
23
|
+
* sessionId?: string, handle?: any, turnEnded: boolean, ac: AbortController,
|
|
24
24
|
* result?: any, error?: { code: number, message: string },
|
|
25
25
|
* }} Task
|
|
26
26
|
*/
|
|
@@ -100,7 +100,7 @@ export function createTaskStore({ now = Date.now, retainMs = RETAIN_MS, maxFinis
|
|
|
100
100
|
* Runs a delegation that answers its request with a task once the prompt is sent. A run that
|
|
101
101
|
* settles before then, setup failures included, answers with its result as a blocking call does.
|
|
102
102
|
* @param {{
|
|
103
|
-
* run: (over: { signal: AbortSignal, onProgress: (m: string) => void, onPromptSent: (id: string) => void, onTurnEnd: () => void }) => Promise<any>,
|
|
103
|
+
* run: (over: { signal: AbortSignal, onProgress: (m: string) => void, onPromptSent: (id: string, handle?: any) => void, onTurnEnd: () => void }) => Promise<any>,
|
|
104
104
|
* signal?: AbortSignal, notify?: (message: string) => void, store: ReturnType<typeof createTaskStore>,
|
|
105
105
|
* }} opts
|
|
106
106
|
*/
|
|
@@ -124,7 +124,7 @@ export async function runAsTask({ run, signal, notify = () => {}, store }) {
|
|
|
124
124
|
// Once the task is the answer, progress belongs to the task, not the request.
|
|
125
125
|
if (!answered) notify(message);
|
|
126
126
|
},
|
|
127
|
-
onPromptSent: (sessionId) => { task.sessionId = sessionId; markSent(); },
|
|
127
|
+
onPromptSent: (sessionId, handle) => { task.sessionId = sessionId; task.handle = handle; markSent(); },
|
|
128
128
|
onTurnEnd: () => { task.turnEnded = true; },
|
|
129
129
|
}).then((result) => ({ result }), (error) => ({ error }));
|
|
130
130
|
const first = await Promise.race([sent, outcome]);
|