cursor-delegate-mcp 1.19.0 → 1.20.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 +5 -3
- package/SECURITY.md +14 -6
- package/package.json +1 -1
- package/src/acp-client.js +7 -2
- package/src/delegate.js +44 -16
- package/src/server.js +18 -21
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ Cursor Delegate is the MCP bridge that lets Claude Code, ChatGPT/Codex, Copilot
|
|
|
24
24
|
|
|
25
25
|
## 🧠 Frontier quality, kept
|
|
26
26
|
|
|
27
|
-
Your assistant does what frontier models are
|
|
27
|
+
Your assistant does what frontier models are for: understands the task, writes a precise brief, reviews the finished diff. **Composer 2.5** runs the implementation loop under that brief. The bundled skill puts the review step in the loop — the agent that scoped the work reads the changed files back before reporting.
|
|
28
28
|
|
|
29
29
|
## ⚡ Done faster
|
|
30
30
|
|
|
@@ -42,12 +42,14 @@ Composer and Grok run on their **own usage allowance** on every Cursor plan —
|
|
|
42
42
|
|
|
43
43
|
- 🤝 **Native plugins** — install into Claude Code, ChatGPT/Codex, or GitHub Copilot CLI and just say *"delegate this to Cursor"*. The shared skill teaches your agent how to delegate well.
|
|
44
44
|
- 💬 **No stalled runs** — if Cursor needs to clarify, it ends the turn and returns the question as a normal result. Your agent reads it and answers by resuming the same session — nothing blocks on a modal waiting for input.
|
|
45
|
-
- 📦 **Clean, named results** — final answer, changed files, session id, and the plan, returned as one compact JSON payload. Nothing to scrape
|
|
45
|
+
- 📦 **Clean, named results** — final answer, changed files, session id, and the plan, returned as one compact JSON payload. Nothing to scrape.
|
|
46
46
|
- 📋 **Plan first** — `plan` mode: Cursor drafts a plan, you review it, then the same session implements it.
|
|
47
|
-
- 🔍 **Ask anything** — `ask` mode:
|
|
47
|
+
- 🔍 **Ask anything** — `ask` mode: Q&A over your codebase.
|
|
48
48
|
- 🩺 **Self-diagnosing** — a `doctor` tool that tells you exactly what's missing if setup isn't right.
|
|
49
49
|
- 🔌 **Portable** — plain stdio MCP, so it runs anywhere: VS Code, JetBrains, Windsurf, Visual Studio, and more.
|
|
50
50
|
|
|
51
|
+
`plan` and `ask` are instructions to the agent, and `workspace` is its working directory — [Security](SECURITY.md) and the [delegate reference](skills/delegate/reference.md) spell out what the bridge enforces and what it reports back.
|
|
52
|
+
|
|
51
53
|
## Install
|
|
52
54
|
|
|
53
55
|
You need [Node.js 20+](https://nodejs.org/) and the [Cursor CLI](https://cursor.com/docs/cli/overview), logged in (`cursor-agent login`).
|
package/SECURITY.md
CHANGED
|
@@ -2,17 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
## What this plugin does
|
|
4
4
|
|
|
5
|
-
`cursor-delegate-mcp` spawns **cursor-agent** in your workspace and **auto-approves
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
`cursor-delegate-mcp` spawns **cursor-agent** in your workspace and **auto-approves every
|
|
6
|
+
permission it requests** over ACP, in every mode — `agent`, `plan` and `ask`. Each request is
|
|
7
|
+
answered with the broadest allow option the agent offered (`allow_always`, else `allow_once`).
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
`workspace` is the agent's working directory, and a run can reach outside it. `mode` is
|
|
10
|
+
passed to the agent as an instruction, so `plan` and `ask` describe how it behaves rather
|
|
11
|
+
than what it is permitted to do. Delegated tasks can create, modify, or delete files
|
|
12
|
+
anywhere your user account can reach, and reach the network.
|
|
13
|
+
|
|
14
|
+
Treat every `delegate` call like handing an engineer a shell on your machine. Your MCP host
|
|
15
|
+
is the orchestrator: it should scope the brief, then review `filesReportedByEditTools` and
|
|
16
|
+
the git diff. That field lists what the agent's edit tools reported touching; the git diff
|
|
17
|
+
is authoritative.
|
|
10
18
|
|
|
11
19
|
## Recommendations
|
|
12
20
|
|
|
13
21
|
- Point `workspace` at the smallest directory that contains the task (not `$HOME` or `/`).
|
|
14
|
-
|
|
15
|
-
-
|
|
22
|
+
It scopes what the agent works on, not what it can reach.
|
|
23
|
+
- Review the git diff before committing, after every run — including `plan` and `ask` ones.
|
|
16
24
|
- Run verification (tests, lint) after delegation — the delegate skill asks Claude to do
|
|
17
25
|
this, but automated gates in CI are still your backstop.
|
|
18
26
|
- Do not commit secrets (`.env`, credentials, tokens). The bridge does not redact them from
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cursor-delegate-mcp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20.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, or Copilot to Cursor's CLI agent — structured results, plan mode, and changed files.",
|
package/src/acp-client.js
CHANGED
|
@@ -61,8 +61,9 @@ export class AcpClient extends EventEmitter {
|
|
|
61
61
|
this.child.stderr.on("error", () => {});
|
|
62
62
|
// A supervisor trip writes session/cancel, which can land after the agent is already gone.
|
|
63
63
|
// Without a handler that surfaces as an unhandled 'error' event on some platforms, taking
|
|
64
|
-
// the whole MCP server down with it.
|
|
64
|
+
// the whole MCP server down with it. stdout needs the same guard; readline adds none.
|
|
65
65
|
this.child.stdin.on("error", () => {});
|
|
66
|
+
this.child.stdout.on("error", () => {});
|
|
66
67
|
const emitExit = (code, signal) => {
|
|
67
68
|
if (this._exitEmitted) return;
|
|
68
69
|
this._exitEmitted = true;
|
|
@@ -80,7 +81,11 @@ export class AcpClient extends EventEmitter {
|
|
|
80
81
|
this.router = null; // set before first stdout line
|
|
81
82
|
this.peer = new JsonRpcPeer(this.child.stdout, this.child.stdin, {
|
|
82
83
|
onNotification: (method, params) => { if (method === "session/update") this.emit("update", params); },
|
|
83
|
-
|
|
84
|
+
// The router is async and its result discarded, so a throw from its own catch would reject
|
|
85
|
+
// unobserved and exit the process. Promise.resolve covers a sync router in tests.
|
|
86
|
+
onRequest: (id, method, params) => {
|
|
87
|
+
if (this.router) Promise.resolve(this.router(id, method, params)).catch(() => {});
|
|
88
|
+
},
|
|
84
89
|
onActivity: () => this.emit("activity"),
|
|
85
90
|
});
|
|
86
91
|
this.router = createRequestRouter({
|
package/src/delegate.js
CHANGED
|
@@ -143,12 +143,32 @@ async function buildContextBlocks(contextFiles, workspace, client, warnings) {
|
|
|
143
143
|
return blocks;
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
+
// Only a session the agent does not have justifies a fresh one; falling back on anything else
|
|
147
|
+
// runs the task without the context the caller asked for. Code and wording together, never
|
|
148
|
+
// either: 2026.08.11 returns -32602 `Session "<id>" not found` when it is missing, but -32603
|
|
149
|
+
// `Failed to load session "<id>": <cause>` when restore fails, and that cause can carry the
|
|
150
|
+
// same words. A missed match costs a recoverable resume-failed; a false match costs a silent turn.
|
|
151
|
+
function isMissingSession(err) {
|
|
152
|
+
const message = err?.message || "";
|
|
153
|
+
return err?.code === -32602
|
|
154
|
+
&& /\bsession\b/i.test(message)
|
|
155
|
+
&& /\bnot found\b|\bdoes not exist\b|\bunknown session\b|\bno such session\b/i.test(message);
|
|
156
|
+
}
|
|
157
|
+
|
|
146
158
|
async function openSession(client, resumeSessionId, workspace) {
|
|
147
159
|
if (!resumeSessionId) return client.newSession(workspace);
|
|
148
160
|
try {
|
|
149
161
|
await client.loadSession(resumeSessionId, workspace);
|
|
150
162
|
return { sessionId: resumeSessionId }; // load does not echo sessionId
|
|
151
163
|
} catch (err) {
|
|
164
|
+
if (!isMissingSession(err)) {
|
|
165
|
+
throw makeError(
|
|
166
|
+
"resume-failed",
|
|
167
|
+
`session ${resumeSessionId} could not be loaded: ${err?.message || String(err)}.`
|
|
168
|
+
+ ` The session was not resumed and no fresh session was started — retry, or omit`
|
|
169
|
+
+ ` resumeSessionId to start fresh deliberately.`
|
|
170
|
+
);
|
|
171
|
+
}
|
|
152
172
|
// Starting fresh is right, but silently doing so leaves the caller unable to tell a
|
|
153
173
|
// stale id from a typo'd one — keep why the load failed.
|
|
154
174
|
const fresh = await client.newSession(workspace);
|
|
@@ -225,6 +245,12 @@ export async function runDelegate({
|
|
|
225
245
|
// Before the spawn: validating later costs a process, a handshake and a billed turn.
|
|
226
246
|
assertWorkspace(workspace);
|
|
227
247
|
const promptText = await resolveSpec(spec);
|
|
248
|
+
// addEventListener does not replay an abort that already fired, and the listener is registered
|
|
249
|
+
// below, so an abort during the await above is otherwise lost. Throwing, not supervisor.abort():
|
|
250
|
+
// tripping before supervise() installs its reject settles the supervisor with nothing listening.
|
|
251
|
+
if (signal?.aborted) {
|
|
252
|
+
throw makeError("aborted", "delegation aborted by MCP host");
|
|
253
|
+
}
|
|
228
254
|
const capMs = hardCapMs ?? timeoutMs ?? envMs("CURSOR_DELEGATE_HARD_CAP_MS", 3600000);
|
|
229
255
|
const shakeMs = handshakeMs ?? envMs("CURSOR_DELEGATE_HANDSHAKE_MS", DEFAULT_HANDSHAKE_MS);
|
|
230
256
|
const turnIdleMs = idleMs ?? envMs("CURSOR_DELEGATE_IDLE_MS", 0);
|
|
@@ -495,8 +521,7 @@ export async function runDelegate({
|
|
|
495
521
|
// outstanding — it also lets a retry resume the work already done.
|
|
496
522
|
const isTimeout = err?.reason === "hard-cap" || err?.reason === "idle-timeout";
|
|
497
523
|
// A handshake timeout gets the forensics but not the long-command advice: no prompt was sent,
|
|
498
|
-
// so no shell command explains the silence.
|
|
499
|
-
// set_model/set_config_option/set_mode, any of which can hang), so the resume hint applies.
|
|
524
|
+
// so no shell command explains the silence.
|
|
500
525
|
const isStall = isTimeout || err?.reason === "handshake-timeout";
|
|
501
526
|
if (isStall || err?.reason === "aborted" || err?.reason === "agent-exit") {
|
|
502
527
|
const age = fmtDuration(supervisor.msSinceActivity());
|
|
@@ -510,20 +535,23 @@ export async function runDelegate({
|
|
|
510
535
|
}
|
|
511
536
|
const files = normalizeAgentReportedFiles([...state.touched], workspace);
|
|
512
537
|
if (files.length) err.message += ` Files reported edited: ${files.join(", ")}.`;
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
538
|
+
}
|
|
539
|
+
// Every failure after session/new leaves a live session, not just the stalls: the id is set
|
|
540
|
+
// before set_model/set_config_option/set_mode, so unknown-model and a rejected config value
|
|
541
|
+
// land here too and are abandoned without it.
|
|
542
|
+
if (resumeError) {
|
|
543
|
+
// Without this the resume hint reads as "carry on from where you were", when the requested
|
|
544
|
+
// session was never loaded.
|
|
545
|
+
err.message += ` Note: resuming ${resumeSessionId} had already failed (${resumeError}),`
|
|
546
|
+
+ ` so this ran as a fresh session and none of that earlier work was in context.`;
|
|
547
|
+
}
|
|
548
|
+
if (sessionId) err.message += ` Resume with resumeSessionId ${sessionId}.`;
|
|
549
|
+
if (isTimeout) {
|
|
550
|
+
// Name the knob that actually fired: raising the hard cap does nothing for an
|
|
551
|
+
// idle-timeout, whose ceiling is CURSOR_DELEGATE_IDLE_MS.
|
|
552
|
+
const knob = err.reason === "idle-timeout" ? "CURSOR_DELEGATE_IDLE_MS" : "CURSOR_DELEGATE_HARD_CAP_MS";
|
|
553
|
+
err.message += " cursor-agent does not stream shell output over ACP, so a long-running command emits"
|
|
554
|
+
+ ` nothing until it exits. Split the command, run it in the background and poll, or raise ${knob}.`;
|
|
527
555
|
}
|
|
528
556
|
// Opt-in: the frames land in the caller's context and nothing there is actionable — the
|
|
529
557
|
// forensics above already carry that. Raw frames only help someone debugging the bridge.
|
package/src/server.js
CHANGED
|
@@ -50,7 +50,7 @@ function rememberSession(set, id) {
|
|
|
50
50
|
// Loaded at connect, before any tool schema is, so this carries only pre-call facts: what a
|
|
51
51
|
// caller needs to decide whether to delegate at all. Call-time facts belong on the parameter
|
|
52
52
|
// descriptions, read while the call is being written.
|
|
53
|
-
export const SERVER_INSTRUCTIONS = `Delegate coding work to Cursor through the delegate tool. Every permission the agent requests is auto-approved, in every mode:
|
|
53
|
+
export const SERVER_INSTRUCTIONS = `Delegate coding work to Cursor through the delegate tool. Every permission the agent requests is auto-approved, in every mode: agent/plan/ask reach any file the user account can, and mode instructs the agent rather than limiting it. Scope workspace tightly and review the git diff after every run — filesReportedByEditTools carries only what the agent's edit tools reported; the diff is authoritative.`;
|
|
54
54
|
|
|
55
55
|
const planEntrySchema = z.object({
|
|
56
56
|
content: z.string(),
|
|
@@ -141,22 +141,17 @@ export const doctorOutputShape = {
|
|
|
141
141
|
};
|
|
142
142
|
|
|
143
143
|
export const delegateInputSchema = z.object({
|
|
144
|
-
spec: z.string().trim().min(1, "spec must not be blank").describe("
|
|
145
|
-
mode: z.enum(["agent", "plan", "ask"]).default("agent").describe("
|
|
146
|
-
resumeSessionId: z.string().optional().describe("
|
|
147
|
-
workspace: z.string().optional().describe("
|
|
144
|
+
spec: z.string().trim().min(1, "spec must not be blank").describe("Task brief: goal, scope, fixed decisions quoted exactly, acceptance criteria. Point at files to read rather than pasting code. A lone file path is read as the brief."),
|
|
145
|
+
mode: z.enum(["agent", "plan", "ask"]).default("agent").describe("agent implements; plan and ask are instructions to the agent, not limits."),
|
|
146
|
+
resumeSessionId: z.string().optional().describe("Continue an existing ACP session."),
|
|
147
|
+
workspace: z.string().optional().describe("The agent's working directory, not a limit. Defaults to the server process cwd, which under npx is often not your project root — pass it explicitly. Must already exist; never create one for the call."),
|
|
148
148
|
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."),
|
|
149
|
-
fast: z.boolean().default(false).describe("Fast
|
|
149
|
+
fast: z.boolean().default(false).describe("Fast tier; higher cost — only when the user asks."),
|
|
150
150
|
// Which options a model offers, and their valid values, are only knowable by asking the
|
|
151
151
|
// agent, so these stay open strings and the agent rejects what it does not accept.
|
|
152
|
-
effort: z.string().trim().min(1).optional().describe("Thinking effort
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
reasoning: z.string().trim().min(1).optional()
|
|
156
|
-
.refine((v) => v === undefined, { message: "reasoning was renamed to effort; pass effort instead" })
|
|
157
|
-
.describe("Removed — use effort."),
|
|
158
|
-
context: z.string().trim().min(1).optional().describe("Context window size. Not offered by every model; gpt-5.x accepts 272k and 1m."),
|
|
159
|
-
contextFiles: z.array(z.string()).optional().describe("Paths to attach instead of pasting file contents into spec. Text files are passed as references the agent may open; images (png, jpg, gif, webp, under 5MB) are sent inline. Relative paths resolve against workspace, and paths outside it are allowed — attach only files the agent should read. Anything skipped is reported in protocolWarnings, never fatal."),
|
|
152
|
+
effort: z.string().trim().min(1).optional().describe("Thinking effort; ids and values differ per model, and some offer none. gpt-5.x: none, low, medium, high, extra-high. doctor deep:true lists the current model's."),
|
|
153
|
+
context: z.string().trim().min(1).optional().describe("Context window size; gpt-5.x accepts 272k and 1m. Do not pass speculatively."),
|
|
154
|
+
contextFiles: z.array(z.string()).optional().describe("Paths to attach instead of pasting contents into spec. Text becomes references the agent may open; images (png/jpg/gif/webp, <5MB) are sent inline. Relative paths resolve against workspace but are not limited to it. Skips are reported in protocolWarnings, never fatal."),
|
|
160
155
|
});
|
|
161
156
|
|
|
162
157
|
/**
|
|
@@ -177,11 +172,13 @@ export async function runDelegateTool({ args, extra, runDelegate, inFlight, seen
|
|
|
177
172
|
if (progressToken != null) {
|
|
178
173
|
let progress = 0;
|
|
179
174
|
onProgress = (message) => {
|
|
175
|
+
// sendNotification is async: its rejection settles outside this try and would exit the
|
|
176
|
+
// server. The try stays for a sync throw, which lands before Promise.resolve can wrap it.
|
|
180
177
|
try {
|
|
181
|
-
extra.sendNotification({
|
|
178
|
+
Promise.resolve(extra.sendNotification({
|
|
182
179
|
method: "notifications/progress",
|
|
183
180
|
params: { progressToken, progress: ++progress, message },
|
|
184
|
-
});
|
|
181
|
+
})).catch(() => {});
|
|
185
182
|
} catch {}
|
|
186
183
|
};
|
|
187
184
|
}
|
|
@@ -248,7 +245,7 @@ export function buildServer({ runDelegate: runDelegateInjected, runDoctor: runDo
|
|
|
248
245
|
"delegate",
|
|
249
246
|
{
|
|
250
247
|
description:
|
|
251
|
-
`Delegate a coding task to cursor-agent over ACP. Never shell out to cursor-agent — use this tool only.
|
|
248
|
+
`Delegate a coding task to cursor-agent over ACP. Never shell out to cursor-agent — use this tool only. Auto-approves every permission the agent requests, in any mode and anywhere on disk. Clarifying questions arrive as prose in result — resume with resumeSessionId to answer. Keep model (${DEFAULT_MODEL}), fast and effort at their defaults unless the user asks. See the delegate skill.`,
|
|
252
249
|
inputSchema: delegateInputSchema,
|
|
253
250
|
annotations: {
|
|
254
251
|
title: "Delegate coding task to Cursor",
|
|
@@ -265,10 +262,10 @@ export function buildServer({ runDelegate: runDelegateInjected, runDoctor: runDo
|
|
|
265
262
|
"cancel",
|
|
266
263
|
{
|
|
267
264
|
description:
|
|
268
|
-
"Best-effort cancel of an in-flight
|
|
265
|
+
"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, not-running (turn already ended, still resumable), not-found (id never seen this process).",
|
|
269
266
|
inputSchema: {
|
|
270
267
|
sessionId: z.string(),
|
|
271
|
-
force: z.boolean().default(false).describe("
|
|
268
|
+
force: z.boolean().default(false).describe("Kill the agent process if the turn is still running after a short grace period."),
|
|
272
269
|
},
|
|
273
270
|
annotations: {
|
|
274
271
|
title: "Cancel Cursor delegation",
|
|
@@ -310,12 +307,12 @@ export function buildServer({ runDelegate: runDelegateInjected, runDoctor: runDo
|
|
|
310
307
|
"doctor",
|
|
311
308
|
{
|
|
312
309
|
description:
|
|
313
|
-
"
|
|
310
|
+
"Setup diagnostics: plugin version, MCP client capabilities, cursor-agent launcher resolution. Run when delegation fails or agent.found is false.",
|
|
314
311
|
inputSchema: {
|
|
315
312
|
deep: z
|
|
316
313
|
.boolean()
|
|
317
314
|
.default(false)
|
|
318
|
-
.describe("
|
|
315
|
+
.describe("Run an ACP handshake (start → initialize → newSession) to verify the agent is usable; adds models, modes and the current model's options."),
|
|
319
316
|
},
|
|
320
317
|
annotations: {
|
|
321
318
|
title: "Diagnose Cursor delegation setup",
|