游标 MCP(模型上下文协议)
Cursor MCP 是 Claude 桌面应用程序和 Cursor 编辑器之间的桥梁,可实现无缝的 AI 自动化和多实例管理。它是更广泛的模型上下文协议 (MCP) 生态系统的一部分,允许 Cursor 通过标准化接口与各种 AI 模型和服务进行交互。
概述
🤖 AI 集成
与 Claude 的桌面应用程序直接集成
能够利用其他与 MCP 兼容的 AI 服务
AI 与编辑之间的实时上下文共享
人工智能驱动的自动化和代码生成
🔌 MCP 协议支持
与AI模型的标准化沟通
可扩展插件系统,用于附加 MCP
上下文感知命令执行
基于令牌的安全身份验证
🖥️ 跨平台窗口管理
无缝管理跨操作系统的 Cursor 编辑器窗口
通过编程聚焦、最小化、恢复和排列窗口
跟踪窗口状态变化和位置
同时处理多个 Cursor 实例
⌨️ 输入自动化
AI 驱动的键盘输入支持:
代码生成和插入
重构操作
上下文感知补全
多光标编辑
智能鼠标自动化包括:
智能选择
上下文菜单操作
人工智能导航
🔄 流程管理
AI 协调的实例管理
智能工作空间组织
自动上下文保存
智能会话恢复
MCP 集成
Claude 桌面集成
使用多个 MCP
自定义 MCP 集成
配置
该工具可以通过环境变量或配置文件进行配置:
Windows:
%LOCALAPPDATA%\cursor-mcp\config\config.json
macOS:
~/Library/Application Support/cursor-mcp/config/config.json
Linux:
~/.config/cursor-mcp/config.json
示例配置:
安装
视窗
macOS
Linux
用法
基本用法
窗口管理
输入自动化
工作原理
桥梁建筑
此工具充当 Cursor 和 MCP 服务器之间的中间件层:
光标集成:
监视 Cursor 的文件系统事件
捕获编辑器状态和上下文
将响应注入编辑器
管理窗口和流程自动化
MCP 协议转换:
将 Cursor 的内部事件转换为 MCP 协议消息
将 MCP 响应转换为与 Cursor 兼容的操作
维护会话状态和上下文
处理身份验证和安全
服务器通信:
连接到 Claude 的桌面应用程序 MCP 服务器
将请求路由到适当的 AI 提供商
管理与多个 MCP 的并发连接
处理回退和错误恢复
示例工作流程
代码完成请求:
// 1. Cursor Event (File Change) // When user types in Cursor: function calculateTotal(items) { // Calculate the total price of items| <-- cursor position // 2. Bridge Translation const event = { type: 'completion_request', context: { file: 'shopping-cart.ts', line: 2, prefix: '// Calculate the total price of items', language: 'typescript', cursor_position: 43 } } // 3. MCP Protocol Message await mcpServer.call('generate_completion', { prompt: event.context, max_tokens: 150, temperature: 0.7 }) // 4. Response Translation // Bridge converts MCP response: const response = `return items.reduce((total, item) => { return total + (item.price * item.quantity); }, 0);` // 5. Cursor Integration // Bridge injects the code at cursor position代码重构:
// 1. Cursor Event (Command) // User selects code and triggers refactor command const oldCode = ` if (user.age >= 18) { if (user.hasLicense) { if (car.isAvailable) { rentCar(user, car); } } } ` // 2. Bridge Translation const event = { type: 'refactor_request', context: { selection: oldCode, command: 'simplify_nesting' } } // 3. MCP Protocol Message await mcpServer.call('refactor_code', { code: event.context.selection, style: 'simplified', maintain_logic: true }) // 4. Response Translation const response = ` const canRentCar = user.age >= 18 && user.hasLicense && car.isAvailable; if (canRentCar) { rentCar(user, car); } ` // 5. Cursor Integration // Bridge replaces selected code多文件上下文:
// 1. Cursor Event (File Dependencies) // When user requests help with a component // 2. Bridge Translation const event = { type: 'context_request', files: { 'UserProfile.tsx': '...', 'types.ts': '...', 'api.ts': '...' }, focus_file: 'UserProfile.tsx' } // 3. MCP Protocol Message await mcpServer.call('analyze_context', { files: event.files, primary_file: event.focus_file, analysis_type: 'component_dependencies' }) // 4. Response Processing // Bridge maintains context across requests
积分方法
文件系统监控:
import { FileSystemWatcher } from 'cursor-mcp/watcher' const watcher = new FileSystemWatcher({ paths: ['/path/to/cursor/workspace'], events: ['change', 'create', 'delete'] }) watcher.on('change', async (event) => { const mcpMessage = await bridge.translateEvent(event) await mcpServer.send(mcpMessage) })窗口集成:
import { CursorWindow } from 'cursor-mcp/window' const window = new CursorWindow() // Inject AI responses await window.injectCode({ position: cursorPosition, code: mcpResponse.code, animate: true // Smooth typing animation }) // Handle user interactions window.onCommand('refactor', async (selection) => { const mcpMessage = await bridge.createRefactorRequest(selection) const response = await mcpServer.send(mcpMessage) await window.applyRefactoring(response) })上下文管理:
import { ContextManager } from 'cursor-mcp/context' const context = new ContextManager() // Track file dependencies await context.addFile('component.tsx') await context.trackDependencies() // Maintain conversation history context.addMessage({ role: 'user', content: 'Refactor this component' }) // Send to MCP server const response = await mcpServer.send({ type: 'refactor', context: context.getFullContext() })
安全
基于令牌的安全 AI 服务身份验证
加密通信渠道
沙盒执行环境
细粒度的权限控制
要求
视窗
Windows 10 或更高版本
Node.js 18 或更高版本
安装的管理员权限
macOS
macOS 10.15 (Catalina) 或更高版本
Node.js 18 或更高版本
Xcode 命令行工具
终端的辅助功能权限
Linux
X11显示服务器
Node.js 18 或更高版本
xdotool
libxtst-dev
libpng++-dev
构建必需
发展
设置
运行测试
贡献
欢迎大家贡献!详情请参阅我们的贡献指南。
执照
该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅LICENSE文件。
支持
致谢
Cursor Editor - AI-first 代码编辑器
Claude AI - 高级人工智能助手
@nut-tree/nut-js - 跨平台自动化
active-win - 窗口检测
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
充当 Claude 桌面应用程序和 Cursor 编辑器之间的桥梁,通过标准化通信和基于安全令牌的身份验证实现跨平台的无缝 AI 自动化和多实例管理。
Related MCP Servers
- -securityAlicense-qualityFacilitates integration with the Cursor code editor by enabling real-time code indexing, analysis, and bi-directional communication with Claude, supporting concurrent sessions and automatic reconnection.Last updated -139MIT License
- AsecurityAlicenseAqualityConnects Claude to Portkey's API for managing AI configurations, workspaces, analytics, and user access, providing comprehensive control over API usage and settings.Last updated -MIT License
- AsecurityAlicenseAqualityAn easy-to-use bridge that lets AI assistants like Claude and Cursor IDE directly query and explore Microsoft SQL Server databases. No coding experience required!Last updated -338762GPL 3.0
- -securityAlicense-qualityA server that allows AI tools like Claude and Cursor to automate and control Photoshop through natural language commands, enabling tasks like editing PSDs, toggling layers, and generating marketing creatives.Last updated -9MIT License