cursor-delegate-mcp 1.5.0 → 1.7.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 +20 -26
- package/package.json +2 -2
- package/src/acp-client.js +1 -1
- package/src/delegate.js +10 -1
- package/src/server.js +47 -16
- package/src/session-supervisor.js +5 -1
- package/src/spawn.js +1 -1
package/README.md
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
# Cursor Delegate MCP
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**Keep the brains. Delegate the build.**
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/cursor-delegate-mcp)
|
|
6
6
|
[](https://www.npmjs.com/package/cursor-delegate-mcp)
|
|
7
7
|
[](https://nodejs.org)
|
|
8
8
|
[](LICENSE)
|
|
9
|
+
[](https://github.com/andreilungeanu/cursor-delegate-mcp/actions/workflows/test.yml)
|
|
9
10
|
|
|
10
11
|
<img src="assets/logo-light.png" alt="Cursor Delegate MCP logo" width="150" align="left" hspace="15">
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
Use your best coding agent where its judgment matters most: understanding the task, shaping the plan, and reviewing the result.
|
|
13
14
|
|
|
14
|
-
Cursor Delegate is
|
|
15
|
+
Cursor Delegate is the MCP bridge that lets Claude Code, ChatGPT/Codex, Copilot — or any MCP client — hand implementation to **Cursor's CLI agent**, then get a clean, structured result back for review.
|
|
15
16
|
|
|
16
17
|
<br clear="left">
|
|
17
18
|
|
|
@@ -53,7 +54,7 @@ You → your agent (plans & reviews)
|
|
|
53
54
|
|
|
54
55
|
You need [Node.js 22+](https://nodejs.org/) and the [Cursor CLI](https://cursor.com/docs/cli/overview), logged in (`cursor-agent login`).
|
|
55
56
|
|
|
56
|
-
### Claude Code
|
|
57
|
+
### Claude Code
|
|
57
58
|
|
|
58
59
|
```shell
|
|
59
60
|
/plugin marketplace add andreilungeanu/cursor-delegate-mcp
|
|
@@ -64,7 +65,7 @@ Then just ask:
|
|
|
64
65
|
|
|
65
66
|
> Delegate to Cursor: migrate src/api from callbacks to async/await and update the tests, then walk me through what changed.
|
|
66
67
|
|
|
67
|
-
That's the whole loop — Claude writes the brief, Cursor grinds through the files, Claude walks you through the diff.
|
|
68
|
+
That's the whole loop — Claude writes the brief, Cursor grinds through the files, Claude walks you through the diff.
|
|
68
69
|
|
|
69
70
|
### ChatGPT desktop / Codex
|
|
70
71
|
|
|
@@ -79,20 +80,7 @@ codex plugin add cursor-delegate-mcp@cursor-delegate-mcp
|
|
|
79
80
|
copilot plugin install andreilungeanu/cursor-delegate-mcp
|
|
80
81
|
```
|
|
81
82
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
### Any other MCP client
|
|
85
|
-
|
|
86
|
-
```json
|
|
87
|
-
{
|
|
88
|
-
"mcpServers": {
|
|
89
|
-
"cursor-delegate-mcp": {
|
|
90
|
-
"command": "npx",
|
|
91
|
-
"args": ["-y", "cursor-delegate-mcp"]
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
```
|
|
83
|
+
### More clients
|
|
96
84
|
|
|
97
85
|
<details>
|
|
98
86
|
<summary><strong>VS Code</strong> — <code>.vscode/mcp.json</code></summary>
|
|
@@ -116,7 +104,7 @@ Or run **Chat: Install Plugin From Source** with this repository's URL.
|
|
|
116
104
|
<details>
|
|
117
105
|
<summary><strong>JetBrains AI Assistant</strong> — Settings → Tools → AI Assistant → MCP</summary>
|
|
118
106
|
|
|
119
|
-
|
|
107
|
+
Under **Settings → Tools → AI Assistant → Model Context Protocol (MCP)**, add a server with command `npx` and arguments `-y cursor-delegate-mcp`.
|
|
120
108
|
|
|
121
109
|
</details>
|
|
122
110
|
|
|
@@ -157,14 +145,20 @@ Requires 17.14+. Note the top-level key is `servers`, not `mcpServers`.
|
|
|
157
145
|
|
|
158
146
|
</details>
|
|
159
147
|
|
|
160
|
-
|
|
161
|
-
<summary><strong>Kiro, Kilo Code, Zed, and friends</strong></summary>
|
|
148
|
+
### Kiro, Kilo Code, and any other MCP client
|
|
162
149
|
|
|
163
|
-
|
|
150
|
+
Add the following server to the client's MCP config:
|
|
164
151
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
152
|
+
```json
|
|
153
|
+
{
|
|
154
|
+
"mcpServers": {
|
|
155
|
+
"cursor-delegate-mcp": {
|
|
156
|
+
"command": "npx",
|
|
157
|
+
"args": ["-y", "cursor-delegate-mcp"]
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
```
|
|
168
162
|
|
|
169
163
|
## License
|
|
170
164
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cursor-delegate-mcp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "MCP server bridging AI coding hosts to cursor-agent over the Agent Client Protocol (ACP).",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
],
|
|
44
44
|
"scripts": {
|
|
45
45
|
"test": "node --test test/*.test.js",
|
|
46
|
-
"test:pack": "node
|
|
46
|
+
"test:pack": "node test/npm-package-smoke.mjs",
|
|
47
47
|
"start": "node src/server.js"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
package/src/acp-client.js
CHANGED
|
@@ -57,7 +57,7 @@ export class AcpClient extends EventEmitter {
|
|
|
57
57
|
});
|
|
58
58
|
return new Promise((resolve, reject) => {
|
|
59
59
|
this.child.once("error", (e) =>
|
|
60
|
-
reject(new Error(`Failed to spawn agent (${command}): ${e.message}. Install Cursor CLI and run 'agent login'.`)));
|
|
60
|
+
reject(new Error(`Failed to spawn agent (${command}): ${e.message}. Install Cursor CLI and run 'cursor-agent login'.`)));
|
|
61
61
|
this.child.once("spawn", () => resolve());
|
|
62
62
|
});
|
|
63
63
|
}
|
package/src/delegate.js
CHANGED
|
@@ -26,7 +26,7 @@ async function openSession(client, resumeSessionId, workspace) {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
// Composer bare ids (e.g. composer-2.5) expose standard vs fast via set_config_option.
|
|
29
|
-
// Other models use separate ids (e.g. gpt-5-fast) — see agent --list-models.
|
|
29
|
+
// Other models use separate ids (e.g. gpt-5-fast) — see cursor-agent --list-models.
|
|
30
30
|
function composerFastToggleApplies(model) {
|
|
31
31
|
return /^composer-\d+(?:\.\d+)?$/i.test(model);
|
|
32
32
|
}
|
|
@@ -36,7 +36,13 @@ export async function runDelegate({
|
|
|
36
36
|
model = "composer-2.5", fast = false, clientFactory, onElicit,
|
|
37
37
|
idleMs = 90000, hardCapMs, timeoutMs, cancelGraceMs = 10000, killGraceMs = 5000,
|
|
38
38
|
onSessionReady, onProgress, progressThrottleMs = 2000, gitChangedSet = gitChangedSetReal,
|
|
39
|
+
signal,
|
|
39
40
|
} = {}) {
|
|
41
|
+
if (signal?.aborted) {
|
|
42
|
+
const err = new Error("delegation aborted by MCP host");
|
|
43
|
+
err.reason = "aborted";
|
|
44
|
+
throw err;
|
|
45
|
+
}
|
|
40
46
|
const capMs = hardCapMs ?? timeoutMs ?? 3600000;
|
|
41
47
|
const MAX_OUTPUT = 10 * 1024 * 1024;
|
|
42
48
|
const TRUNCATION_MARKER = "\n\n[output truncated at 10MB]";
|
|
@@ -97,6 +103,8 @@ export async function runDelegate({
|
|
|
97
103
|
const make = clientFactory || ((opts) => new AcpClient(opts));
|
|
98
104
|
const client = make({ onElicit: wrappedElicit, mode, onCreatePlan: recordCreatePlan });
|
|
99
105
|
const supervisor = new SessionSupervisor(client, { idleMs, hardCapMs: capMs, cancelGraceMs, killGraceMs });
|
|
106
|
+
const onAbort = () => supervisor.abort();
|
|
107
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
100
108
|
|
|
101
109
|
const resultChunks = [];
|
|
102
110
|
let resultLength = 0;
|
|
@@ -282,6 +290,7 @@ export async function runDelegate({
|
|
|
282
290
|
} catch {}
|
|
283
291
|
throw err;
|
|
284
292
|
} finally {
|
|
293
|
+
signal?.removeEventListener("abort", onAbort);
|
|
285
294
|
try { supervisor.finish(); } catch {}
|
|
286
295
|
client.stop();
|
|
287
296
|
}
|
package/src/server.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import process from "node:process";
|
|
3
|
-
import
|
|
3
|
+
import { realpathSync } from "node:fs";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
6
6
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
@@ -37,6 +37,7 @@ const delegateOutputSchema = z.object({
|
|
|
37
37
|
resumed: z.boolean().optional(),
|
|
38
38
|
autoAnswered: z.array(z.object({ prompt: z.string(), chosen: z.string() })).optional(),
|
|
39
39
|
fallbackAnswers: z.array(z.object({ prompt: z.string(), given: z.string(), chosen: z.string() })).optional(),
|
|
40
|
+
cancelRequested: z.boolean().optional(),
|
|
40
41
|
protocolWarnings: z.array(z.string()).optional(),
|
|
41
42
|
plan: z.object({
|
|
42
43
|
entries: z.array(planEntrySchema),
|
|
@@ -133,6 +134,7 @@ export async function runDelegateTool({ args, extra, server, runDelegate, inFlig
|
|
|
133
134
|
};
|
|
134
135
|
|
|
135
136
|
let capturedSessionId;
|
|
137
|
+
let handle;
|
|
136
138
|
try {
|
|
137
139
|
const out = await runDelegate({
|
|
138
140
|
spec,
|
|
@@ -143,13 +145,16 @@ export async function runDelegateTool({ args, extra, server, runDelegate, inFlig
|
|
|
143
145
|
fast,
|
|
144
146
|
onElicit,
|
|
145
147
|
onProgress,
|
|
148
|
+
signal: extra?.signal,
|
|
146
149
|
onSessionReady: (sessionId, client) => {
|
|
147
150
|
capturedSessionId = sessionId;
|
|
148
|
-
|
|
151
|
+
handle = { client, cancelRequested: false };
|
|
152
|
+
inFlight.set(sessionId, handle);
|
|
149
153
|
},
|
|
150
154
|
});
|
|
151
155
|
if (autoAnswered.length) out.autoAnswered = autoAnswered;
|
|
152
156
|
if (fallbackAnswers.length) out.fallbackAnswers = fallbackAnswers;
|
|
157
|
+
if (handle?.cancelRequested) out.cancelRequested = true;
|
|
153
158
|
return {
|
|
154
159
|
content: [{ type: "text", text: JSON.stringify(out, null, 2) }],
|
|
155
160
|
structuredContent: out,
|
|
@@ -164,7 +169,7 @@ export async function runDelegateTool({ args, extra, server, runDelegate, inFlig
|
|
|
164
169
|
}
|
|
165
170
|
}
|
|
166
171
|
|
|
167
|
-
export function buildServer({ runDelegate: runDelegateInjected, runDoctor: runDoctorInjected } = {}) {
|
|
172
|
+
export function buildServer({ runDelegate: runDelegateInjected, runDoctor: runDoctorInjected, forceGraceMs = 5000 } = {}) {
|
|
168
173
|
const runDelegate = runDelegateInjected || runDelegateDefault;
|
|
169
174
|
const runDoctor = runDoctorInjected || runDoctorDefault;
|
|
170
175
|
const server = new McpServer(
|
|
@@ -178,11 +183,11 @@ export function buildServer({ runDelegate: runDelegateInjected, runDoctor: runDo
|
|
|
178
183
|
description:
|
|
179
184
|
"Delegate a coding task to cursor-agent over ACP. Never shell out to cursor-agent — use this tool only. Pass structured task text inline in spec (default); a file path is optional when the user wants a persisted brief. Defaults: mode=agent, model=composer-2.5, fast=false. Plan workflow: mode=plan, then resume with mode=agent and resumeSessionId. Auto-approves writes in workspace; uses MCP elicitation for clarifying questions and selects the first option when the client lacks elicitation. Returns the final result, selection source, stop reason, session ID, changed files, and optional plan. See the delegate skill for orchestration.",
|
|
180
185
|
inputSchema: {
|
|
181
|
-
spec: z.string().describe("Inline task brief (default): goal, scope, acceptance criteria. Optional file path if the user wants a persisted spec."),
|
|
186
|
+
spec: z.string().describe("Inline task brief (default): goal, scope, decisions already made (constraints and fixed choices — quote the user's exact values verbatim), acceptance criteria. Point at files to read or mimic rather than pasting code. Optional file path if the user wants a persisted spec."),
|
|
182
187
|
mode: z.enum(["agent", "plan", "ask"]).default("agent"),
|
|
183
188
|
resumeSessionId: z.string().optional().describe("Resume an existing ACP session instead of a new one"),
|
|
184
189
|
workspace: z.string().optional().describe("Working directory for the agent (defaults to cwd)"),
|
|
185
|
-
model: z.string().default("composer-2.5"),
|
|
190
|
+
model: z.string().trim().min(1, "model must be a non-empty string").default("composer-2.5"),
|
|
186
191
|
fast: z.boolean().default(false).describe("Fast speed tier — higher cost; enable only when the user asks"),
|
|
187
192
|
},
|
|
188
193
|
outputSchema: delegateOutputSchema,
|
|
@@ -197,13 +202,16 @@ export function buildServer({ runDelegate: runDelegateInjected, runDoctor: runDo
|
|
|
197
202
|
async (args, extra) => runDelegateTool({ args, extra, server, runDelegate, inFlight })
|
|
198
203
|
);
|
|
199
204
|
|
|
200
|
-
// cancel is best-effort: MCP tool calls are serialized, so delegate must finish first.
|
|
201
205
|
server.registerTool(
|
|
202
206
|
"cancel",
|
|
203
207
|
{
|
|
204
|
-
description:
|
|
205
|
-
|
|
206
|
-
|
|
208
|
+
description:
|
|
209
|
+
"Best-effort cancel of an in-flight ACP delegation by sessionId. Sends session/cancel; the agent may finish the turn anyway. The delegate result carries cancelRequested: true when the turn was cancelled mid-run. MCP hosts that serialize tool calls cannot run this while delegate is in flight. With force: true, the agent process is killed if the turn is still running after a short grace period.",
|
|
210
|
+
inputSchema: {
|
|
211
|
+
sessionId: z.string(),
|
|
212
|
+
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"),
|
|
213
|
+
},
|
|
214
|
+
outputSchema: z.object({ status: z.enum(["cancelled", "killed", "not-found"]), sessionId: z.string() }),
|
|
207
215
|
annotations: {
|
|
208
216
|
title: "Cancel Cursor delegation",
|
|
209
217
|
readOnlyHint: false,
|
|
@@ -212,19 +220,35 @@ export function buildServer({ runDelegate: runDelegateInjected, runDoctor: runDo
|
|
|
212
220
|
openWorldHint: false,
|
|
213
221
|
},
|
|
214
222
|
},
|
|
215
|
-
async ({ sessionId }) => {
|
|
216
|
-
const
|
|
217
|
-
if (
|
|
218
|
-
|
|
223
|
+
async ({ sessionId, force }) => {
|
|
224
|
+
const handle = inFlight.get(sessionId);
|
|
225
|
+
if (!handle) {
|
|
226
|
+
return {
|
|
227
|
+
content: [{ type: "text", text: `no in-flight session ${sessionId}` }],
|
|
228
|
+
structuredContent: { status: "not-found", sessionId },
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
handle.cancelRequested = true;
|
|
232
|
+
await handle.client.cancel(sessionId).catch(() => {});
|
|
233
|
+
if (!force) {
|
|
219
234
|
inFlight.delete(sessionId);
|
|
220
235
|
return {
|
|
221
236
|
content: [{ type: "text", text: `cancelled ${sessionId}` }],
|
|
222
237
|
structuredContent: { status: "cancelled", sessionId },
|
|
223
238
|
};
|
|
224
239
|
}
|
|
240
|
+
await new Promise((r) => setTimeout(r, forceGraceMs));
|
|
241
|
+
if (!inFlight.has(sessionId)) {
|
|
242
|
+
return {
|
|
243
|
+
content: [{ type: "text", text: `cancelled ${sessionId}` }],
|
|
244
|
+
structuredContent: { status: "cancelled", sessionId },
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
handle.client.stop();
|
|
248
|
+
inFlight.delete(sessionId);
|
|
225
249
|
return {
|
|
226
|
-
content: [{ type: "text", text: `
|
|
227
|
-
structuredContent: { status: "
|
|
250
|
+
content: [{ type: "text", text: `killed ${sessionId}` }],
|
|
251
|
+
structuredContent: { status: "killed", sessionId },
|
|
228
252
|
};
|
|
229
253
|
}
|
|
230
254
|
);
|
|
@@ -268,7 +292,14 @@ export function buildServer({ runDelegate: runDelegateInjected, runDoctor: runDo
|
|
|
268
292
|
}
|
|
269
293
|
|
|
270
294
|
const __filename = fileURLToPath(import.meta.url);
|
|
271
|
-
|
|
295
|
+
let isMain = false;
|
|
296
|
+
if (process.argv[1]) {
|
|
297
|
+
try {
|
|
298
|
+
isMain = realpathSync(process.argv[1]) === realpathSync(__filename);
|
|
299
|
+
} catch {
|
|
300
|
+
// An imported module must not fail just because argv[1] is not a file.
|
|
301
|
+
}
|
|
302
|
+
}
|
|
272
303
|
|
|
273
304
|
if (isMain) {
|
|
274
305
|
const server = buildServer();
|
|
@@ -70,12 +70,16 @@ export class SessionSupervisor {
|
|
|
70
70
|
}, this.idleMs);
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
abort() {
|
|
74
|
+
this._trip("aborted", "delegation aborted by MCP host");
|
|
75
|
+
}
|
|
76
|
+
|
|
73
77
|
_trip(reason, message) {
|
|
74
78
|
if (this._settled) return;
|
|
75
79
|
this._settled = true;
|
|
76
80
|
this.disarm();
|
|
77
81
|
const err = makeError(reason, message);
|
|
78
|
-
if (reason === "idle-timeout" || reason === "hard-cap") {
|
|
82
|
+
if (reason === "idle-timeout" || reason === "hard-cap" || reason === "aborted") {
|
|
79
83
|
if (!this._escalation) this._escalation = this._runEscalation();
|
|
80
84
|
}
|
|
81
85
|
this._guardReject?.(err);
|
package/src/spawn.js
CHANGED
|
@@ -10,7 +10,7 @@ export function splitArgs(raw) {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export function resolveAcpSpawn() {
|
|
13
|
-
const command = process.env.ACP_AGENT_COMMAND || "agent";
|
|
13
|
+
const command = process.env.ACP_AGENT_COMMAND || "cursor-agent";
|
|
14
14
|
const args = process.env.ACP_AGENT_ARGS
|
|
15
15
|
? splitArgs(process.env.ACP_AGENT_ARGS)
|
|
16
16
|
: ["acp"];
|