SC

sailay1996/cursor-agent-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

21 stars 7 forks 质量 59 趋势 0

光标代理MCP:在Claude代码内进行成本效益高的仓库分析和编辑。

概览

简约、加固的模型上下文协议(MCP)服务器,包裹光标代理CLI并开放多种友好Claude工具,用于聊天、仓库分析、代码搜索、规划等。 核心实现:cursor-agent-mcp/server.js 测试约束:cursor-agent-mcp/test_client.mjs 包清单:cursor-agent-mcp/package.json 该MCP的目的是将主机(如Claude代码)的繁重“思考”和仓库感知任务卸载到光标代理CLI中。通过让CLI以聚焦的提示指令处理分析/规划/搜索,你可以: - 只针对所需的文件/路径进行范围工作,而非对整个工作区进行流式传输。- 通过环境(或每次调用)选择成本效益高的模型,并保持主机上下文较小。- 通过output_format(“文本” |“markdown” |“json”)和定制提示来控制响应的冗长程度。- 使用专门工具(分析、搜索、规划、编辑),以产生有针对性的输出,而非泛泛的聊天。

概述(AI 翻译)

简约、加固的模型上下文协议(MCP)服务器,包裹cursor-agent的CLI并提供多种Claude友好工具,用于聊天、仓库分析、代码搜索、规划等。

核心实现:cursor-agent-mcp/server.js 测试束:cursor-agent-mcp/test_client.mjs 包清单:cursor-agent-mcp/package.json

目的:减少Claude代码中的代币使用和成本

该MCP旨在将主机(如Claude代码)的繁重“思考”和仓库感知任务卸载到cursor-agent CLI。通过让CLI以聚焦、基于提示的指令处理分析/规划/搜索,你可以:

  • 范围只处理所需的文件/路径,而不是对整个工作区进行流式处理。
  • 通过环境(或每次通话)选择成本效益高的模型,并保持主机上下文较小。
  • 通过output_format(“文本” |“markdown” |“json”)和定制提示来实现控制响应的冗长性。
  • 使用专门的工具(analyze、search、plan、edit),生成有针对性的输出,而非通用聊天。

成本控制技巧

  • 偏好精确的示波器:
  • 使用 include/exclude 球块与 cursor_agent_search_repo 并精选 paths 用于 cursor_agent_analyze_files。

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

Cursor Agent MCP Server

Minimal, hardened Model Context Protocol (MCP) server that wraps the cursor-agent CLI and exposes multiple, Claude‑friendly tools for chat, repository analysis, code search, planning, and more.

Core implementation: cursor-agent-mcp/server.js Test harness: cursor-agent-mcp/test_client.mjs Package manifest: cursor-agent-mcp/package.json

Purpose: reduce token usage and cost in Claude Code

This MCP exists to offload heavy “thinking” and repo‑aware tasks from the host (e.g., Claude Code) to the cursor-agent CLI. By letting the CLI handle analysis/planning/search with focused, prompt‑based instructions, you can:

  • Scope work to only the needed files/paths instead of streaming the entire workspace.
  • Choose a cost‑effective model via environment (or per call) and keep the host’s context small.
  • Control response verbosity through output_format (“text” | “markdown” | “json”) and tailored prompts.
  • Use specialized tools (analyze, search, plan, edit) that produce targeted outputs rather than general chat.

Cost‑control tips

  • Prefer precise scopes:
    • Use include/exclude globs with cursor_agent_search_repo and curated paths for cursor_agent_analyze_files.
  • Pick output formats intentionally:
    • Use "text" or "markdown" for concise answers. Reserve "json" only when you truly need structured output (it’s usually larger).
  • Select a model that matches the task:
    • Set CURSOR_AGENT_MODEL to a cost‑effective default; override per tool call only when necessary.
  • Avoid unnecessary echo/debug:
    • CURSOR_AGENT_ECHO_PROMPT=1 is helpful during setup, but disables it later to save tokens in host logs.
    • Keep DEBUG_CURSOR_MCP off in normal use; it writes diagnostics to stderr (not counted in host tokens, but noisy).
  • Control runtime instead of idle‑kill:
    • Keep CURSOR_AGENT_IDLE_EXIT_MS="0" so valid runs aren’t cut mid‑generation. Bound cost/time with CURSOR_AGENT_TIMEOUT_MS and focused prompts.
  • Use cursor_agent_raw thoughtfully:
    • It’s powerful and can stream detailed sessions; for cheapest usage, prefer the focused tools with concise prompts and "text" output.

Features

  • Multi‑tool surface modeled after “verb-centric” CLIs
  • Works well in Claude Code and other MCP hosts
  • Safe process spawn (no shell), robust timeout handling
  • Optional prompt echoing for easy debugging inside hosts
  • Configurable defaults via environment variables (model, force, timeouts, executable path)
  • Backward‑compatible legacy tool for single‑shot chat

Requirements

  • Node.js 18+ (tested up to Node 22)
  • A working cursor-agent CLI in your PATH or at an explicit location
  • Provider credentials configured for your chosen model (e.g., via the CLI’s own mechanism)

Installation

  1. Clone or download this repository.

  2. Install dependencies for the MCP server:

cd ./cursor-agent-mcp
npm ci        # or: npm install
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "cursor-agent": { "command": "node", "args": ["/abs/path/to/cursor-agent-mcp/server.js"], "env": { "CURSOR_AGENT_ECHO_PROMPT": "1", "CURSOR_AGENT_FORCE": "true", "CURSOR_AGENT_PATH": "/home/you/.local/bin/cursor-agent", "CURSOR_AGENT_MODEL": "gpt-5", "CURSOR_AGENT_IDLE_EXIT_MS": "0", "CURSOR_AGENT_TIMEOUT_MS": "60000" } } } }