本文主要介绍 Cursor IDE 是如何通过 Model Context Protocol (MCP) 服务来增强其功能的。本文将重点介绍两个核心 MCP 服务的集成:GitHub MCP 服务和 Filesystem MCP 服务。
MCP 服务简介
MCP(Model Context Protocol)是一个允许 IDE 与各种服务进行交互的协议框架。通过 MCP,Cursor 可以无缝地集成各种强大的功能,提升开发体验。

准备工作
- 首先本地要安装node及npx
 

- Cursor版本更新到最新版本
 - 生成一个GitHub用户token
 
- GitHub token获取用户头像->settings->Developer Settings->Personal access tokens -> Tokens -> generate new token
 
配置文件解析
MCP 服务的配置通常存放在 .cursor/mcp.json 文件中。
实际的配置示例windows和mac略有不同:
- windows:
 
{"mcpServers": {"github.com/modelcontextprotocol/servers/tree/main/src/github": {"command": "cmd","args": ["/c","npx","-y","@modelcontextprotocol/server-github"],"env": {"GITHUB_PERSONAL_ACCESS_TOKEN": "your-token-here"}},"filesystem": {"command": "cmd","args": ["/c","npx","-y","@modelcontextprotocol/server-filesystem","workspace-path"]}}
} 
- mac:
 
{"mcpServers": {"github.com/modelcontextprotocol/servers/tree/main/src/github": {"command": "npx","args": ["-y","@modelcontextprotocol/server-github"],"env": {"GITHUB_PERSONAL_ACCESS_TOKEN": "your-token-here"}},"filesystem": {"command": "npx","args": ["-y","@modelcontextprotocol/server-filesystem","workspace-path"]}}
} 
验证是否集成成功,setting->MCP,前边的小点显示为绿色说明安装成功:

GitHub MCP 服务
功能介绍
GitHub MCP 服务允许 Cursor 直接与 GitHub 仓库进行交互,提供以下核心功能:
- 代码仓库访问
 - Issue 追踪
 - Pull Request 管理
 - 代码审查集成
 
配置步骤
- 安装 GitHub MCP 服务:
 
npx -y @modelcontextprotocol/server-github
- 配置 GitHub Personal Access Token
 - 在 mcp.json 中添加相应配置
 - 验证,注意选择agent模式
 

结果:

相关资源
- GitHub MCP 服务官方文档:https://github.com/modelcontextprotocol/servers
 - NPM 包地址:@modelcontextprotocol/server-github - npm
 
Filesystem MCP 服务
功能介绍
Filesystem MCP 服务为 Cursor 提供了强大的文件系统操作能力:
- 文件读写
 - 目录遍历
 - 文件搜索
 - 文件监控
 - 权限管理
 
配置步骤
- 安装 Filesystem MCP 服务:
 
npx -y @modelcontextprotocol/server-filesystem
- 配置工作区路径
 - 在 mcp.json 中添加相应配置
 
验证:

结果:


相关资源
- Filesystem MCP 服务官方文档:https://github.com/modelcontextprotocol/servers
 - NPM 包地址:@modelcontextprotocol/server-filesystem - npm