cursor-dispatcher
An MCP server that lets Claude spawn Cursor subagents as async, bounded workers, enabling non-blocking task delegation with asynchronous completion notifications.
README
cursor-dispatcher
An MCP server + Claude Code plugin that lets Claude spawn Cursor subagents as async, bounded workers.
Claude delegates a task, gets a run_id back immediately, and continues talking to the user. When the subagent finishes, a plugin hook injects the outcome into Claude's next turn — no polling, no blocked chat.
The original design spec lives in
PRD.md.
What it does
- Spawn Cursor subagents on demand (
spawn_subagent). - Message them mid-run via
--resume=<chat_id>(send_subagent_message). - Stream their NDJSON events to disk as they run (readable via
get_subagent_eventsor thesubagent://<run_id>/eventsMCP resource). - Synthesize a structured completion payload — status, summary, artifacts (file edits + shell tool calls with stdout/stderr) — via
get_subagent_result. - Cancel, list, prune.
- Retain run history under
~/.claude-cursor-harness/with tiered compression (7d → gzip, 14d → delete) and an LRU cap. - Notify Claude asynchronously via an
UserPromptSubmithook so subagent completions surface without polling. - Preflight cursor-agent auth on startup + every spawn; refuses with an actionable error if not logged in.
Requirements
- Node ≥ 20 (for the MCP server)
cursor-agentinstalled on$PATH, authenticated viacursor-agent loginorCURSOR_API_KEYenv var- Claude Code (for the plugin — hooks, skill, slash command)
Install
Public (via GitHub marketplace)
From inside Claude Code:
/plugin marketplace add ppetko98/cursor-dispatcher
/plugin install cursor-dispatcher@cursor-dispatcher
/reload-plugins
That's it — Claude Code clones the repo, wires up the MCP server, hook, skill, and slash command. You still need cursor-agent installed on $PATH and authenticated (see /cursor-login).
Local (for dev)
git clone https://github.com/ppetko98/cursor-dispatcher.git
cd cursor-dispatcher
npm install
npm run build
# From Claude Code:
/plugin marketplace add /absolute/path/to/cursor-dispatcher
/plugin install cursor-dispatcher@cursor-dispatcher
/reload-plugins
Then verify:
/mcp # cursor-dispatcher should be listed
/hooks # UserPromptSubmit → on-user-prompt.mjs
Skill: cursor-dispatcher:cursor-subagent
Slash: /cursor-login
Without the plugin (MCP-only)
If you only want the MCP tools without the hook + skill:
claude mcp add cursor-dispatcher -- node /absolute/path/to/cursor-dispatcher/dist/server.js
Usage (from Claude)
Typical delegation flow, driven by the shipped cursor-subagent skill:
- You: "have cursor scaffold a fastify server under
./demo." - Claude: calls
spawn_subagent({ prompt: "...", cwd: "...", permission: "auto" })→ returnsrun_idinstantly. Tells you it's running and moves on. - Subagent runs
cursor-agent -p --output-format stream-json --resume-supportin the background, streaming NDJSON events to~/.claude-cursor-harness/runs/<run_id>/events.ndjson. - You send any next message — the
UserPromptSubmithook scans for terminal transitions and prependsSUBAGENT <id> → completed — <summary>to your prompt. - Claude sees the update inline in the very next turn and reports back with the outcome (files edited, shell output, etc.).
Follow-ups on the same run use send_subagent_message — it re-invokes cursor-agent --resume=<chat_id> so the subagent picks up where it left off.
Permission model
The harness maps the parent Claude session's own posture to Cursor's approval flags:
permission value |
Cursor flags | When to pick |
|---|---|---|
read |
--mode ask (no --trust) |
Parent Claude is in plan / read-only mode. Subagent cannot write files or run shell commands. |
auto (default) |
--trust --auto-review |
Default. Server-side classifier auto-approves safe tool calls; unsafe ones would prompt (and effectively hang in headless mode). |
trust |
--trust --yolo |
Fully autonomous. Use only when the user has explicitly said "let it rip." |
Model must come from an allowlist (default: auto, gpt-5.2, claude-opus-5-thinking-high, claude-opus-4-8-thinking-high, composer-2.5). Working directory must live under a configured root (default ~/workspace).
MCP tools
All tools live under the cursor-dispatcher MCP server.
| Tool | Purpose |
|---|---|
spawn_subagent |
Launch a new subagent. Returns { run_id, chat_id?, status } immediately. |
send_subagent_message |
Send a follow-up message to a run (resumes the same Cursor chat). |
get_subagent_status |
Cheap poll: status + last event id + current turn. |
get_subagent_events |
Fetch NDJSON events since a given event_id. |
get_subagent_result |
Terminal-run completion payload: { status, summary, artifacts: [{ type, ref, metadata }] }. |
list_subagents |
Filterable list of runs known to the harness. |
cancel_subagent |
SIGTERM the child. |
prune_subagents |
Manual cleanup: { compress_after_days?, max_age_days?, keep_last?, dry_run? }. |
Resources are exposed at subagent://<run_id>/status and subagent://<run_id>/events, with notifications/resources/updated fired on each new batch of events.
Configuration
Precedence: env var > ~/.claude-cursor-harness/config.json > built-in defaults.
Example config file:
{
"runtime": { "cursorBin": "cursor-agent" },
"policy": {
"models": ["auto", "gpt-5.2"],
"defaultModel": "auto",
"cwdRoot": "/Users/you/workspace",
"sandbox": "enabled"
},
"retention": {
"compressAfterDays": 7,
"maxAgeDays": 14,
"maxRuns": 200,
"pruneOnStartup": true,
"pruneOnSpawn": true
}
}
Env-var overrides:
| Env | Config path |
|---|---|
CURSOR_HARNESS_HOME |
root data dir (default ~/.claude-cursor-harness) |
CURSOR_HARNESS_BIN |
runtime.cursorBin |
CURSOR_HARNESS_MODELS |
policy.models (comma-separated) |
CURSOR_HARNESS_DEFAULT_MODEL |
policy.defaultModel |
CURSOR_HARNESS_CWD_ROOT |
policy.cwdRoot |
CURSOR_HARNESS_SANDBOX |
policy.sandbox |
CURSOR_HARNESS_COMPRESS_AFTER_DAYS |
retention.compressAfterDays |
CURSOR_HARNESS_MAX_AGE_DAYS |
retention.maxAgeDays |
CURSOR_HARNESS_MAX_RUNS |
retention.maxRuns |
CURSOR_HARNESS_PRUNE_ON_STARTUP |
retention.pruneOnStartup |
CURSOR_HARNESS_PRUNE_ON_SPAWN |
retention.pruneOnSpawn |
CURSOR_API_KEY |
cursor-agent auth (bypasses login) |
Retention
Each run's data lives under ~/.claude-cursor-harness/runs/<run_id>/:
runs/<run_id>/
├── meta.json # RunMeta (status, model, chat_id, session, summary, retention state)
├── events.ndjson # NDJSON of every parsed cursor-agent event
├── messages.ndjson # Parent ↔ subagent message log
└── artifacts/ # Reserved for future materialized outputs
Lifecycle:
- 0–7 days: kept fully.
- 7–14 days:
events.ndjsonandmessages.ndjsongzipped in place.meta.jsongainsretentionState: "compressed",compressedAt, and a materializedsummaryso it stays self-describing.get_subagent_resultstill works —readEventstransparently gunzips. - >14 days: entire run dir deleted.
- LRU: if more than
maxRunsterminal survivors remain, the oldest (byendedAt) are deleted regardless of age. - Non-terminal runs are never touched.
Triggers: startup (registry.load), after every spawn_subagent, and on-demand via prune_subagents.
The plugin bundle
Under plugin/:
- MCP server — same code that ships as
dist/server.js. - Skill
cursor-subagent(plugin/skills/cursor-subagent/SKILL.md) — teaches Claude the non-blocking pattern, permission mapping, and follow-up flow. - Slash command
/cursor-login(plugin/commands/cursor-login.md) — walks the user through interactive login orCURSOR_API_KEYsetup. - Hook
UserPromptSubmit(plugin/hooks/on-user-prompt.mjs) — before each of your prompts, scans for new terminal transitions and injects a summary block. Filters to this Claude Code session where possible; falls back to reporting mismatched-session runs as[unlinked]so nothing is silently missed.
Development
npm install
npm run build # tsc
npm test # vitest (34 tests)
npm run lint # tsc --noEmit
Repo layout:
src/
├── server.ts # MCP stdio entrypoint
├── config.ts # Config layer (env + config.json)
├── session.ts # Per-server session id resolver
├── types.ts
├── runtime/
│ ├── runner.ts # Cursor CLI child process
│ ├── registry.ts # In-memory + disk-backed run registry
│ ├── storage.ts # ~/.claude-cursor-harness/ layout + gzip helpers
│ ├── events.ts # NDJSON parser, summary + artifact synthesis
│ ├── cleanup.ts # Retention engine (compress/delete/LRU)
│ ├── auth.ts # cursor-agent status preflight
│ └── notifier.ts # MCP notifications helpers
├── tools/ # One file per MCP tool
└── policy/ # Model allowlist, sandbox, cwd whitelist
plugin/
├── .claude-plugin/plugin.json
├── skills/cursor-subagent/SKILL.md
├── commands/cursor-login.md
└── hooks/on-user-prompt.mjs
tests/
Known limitations
- Session linking is loose. Claude Code doesn't expose a shared session id to child MCP servers, so runs stamped with the MCP server's random UUID rarely match the session id Claude Code injects into the hook. The hook falls back to reporting these as
[unlinked]so nothing is missed — noisy if you run concurrent Claude sessions. - True mid-silence wake-up isn't possible. MCP notifications reach the client but Claude Code doesn't (currently) auto-invoke the model on them. Subagent completions surface on your next prompt, not asynchronously.
spawn_subagentrequires a working cursor-agent + auth. No queueing, no retry. If cursor-agent isn't installed or not authenticated, the tool call fails with a clear message pointing at/cursor-login.
License
PolyForm Noncommercial 1.0.0 — free for personal, research, educational, hobbyist, and other noncommercial use (including noncommercial open-source projects, charities, and government/academic institutions). Commercial use, hosting-as-a-service, and repackaging for resale are not permitted. If you want to use this in a for-profit setting, open an issue to discuss a commercial license.
Note: "noncommercial" here does not meet the OSI's Open Source Definition (which forbids field-of-use restrictions); this is a source-available license.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。