cursor-mcp-server
cursor-mcp-server
一个 MCP 服务器,将所有代码编写工作委托给 Cursor 的 Composer 2(或 Grok 4.5)代理。它的设计目标是让 PM/编排器模型——在本项目为之构建的配置中,也就是 Claude——永远不直接编写代码。它会读取上下文、将工作拆分为范围明确的任务,并调用 Cursor 的 agent SDK 来真正生成或编辑文件。
为什么
在编排器工作流中,Claude 的上下文窗口才是最稀缺的资源。Claude 每直接写下一行代码,它就必须在自己的 token 预算中保存这行代码、重新读取它、并为它付费——而这个预算随功能规模增长,与任务描述的复杂程度无关。将代码生成委托给 Cursor,可以把编排器的成本与输出规模解耦:一次 cursor_write_code 调用,无论 Cursor 最终产出 20 行还是 400 行,成本都大致相同。
Cursor 的按 token 定价也比前沿推理模型便宜得多,因此把大批量代码生成迁移过去是一笔复利式收益,而不仅仅是上下文窗口上的小技巧。
Related MCP server: local-llm-mcp
架构
基于 @modelcontextprotocol/sdk 的一个 MCP 服务器,对外暴露两个工具,二者都由 @cursor/sdk 的 Agent.prompt() 驱动:
cursor_write_code—— 委托创建新文件/新功能cursor_edit_code—— 委托编辑现有文件
两个工具都接受以下字段:
字段 | 必需 | 用途 |
| 是 | 清楚地描述要构建/修改的内容 |
| 否 | 项目根的绝对路径(默认为服务器的 cwd) |
| 仅写入 | Composer 应读取以获取上下文的现有文件 |
| 仅编辑 | 正在编辑的文件的路径 |
| 否 | 需要遵守的架构决策、接口或约束 |
| 否 |
|
| 否 |
|
服务器会根据这些字段构建出一条提示词,并将其交给 Cursor 的代理运行(local 模式在你机器上的 workingDirectory 中执行;cloud 模式在 Cursor 的沙箱虚拟机上运行)。
设置
npm install
cp .env.example .env
# edit .env: set CURSOR_API_KEY (Cursor dashboard -> Integrations -> API Keys)
npm run build环境变量
变量 | 取值 | 默认值 |
| 你的 Cursor API 密钥 | 必需 |
|
|
|
在 Claude Code / 任意 MCP 客户端中注册
将其添加到你的 MCP 客户端配置中(例如 .mcp.json 或 claude mcp add):
{
"mcpServers": {
"cursor-coder": {
"command": "node",
"args": ["/absolute/path/to/cursor-mcp-server/dist/index.js"],
"env": { "CURSOR_API_KEY": "your_cursor_api_key_here" }
}
}
}模型选择
composer(默认)——Composer 2。对于定义明确、机械性的任务,它快速且可靠:CRUD、脚手架、小改动、遵循已有清晰模式。grok——Grok 4.5。能力更强,价格更高。请留给复杂推理、棘手的重构、对架构敏感的改动,或当 Composer 返回错误/混乱结果时使用。最困难的情况下使用effort: "high"。
编排器契约
该服务器旨在搭配一个系统提示词 / CLAUDE.md 使用,它会将代码生成硬性限制为必须经由它完成:
You are the architect and project manager. Cursor Composer 2 is your
code-writing sub-agent.
- NEVER write code yourself. No code blocks, no file edits.
- For ALL code generation -> call cursor_write_code.
- For ALL code edits -> call cursor_edit_code.
- You MAY read files to understand context before delegating.
- You MAY review Composer's output and ask it to revise via another
tool call.编排器的职责保持不变:将任务拆分为有明确范围的子任务、在 Composer 编写之前定义接口/契约、审查输出以保证正确性,并决定接下来要构建什么。实际的代码生成完全在 Cursor 的代理循环中运行。
始终独立复核返回的结果。 不要轻信完成消息的表面说法——打开文件、运行测试、检查 diff。子代理自称的“done”并不是证据。
脚本
命令 | 用途 |
| 使用 |
| 将 TypeScript 编译到 |
| 运行编译后的服务器 |
许可证
MIT —— 参见 LICENSE。
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityAmaintenanceEnables AI assistants to delegate specific tasks to specialized sub-agents (e.g., test-writer, code-reviewer). Supports both Cursor and Claude Code with custom agent definitions.178294MIT
- AlicenseBqualityCmaintenanceEnables coding agents like Claude Code and Codex to offload boilerplate generation, summarization, and other bounded text tasks to local or cheap cloud LLMs, keeping the frontier agent in charge of judgment and code edits.92MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI to delegate boilerplate, drafts, tests, and refactors to free LLM providers, saving tokens and running tasks in parallel.204MIT
- AlicenseAqualityBmaintenanceLets your primary coding agent delegate grunt work to a cheaper model via OpenCode, enabling cost-effective task distribution.5MIT
Related MCP Connectors
Coding agents from Claude Code, Cursor and Codex claim jobs and lock files on one shared board.
The team layer for AI coding agents: shared contracts, collision alerts, E2EE sessions.
Coding agents build full-stack apps in persistent workspaces and share them by link.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Villarley/cursor-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server