cursor-delegate-mcp 1.16.0 → 1.18.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/README.md +1 -1
- package/package.json +10 -5
- package/src/delegate.js +23 -11
- package/src/server.js +16 -31
package/README.md
CHANGED
|
@@ -52,7 +52,7 @@ You → your agent (plans & reviews)
|
|
|
52
52
|
|
|
53
53
|
## Quick start
|
|
54
54
|
|
|
55
|
-
You need [Node.js
|
|
55
|
+
You need [Node.js 20+](https://nodejs.org/) and the [Cursor CLI](https://cursor.com/docs/cli/overview), logged in (`cursor-agent login`).
|
|
56
56
|
|
|
57
57
|
### Claude Code
|
|
58
58
|
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cursor-delegate-mcp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.18.0",
|
|
4
|
+
"mcpName": "io.github.andreilungeanu/cursor-delegate-mcp",
|
|
4
5
|
"type": "module",
|
|
5
|
-
"description": "
|
|
6
|
+
"description": "Delegate multi-file coding work from Claude Code, Codex, or Copilot to Cursor's CLI agent — structured results, plan mode, and changed files.",
|
|
6
7
|
"license": "MIT",
|
|
7
8
|
"author": "Andrei Lungeanu <andrei@lungeanu.ro>",
|
|
8
9
|
"repository": {
|
|
@@ -24,14 +25,18 @@
|
|
|
24
25
|
"chatgpt",
|
|
25
26
|
"github-copilot",
|
|
26
27
|
"vscode",
|
|
27
|
-
"composer"
|
|
28
|
+
"composer",
|
|
29
|
+
"composer-2.5",
|
|
30
|
+
"delegation",
|
|
31
|
+
"coding-agent",
|
|
32
|
+
"ai-agents"
|
|
28
33
|
],
|
|
29
34
|
"main": "src/server.js",
|
|
30
35
|
"bin": {
|
|
31
36
|
"cursor-delegate-mcp": "src/server.js"
|
|
32
37
|
},
|
|
33
38
|
"engines": {
|
|
34
|
-
"node": ">=
|
|
39
|
+
"node": ">=20"
|
|
35
40
|
},
|
|
36
41
|
"files": [
|
|
37
42
|
"src",
|
|
@@ -42,7 +47,7 @@
|
|
|
42
47
|
"LICENSE"
|
|
43
48
|
],
|
|
44
49
|
"scripts": {
|
|
45
|
-
"test": "node
|
|
50
|
+
"test": "node scripts/run-tests.mjs",
|
|
46
51
|
"test:pack": "node test/npm-package-smoke.mjs",
|
|
47
52
|
"start": "node src/server.js",
|
|
48
53
|
"typecheck": "tsc -p tsconfig.json"
|
package/src/delegate.js
CHANGED
|
@@ -97,6 +97,11 @@ async function buildContextBlocks(contextFiles, workspace, client, warnings) {
|
|
|
97
97
|
const blocks = [];
|
|
98
98
|
// A glob plus an explicit path can resolve to one file; sending it twice wastes prompt space.
|
|
99
99
|
const seen = new Set();
|
|
100
|
+
// Grouped, not one warning per file: a wrong workspace misses every attachment at once, and a
|
|
101
|
+
// line each would repeat the same root N times for one root cause. The other skip reasons stay
|
|
102
|
+
// per-entry — they are individually distinct and never arrive in bulk.
|
|
103
|
+
const notFound = [];
|
|
104
|
+
const root = path.resolve(workspace || process.cwd());
|
|
100
105
|
for (const entry of contextFiles || []) {
|
|
101
106
|
if (typeof entry !== "string" || !entry.trim()) continue;
|
|
102
107
|
const abs = path.resolve(workspace || process.cwd(), entry);
|
|
@@ -106,7 +111,7 @@ async function buildContextBlocks(contextFiles, workspace, client, warnings) {
|
|
|
106
111
|
try {
|
|
107
112
|
stat = statSync(abs);
|
|
108
113
|
} catch {
|
|
109
|
-
|
|
114
|
+
notFound.push(entry);
|
|
110
115
|
continue;
|
|
111
116
|
}
|
|
112
117
|
if (!stat.isFile()) {
|
|
@@ -128,6 +133,12 @@ async function buildContextBlocks(contextFiles, workspace, client, warnings) {
|
|
|
128
133
|
}
|
|
129
134
|
blocks.push({ type: "resource_link", uri: pathToFileURL(abs).href, name: path.basename(abs) });
|
|
130
135
|
}
|
|
136
|
+
if (notFound.length) {
|
|
137
|
+
warnings.push(
|
|
138
|
+
`contextFile${notFound.length > 1 ? "s" : ""} skipped: ${notFound.length} not found under ${root}`
|
|
139
|
+
+ ` — ${notFound.join(", ")}`
|
|
140
|
+
);
|
|
141
|
+
}
|
|
131
142
|
return blocks;
|
|
132
143
|
}
|
|
133
144
|
|
|
@@ -388,12 +399,8 @@ export async function runDelegate({
|
|
|
388
399
|
? (state.sawToolCall ? "post-tool" : "tool-free-stream")
|
|
389
400
|
: "none";
|
|
390
401
|
const protocolWarnings = [];
|
|
391
|
-
//
|
|
392
|
-
|
|
393
|
-
// orchestrator approves from result + plan.entries. So plan/ask drops it and leaves result as
|
|
394
|
-
// the agent's message verbatim. In agent mode result is the implementation report, a separate
|
|
395
|
-
// artifact from the plan — both stay.
|
|
396
|
-
const dropPlanDetail = typeof state.planDetail === "string" && (mode === "plan" || mode === "ask");
|
|
402
|
+
// The mode alone decides this — no bridge-side comparison of prose against entries.
|
|
403
|
+
const dropPlan = mode === "plan" || mode === "ask";
|
|
397
404
|
if (!finalMessageAvailable && state.discardedResult) {
|
|
398
405
|
result = state.discardedResult;
|
|
399
406
|
resultSource = "pre-tool-fallback";
|
|
@@ -437,10 +444,15 @@ export async function runDelegate({
|
|
|
437
444
|
for (const id of unsupportedOptions) protocolWarnings.push(`model ${model} has no ${id} option; the requested value was ignored`);
|
|
438
445
|
protocolWarnings.push(...contextWarnings);
|
|
439
446
|
if (state.planEntries.length > 0 || state.planOverview !== undefined || state.planDetail !== undefined) {
|
|
440
|
-
|
|
441
|
-
//
|
|
442
|
-
|
|
443
|
-
|
|
447
|
+
// Sanitize even when the plan is discarded: the warnings it raises report malformed ACP
|
|
448
|
+
// frames, which the caller needs whatever mode it asked for.
|
|
449
|
+
const plan = sanitizePlan(protocolWarnings);
|
|
450
|
+
// In plan/ask, result IS the plan — the agent's own message, already prose and already
|
|
451
|
+
// what gets shown to the user for approval. Returning entries alongside it puts the same
|
|
452
|
+
// steps in the orchestrator's context twice, and nothing consumes them: the resume that
|
|
453
|
+
// implements reads the agent's own session, not this field. In agent mode result is the
|
|
454
|
+
// implementation report, a separate artifact from the plan, so the whole object stays.
|
|
455
|
+
if (!dropPlan) out.plan = plan;
|
|
444
456
|
}
|
|
445
457
|
// Most turns emit no todos, so an empty list would read as "nothing done" rather than "not
|
|
446
458
|
// tracked". The full list is carried only when it says what todoProgress cannot — which items
|
package/src/server.js
CHANGED
|
@@ -11,8 +11,8 @@ import { VERSION } from "./version.js";
|
|
|
11
11
|
import { PLAN_PRIORITIES, PLAN_STATUSES, TODO_STATUSES } from "./acp-enums.js";
|
|
12
12
|
|
|
13
13
|
const nodeMajor = Number(process.versions.node.split(".")[0]);
|
|
14
|
-
if (nodeMajor <
|
|
15
|
-
console.error(`cursor-delegate-mcp requires Node
|
|
14
|
+
if (nodeMajor < 20) {
|
|
15
|
+
console.error(`cursor-delegate-mcp requires Node 20+ (found ${process.versions.node})`);
|
|
16
16
|
process.exit(1);
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -26,6 +26,10 @@ function registerInFlight(map, sessionId, handle) {
|
|
|
26
26
|
if (handles) handles.add(handle);
|
|
27
27
|
else map.set(sessionId, new Set([handle]));
|
|
28
28
|
}
|
|
29
|
+
/** @returns {import("@modelcontextprotocol/sdk/types.js").CallToolResult} */
|
|
30
|
+
function cancelResult(status, sessionId) {
|
|
31
|
+
return { content: [{ type: "text", text: JSON.stringify({ status, sessionId }) }] };
|
|
32
|
+
}
|
|
29
33
|
function unregisterInFlight(map, sessionId, handle) {
|
|
30
34
|
const handles = map.get(sessionId);
|
|
31
35
|
if (!handles) return;
|
|
@@ -54,11 +58,12 @@ const planEntrySchema = z.object({
|
|
|
54
58
|
status: z.enum(PLAN_STATUSES).optional(),
|
|
55
59
|
}).passthrough();
|
|
56
60
|
|
|
57
|
-
//
|
|
58
|
-
//
|
|
59
|
-
//
|
|
60
|
-
// enforced by the .strict() copy in delegate.test.js, which
|
|
61
|
-
// delegate.js is forgotten here.
|
|
61
|
+
// No tool declares an outputSchema: declaring one obliges the server to also return
|
|
62
|
+
// structuredContent, and a host that reads both it and the text block — Codex does — puts the
|
|
63
|
+
// payload in the model's context twice. Every tool returns one compact JSON text block instead.
|
|
64
|
+
// So this is an in-repo contract, enforced by the .strict() copy in delegate.test.js, which
|
|
65
|
+
// fails when a field added in delegate.js is forgotten here. cancel's status vocabulary is
|
|
66
|
+
// published in its tool description, which is now its only schema.
|
|
62
67
|
//
|
|
63
68
|
// Types only. What each field means, and what its absence means, is documented once in
|
|
64
69
|
// skills/delegate/reference.md.
|
|
@@ -204,8 +209,6 @@ export async function runDelegateTool({ args, extra, runDelegate, inFlight, seen
|
|
|
204
209
|
},
|
|
205
210
|
});
|
|
206
211
|
if (handle?.cancelRequested) out.cancelRequested = true;
|
|
207
|
-
// One copy, compact. The result also went out as structuredContent while an outputSchema
|
|
208
|
-
// was declared, which cost every host that reads both fields the whole payload twice.
|
|
209
212
|
return { content: [{ type: "text", text: JSON.stringify(out) }] };
|
|
210
213
|
} catch (err) {
|
|
211
214
|
return {
|
|
@@ -262,7 +265,6 @@ export function buildServer({ runDelegate: runDelegateInjected, runDoctor: runDo
|
|
|
262
265
|
sessionId: z.string(),
|
|
263
266
|
force: z.boolean().default(false).describe("After the cancel notify, wait a short grace period and kill the agent process if the delegation is still running"),
|
|
264
267
|
},
|
|
265
|
-
outputSchema: z.object({ status: z.enum(["cancelled", "killed", "not-running", "not-found"]), sessionId: z.string() }),
|
|
266
268
|
annotations: {
|
|
267
269
|
title: "Cancel Cursor delegation",
|
|
268
270
|
readOnlyHint: false,
|
|
@@ -277,12 +279,7 @@ export function buildServer({ runDelegate: runDelegateInjected, runDoctor: runDo
|
|
|
277
279
|
// A finished session and a garbage id are both "not in flight". Reporting them alike
|
|
278
280
|
// would read as "bad id" for a session that ran and is still resumable.
|
|
279
281
|
const known = seenSessions.has(sessionId);
|
|
280
|
-
return
|
|
281
|
-
content: [{ type: "text", text: known
|
|
282
|
-
? `session ${sessionId} is not running; its turn already ended (still resumable via resumeSessionId)`
|
|
283
|
-
: `no in-flight session ${sessionId}` }],
|
|
284
|
-
structuredContent: { status: known ? "not-running" : "not-found", sessionId },
|
|
285
|
-
};
|
|
282
|
+
return cancelResult(known ? "not-running" : "not-found", sessionId);
|
|
286
283
|
}
|
|
287
284
|
// Cancel every turn running on the id: the caller named a session, not one of the
|
|
288
285
|
// turns that happen to share it.
|
|
@@ -293,25 +290,14 @@ export function buildServer({ runDelegate: runDelegateInjected, runDoctor: runDo
|
|
|
293
290
|
// be running. Dropping them here made the natural escalation — cancel, wait, cancel
|
|
294
291
|
// with force — report not-found while the agent was alive. Each delegation's own
|
|
295
292
|
// finally removes its handle when the turn actually settles.
|
|
296
|
-
return
|
|
297
|
-
content: [{ type: "text", text: `cancelled ${sessionId}` }],
|
|
298
|
-
structuredContent: { status: "cancelled", sessionId },
|
|
299
|
-
};
|
|
293
|
+
return cancelResult("cancelled", sessionId);
|
|
300
294
|
}
|
|
301
295
|
await new Promise((r) => setTimeout(r, forceGraceMs));
|
|
302
296
|
const stillRunning = inFlight.get(sessionId);
|
|
303
|
-
if (!stillRunning || stillRunning.size === 0)
|
|
304
|
-
return {
|
|
305
|
-
content: [{ type: "text", text: `cancelled ${sessionId}` }],
|
|
306
|
-
structuredContent: { status: "cancelled", sessionId },
|
|
307
|
-
};
|
|
308
|
-
}
|
|
297
|
+
if (!stillRunning || stillRunning.size === 0) return cancelResult("cancelled", sessionId);
|
|
309
298
|
for (const handle of stillRunning) handle.client.stop();
|
|
310
299
|
inFlight.delete(sessionId);
|
|
311
|
-
return
|
|
312
|
-
content: [{ type: "text", text: `killed ${sessionId}` }],
|
|
313
|
-
structuredContent: { status: "killed", sessionId },
|
|
314
|
-
};
|
|
300
|
+
return cancelResult("killed", sessionId);
|
|
315
301
|
}
|
|
316
302
|
);
|
|
317
303
|
|
|
@@ -342,7 +328,6 @@ export function buildServer({ runDelegate: runDelegateInjected, runDoctor: runDo
|
|
|
342
328
|
version: server.server.getClientVersion(),
|
|
343
329
|
}),
|
|
344
330
|
});
|
|
345
|
-
// Single compact copy, for the reason runDelegateTool returns one.
|
|
346
331
|
return { content: [{ type: "text", text: JSON.stringify(out) }] };
|
|
347
332
|
}
|
|
348
333
|
);
|