wb-cursor-bridge
This server provides a governed MCP bridge for dispatching Cursor CLI coding tasks asynchronously and managing their full lifecycle.
Dispatch tasks immediately with a job ID, choosing
consult(read-only Q&A),plan(read-only planning), orexecute(writable, isolated in a git worktree).Poll job status, wait briefly for completion, and fetch only new events with a cursor.
Reply to paused
input-requiredjobs to resume the same task, or send follow-up input preserving Cursor thread context.Cancel running jobs and kill their entire process tree.
List recent jobs with status, tier, and duration.
Inspect what an
executejob changed: changed files, diffstat, and paged raw patch.Run preflight health diagnostics and view job outcome/tier/duration stats.
Gracefully shut down the bridge, canceling in-flight jobs and flushing state.
Enforce workspace allowlists, isolated worktrees, timeouts, concurrency limits, and artifact/audit persistence.
Optionally expose an A2A HTTP service for agent discovery and JSON-RPC task dispatch, streaming, cancellation, auth, and push notifications.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@wb-cursor-bridge Have Cursor fix the failing auth tests in my api repo and show the diff"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
wb-cursor-bridge
把 Cursor CLI 包装成一个受治理的 MCP 子代理,让 WorkBuddy(主)调度它执行代码任务。
WorkBuddy 是唯一的控制面(Supervisor),Cursor 是无状态、可替换的执行器(Worker)。
单向控制面 + 双向数据面:Cursor 可以回问取证,但不能反向派活,杜绝控制环路。
用 MCP 承载传输、按 A2A 语义建模(异步任务 + 会话接续 + 产物可追溯),后续换传输层上层零改动。
另起一个 A2A v1.0 HTTP 服务面(
/.well-known/agent.json+ JSON-RPC 2.0),让另一个 agent 能直接发现并调度它。
目标平台:win-x64(同时可在 macOS / Linux 运行)。
一键安装(Windows)
解压
wb-cursor-bridge-v<version>-win-x64.zip(例如wb-cursor-bridge-v0.4.0-win-x64.zip)在解压目录执行:
# 交互式(会提示输入仓库路径)
powershell -ExecutionPolicy Bypass -File install.ps1
# 或一次性给全参数
powershell -ExecutionPolicy Bypass -File install.ps1 `
-WorkspaceRoots "C:\src\api;C:\src\web" `
-MaxConcurrency 4 -TimeoutSec 900安装器会:
步骤 | 行为 |
校验 | 工作区根目录存在;拒绝非法路径 |
运行时 | 复用 PATH 上的 Node 18+;没有则用 |
Cursor | 自动探测 |
配置 | 写入 |
注册 | 同时注册到 WorkBuddy/CodeBuddy( |
自检 | 启动一次 bridge 并输出健康报告 |
常用参数:-BundleNode、-SkipMcp、-Force、-AdminPort 7801、-CursorBin <path>、-NodeVersion v22.12.0、-AdminShutdownToken <token>、-NodeMirror <url>、-NodeOfflinePackage <zip>。
卸载:
powershell -ExecutionPolicy Bypass -File uninstall.ps1 # 保留日志与审计
powershell -ExecutionPolicy Bypass -File uninstall.ps1 -Purge # 一并清除状态为什么 MCP 入口指向
node.exe而不是launcher.cmd:MCP 客户端用child_process.spawn启动 server,而 Node 在不经过 shell 时拒绝执行.cmd/.bat。launcher.cmd保留给人工排障。
Related MCP server: cursor-mcp-bridge
工具(9 个)
工具 | 用途 |
| 派发任务,立即返回 jobId,永不阻塞 |
| 轮询; |
| 追问;通过 |
| 取消并杀掉整个进程树 |
| 列出近期任务与状态 |
| 查看 |
| 预检:二进制、白名单、状态目录、并发、指标 |
| 成功率 / 耗时 / tier 分布 |
| 取消在途任务、落盘、退出 |
权限分档
tier | Cursor 参数 | 能力 | 隔离 |
|
| 只读问答 | 无 |
|
| 只读规划 | 无 |
|
| 可写 | bridge 托管的 git worktree |
调用方只选档位,永远不传 CLI flag —— 权限策略集中在 bridge,不会被上层 prompt 绕过。
工作原理
WorkBuddy ──MCP(stdio)──▶ wb-cursor-bridge ──spawn──▶ agent -p --output-format stream-json
│ │
├─ 路径白名单 └─ git worktree(execute 档)
├─ 超时 / 并发 / 进程组终止
├─ 事件 JSONL 审计
└─ patch / report 产物落盘execute 任务完成后,bridge 会先把改动导出为 patch 与 report,再删除 worktree —— 你的检出目录始终不被污染。
A2A 互操作(Agent2Agent v1.0)
除了 MCP 控制面,bridge 还能以一个合规的 A2A agent 身份被另一个 agent 发现并对话——
复用同一套 JobManager 引擎,只是把 A2A 请求翻译成引擎调用、把引擎状态翻译成 A2A 响应。
设置 CURSOR_BRIDGE_A2A_PORT 为非 0 即可启用(沿用 adminPort 的"0 = 关闭"约定)。
发现
curl http://127.0.0.1:<a2aPort>/.well-known/agent.json返回遵循 A2A schema 的 Agent Card:protocolVersion、capabilities(streaming /
pushNotifications / stateTransitionHistory)、按 workspace root 派生的 skills[]、
以及启用鉴权时的 securitySchemes / security。
端点与方法
JSON-RPC 2.0 全部
POST /a2a:message/send:派发任务(带message.taskId时续跑既有input-required任务,闭环同一任务 id)tasks/get:支持historyLength取对话历史tasks/cancel:仅submitted/working/input-required可取消,终态返回TASK_NOT_CANCELABLE(-32002)message/stream/tasks/resubscribe:以text/event-stream推送status-update/artifact-update,终态带final
错误码:
TASK_NOT_FOUND(-32001)/INVALID_PARAMS/TASK_NOT_CANCELABLE(-32002)/METHOD_NOT_FOUND(-32601)/UNSUPPORTED_OPERATION(-32004)/AUTH_REQUIRED(-32097)
关键语义约定
A2A 文本在
parts[].text,不在顶层.text;taskId是 Message 的顶层字段(不在 metadata)。 续跑/跟进沿用父任务的contextId;产物以标准Artifact[]暴露,input-required 中断态保留在同一任务 id 上。中断不等于丢弃:暂停时已产生的改动会落盘为 patch,续跑轮自动回放到新 worktree, 桥重启后同样成立。若无法回放(基线移动等),任务退回
input-required并写明原因, 绝不在残缺的代码树上继续执行。
推送通知(可选)
在 message/send 的 message.metadata.pushNotification 带上 { "url": "<webhook>", "token": "..." },
任务终态时 bridge 会向该 webhook POST 一个 status-update 事件(含 3 次重试)。
鉴权(可选)
设置 CURSOR_BRIDGE_A2A_AUTH_TOKEN 后,所有 POST /a2a 必须携带 Authorization: Bearer <token>
或 header X-A2A-Token: <token>,否则返回 401 AUTH_REQUIRED(-32097)。Agent Card 端点保持公开。
A2A v1.0 迁移路线(可选,默认 v0.3.0)
bridge 已内置 v1.0 序列化边界(src/a2a/compat.ts),通过 CURSOR_BRIDGE_A2A_PROTOCOL_VERSION=1.0 启用,无需改代码:
v0.3.0(默认):零回归,沿用既有 Agent Card / Task 形状。
v1.0:Agent Card 的
protocolVersion移入supportedInterfaces['a2a/v1.0'],顶层新增extensions: [];Task/Artifact 的FileContent字段重映射(name→filename、mimeType→mediaType、uri→url、bytes_inline→raw)。message/send/tasks/get/tasks/cancel/message/stream方法名与 JSON-RPC 信封不变。
v1.0 与 v0.3.0 走同一套引擎与同一端口,仅序列化形状不同;建议先在受控环境用下方最小客户端验证 Card/Task 形状后,再对全网客户端切版本。
最小 v1.0 客户端示例(fetch + JSON-RPC):
# 1) 取 v1.0 Agent Card(注意 protocolVersion 已不在顶层,改看 supportedInterfaces)
curl -s http://127.0.0.1:<a2aPort>/.well-known/agent.json | jq '{supportedInterfaces, extensions, name}'
# 2) 派发任务(阻塞等待终态;v1.0 同样用顶层 taskId + parts[].text)
curl -s -X POST http://127.0.0.1:<a2aPort>/a2a \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":1,"method":"message/send","params":{
"message":{"role":"user","parts":[{"text":"在 demo 仓库加一个 hello 函数"}],
"messageId":"m1"},
"configuration":{"blocking":true,"acceptedOutputModes":["text/plain"]}}}'
# 3) 取回 Task,校验 v1.0 FileContent 形状(filename/mediaType/url/raw)
curl -s -X POST http://127.0.0.1:<a2aPort>/a2a \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":2,"method":"tasks/get","params":{"id":"<taskId>","historyLength":10}}' \
| jq '.result.artifacts[]?.parts[]? | select(.file) | .file | {filename, mediaType, url}'配置
%LOCALAPPDATA%\wb-cursor-bridge\config.json(也可用同名环境变量覆盖):
键 / 环境变量 | 默认 | 说明 |
|
| Cursor CLI 路径。Windows 上若指向 |
| 空 | 允许的仓库根, |
|
| 索引、日志、产物 |
|
| 单任务墙钟上限 |
|
| 同时在跑的 worker 上限,超限快速失败( |
|
| 「活任务」上限: |
|
|
|
|
| 单任务事件环的字节预算。 |
| 空 | 额外透传给 worker 的环境变量名(逗号分隔)。默认只传 |
|
| 开启后提供 |
| 空 | 未设置时 |
| 空 | 设置后每个 job 的事件会异步追加到 |
|
| 设为 |
|
|
|
|
| 设为非 0 后暴露 A2A HTTP 服务面(Agent Card + JSON-RPC) |
|
| 监听地址;设 |
| 空 | 设置后 A2A 端点(含 |
| 空 | 对外可达地址,用于 Agent Card 中的 |
| 空 | 逗号分隔的受信 webhook 主机白名单;开启 push 且目标为私有/loopback 时必须命中此项(SSRF 防护逃逸口) |
|
| A2A 协议版本;设为 |
|
|
|
|
|
|
| 空 | 逗号分隔的允许跨域 origin 列表;命中时反射 |
|
| 为允许的来源发送 |
| 空 | 额外 skill 声明( |
安全模型
工作区白名单:路径需同时通过字面与 realpath 双重校验;拒绝
..越界、符号链接逃逸、NUL 字节、DOS 保留设备名、8.3 短名。进程隔离(fail closed):
execute必须在独立 git worktree 内执行;非 git 目录、worktree 创建失败、子目录越界一律拒绝任务,绝不降级为在调用方 checkout 里--force直写。每次尝试用唯一目录名(jobId + 时间 + 随机),续跑撞不上上一次的残留。参数边界:prompt 前固定加
--终止符,model不许以-开头——否则prompt: "--force"会被当成 flag,把 consult 档升级成写权限。环境隔离:worker 只继承白名单 env;宿主密钥(
*TOKEN*/*SECRET*/*KEY*)默认不可见,需要时用CURSOR_BRIDGE_ENV_PASSTHROUGH逐个点名。HTTP 面:
headersTimeout=10s/requestTimeout=60s/keepAliveTimeout=5s/maxConnections=512;限流按来源 IP 分桶(原先单桶=一个客户端能把所有人打成 429),SSE 不受请求超时影响。进程回收:worker pid 落盘,重启后校验
/proc/<pid>/cmdline再回收上一条命遗留的 agent;pid 被复用时不会误杀。资源上限:超时强杀、并发上限、活任务上限、暂停 TTL、结果体积上限、事件环字节上限、job LRU,淘汰时同步删除磁盘产物与事件日志。
审计:任务索引与产物原子落盘;可选开启事件 JSONL 持久化(
CURSOR_BRIDGE_PERSIST_EVENTS=1)以满足强审计需求。崩溃后重启会把遗留running任务标记为orphaned。stdout 洁癖:任何
console.log都被重定向到 stderr,避免污染 JSON-RPC 流。
bridge_stats中的totalDurationMs是进程内运行时计数,长期运行后可能丢失整数精度;需要长期精确统计时请外部系统定期拉取/stats后重启 bridge。
⚠️ MCP server 不受调用方沙箱与审批策略约束 —— bridge 本身就是策略边界。 白名单、worktree、超时、并发、审计必须全部保留,不要为了方便关掉。
开发
npm install
npm run lint # ESLint(correctness 规则;0 error 才放行)
npm run typecheck # tsc --noEmit
npm test # 151 项:单元 + 硬化 + 端到端 + admin + A2A + 审计回归(test/audit-b0)
npm run test:stress # 压力:高并发 / 反复 cancel-reply / hang 超时
npm run test:fault # 故障:磁盘/权限异常的优雅降级
npm run test:audit # 第三方审计 PoC 的反向回归(修复后必须绿)
npm run test:a2a # 仅跑 A2A 互操作(Agent Card / message/send / tasks/get / cancel / stream / push / auth / blocking / 协商 / 限流 / CORS / v1.0 / skills)
npm run verify # 门禁:lint + typecheck + npm test + stress + fault + release 构建
npm run verify:e2e # 端到端真跑实证:真实 dist 二进制 + fake-agent,54 项(v0.3.0/v1.0/鉴权/限流/CORS/产物可达/input-required 续跑/push 真投 + SSRF 拒绝/tasks/cancel 真实取消与清理/崩溃清理…);Linux 与 Windows CI 均执行
npm run build # 编译到 dist/
npm run build:release # 产出 release/wb-cursor-bridge-v<version>-win-x64.zip端到端测试用一个模拟 agent 二进制(test/fake-agent.mjs)讲同一种 stream-json 协议,因此无需 Cursor 账号或网络即可验证全链路。真实 Cursor CLI 集成见下文。
PowerShell 脚本测试(安装器会重写用户配置,值得单独跑):
pwsh -File test/mcp-config.test.ps1目录结构
src/
index.ts 入口:协议装配、stdout 保护、优雅关闭
config.ts 配置解析与校验
tools.ts 9 个 MCP 工具的定义与分发
runner.ts 任务调度、worktree 托管、指标、input-required 续跑
store.ts 任务仓库:持久化、LRU、崩溃恢复
a2a/ A2A v1.0 语义层:types / convert / card / skills / watch / server
logger.ts 分级日志 + JSONL 轮转(按写入次数触发 stat)
admin.ts 可选 HTTP 运维端点(shutdown 支持 token)
version.ts 版本号唯一来源(测试断言与 package.json 一致)
cursor/
cli.ts Cursor 调用、进程管理、结果装配
parse.ts stream-json 解析(容错)
util/
paths.ts Windows 感知的路径白名单
processes.ts 跨平台进程树终止
git.ts worktree 生命周期与产物抓取
ndjson.ts 增量 JSON 行读取
scripts/
build-release.mjs 单文件打包 + ZIP(自实现 zip writer,零依赖)
install.ps1 一键安装
uninstall.ps1 卸载
lib/ 安装器共享库(MCP 配置合并)故障排查
现象 | 处理 |
|
|
| 任务路径不在白名单内,检查 |
| 调高 |
任务一直 | 用 |
启动即退出码 2 | 配置非法,看 |
MCP 工具没出现 | 确认配置写在 |
想看实时状态 | 设 |
shutdown 端点 503 | 未设置 |
shutdown 端点 401 | 设置了 token 但请求未带/带错 header;query |
A2A 端点 401 | 设置了 |
A2A 控制面暴露告警 | 把 |
push 通知没生效 | 开启 push 必须设置 |
版本历史
完整变更记录见 CHANGELOG.md。
版本 | 要点 |
0.4.3 | 工程门禁:ESLint 接入 |
0.4.2 | 非法配置不再静默回退( |
0.4.1 | 修复 |
0.4.0 | A+ 路线图收尾:消费 |
0.3.4 | A2A 真互联:Agent Card 发现 + JSON-RPC 语义层(message/send、tasks/get、tasks/cancel、message/stream SSE、push 通知、Bearer 鉴权);生产级硬化(LRU 保 input-required、文件产物可寻址、SSRF 防护、资源/并发修复、/healthz /metrics /version),83 项测试 |
0.3.3 | P3 加固:可选事件 JSONL 持久化、压力/故障测试、Node 镜像与离线包、Windows CI、metrics 说明 |
0.3.2 | P1/P2 风险消除:参数 limit 钳制、kill 结果记录、persist 失败告警、同步 shutdown、构建后 smoke |
0.3.1 | 全仓审计修复:安装器升级停不掉旧进程、 |
0.3.0 | health 缓存、admin shutdown token、 |
0.2.0 | 首个工程化版本:9 工具、bridge 托管 worktree、win-x64 一键安装 |
真实 Cursor CLI 集成
仓库默认使用 test/fake-agent.mjs 跑测试,不依赖 Cursor 授权。若要在真实 Cursor CLI 上验证:
安装 Cursor CLI 并确认
agent.exe --help可用。在 Windows PowerShell 执行:
$env:CURSOR_BIN = 'C:\Users\<you>\AppData\Local\Programs\cursor\bin\agent.exe'
$env:CURSOR_BRIDGE_WORKSPACE_ROOTS = 'C:\src\demo'
node --test test/e2e.test.mjs或手动触发
.github/workflows/real-cursor-snapshot.yml,填写cursorBin与workspaceRoots。
真实 Cursor 的输出字段可能随版本漂移;遇到解析失败请在 bridge.log 中抓取原始行并提 issue。
文档与报告
本仓库随附以下设计、审计与变更文档,建议按"方案 → 审计 → 变更"的顺序阅读:
文档 | 内容 |
项目说明、一键安装、工具(9 个)、A2A 服务面、配置表、排障、版本历史 | |
语义化版本变更记录(0.2.0 → 0.4.0),版本号来源唯一( | |
A+ 生产级全栈审计与路线图:六维审计 + Phase 0–3 落地 + 端到端真跑实证(54/54 检查全绿) | |
A2A v0.3.3 专项审计报告(Agent Card / message/send / tasks / stream / push / auth 对照表) | |
v0.3.3 全仓审计报告 | |
原始方案设计:双智能体互操作架构、控制面/数据面划分、WorkBuddy↔Cursor 治理边界 |
阅读建议:先看方案理解架构动机与治理边界,再读 A+ 审计报告了解生产级演进路线与真跑实证结论,最后按需在 CHANGELOG 回溯细节。
License
MIT
Available Tools
9 toolsbridge_healthA
Preflight diagnostics: binary resolution, workspace allowlist, state directory writability, concurrency and metrics. Run this first when a task fails for unclear reasons.
Inputs: no named parameters.
bridge_shutdownB
Cancel all in-flight jobs, flush state and exit. Use before restarting the bridge so no Cursor process is left orphaned.
Inputs: graceMs.
bridge_statsA
Counters for job outcomes, tier mix and duration, for capacity planning.
Inputs: no named parameters.
cursor_cancelB
Cancel a running job and kill its entire process tree.
Inputs: jobId (required).
cursor_diffA
Inspect what an execute job changed: changed file list, diffstat, and optionally the raw patch text. Use offset/limit to page through a large patch.
Inputs: jobId (required), limit, offset, includePatch.
cursor_listB
List recent jobs with status, tier and duration.
Inputs: limit, status.
cursor_replyA
Send input to a job. If the task is paused in the A2A input-required state, this RESUMES the SAME task (same job id, thread preserved) — input-required -> working -> completed. Otherwise it spawns a child follow-up job that resumes the Cursor thread. Cancel a running job before replying.
Inputs: jobId (required), prompt (required), tier.
cursor_runA
Dispatch a task to the Cursor sub-agent and return a job id IMMEDIATELY. This tool never blocks: a real code task takes minutes, so poll with cursor_status. tier=consult is read-only Q&A, tier=plan is read-only planning, tier=execute may write files and is always isolated in a git worktree.
Inputs: tier (required), prompt (required), workspace (required), model, +1 more.
cursor_statusB
Poll a job. Pass waitSeconds (max 55) to block briefly until it settles, and since to receive only new events.
Inputs: jobId (required), since, waitSeconds.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 9 tools
Each tool targets a distinct lifecycle step: dispatch, poll, reply/resume, cancel, list, diff inspection, stats, health, and shutdown. The only potentially close pair, cursor_run and cursor_reply, is clearly separated by starting a new job versus resuming or following up on an existing one. No tool appears to duplicate another's purpose.
Names consistently use snake_case with a stable resource prefix: cursor_* for job operations and bridge_* for bridge-level operations. The pattern is predictable and reflects the underlying domain grouping. Minor noun/verb variation (cursor_status, bridge_health) does not undermine consistency.
Nine tools is well-scoped for an asynchronous job bridge, covering dispatch, polling, interaction, cancellation, inspection, diagnostics, and shutdown. Each tool appears to earn its place without obvious filler. The surface is neither thin nor bloated.
The tool set covers the full job lifecycle, including execution, polling, replying/resuming, cancellation, diff inspection, metrics, health checks, and shutdown. A minor gap may exist around explicitly retrieving a finalized job result or artifacts beyond status events and diff output, but agents can likely work around it via cursor_status.
Maintenance
Related MCP Connectors
Control plane for autonomous software labor. Agents claim objectives over MCP with audit trail.
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
Agent-first task marketplace MCP — discover, claim, and deliver paid workspace tasks.
Connect, monitor, and control AI agents — tasks, approvals, schedules, and governance.
Related MCP Servers
- AlicenseNot gradedqualityNot gradedmaintenanceEnables programmatic control of Cursor's cloud-based AI agents for automated code generation and repository management via standardized MCP tools.27 npm6MIT
- AlicenseAqualityBmaintenanceMCP server that lets any agent or MCP host delegate tasks to the Cursor CLI agent for fast, headless execution. Supports task delegation, project discovery, file analysis, and follow-up sessions.314 npm5MIT
- AlicenseAqualityBmaintenanceEnables supervising and orchestrating local coding agents like Muse and AGY through a client-agnostic MCP interface, with isolated Git worktrees, safe execution, and deterministic verification.109 npmMIT
- AlicenseAqualityCmaintenanceEnables AI assistants and other MCP clients to launch and steer Cursor Cloud Agents on repositories or as repo-less research tasks, including model selection, mid-run follow-ups, cancellation, result retrieval, and run listing. Also exposes authentication checks and per-agent or per-run token usage and cost reporting.9MIT