文章目录
- 1、简单回顾 sequentialthinking 的安装
- 2、提出问题:如何在 cursor 配置 github mcp 呢
- 3、结果如下
- How to Configure GitHub MCP in Cursor
- Prerequisites
- Step 1: Update Cursor (if needed)
- Step 2: Generate a GitHub Personal Access Token
- Step 3: Open Cursor MCP Settings
- Step 4: Add GitHub MCP Server
- Option 1: Using Smithery (Recommended)
- Option 2: Manual Configuration
- Step 5: Add the MCP Server in Cursor
- Step 6: Test the GitHub MCP Integration
- Troubleshooting
- 4、操作
- 5、配置成功
- 6、测试下新建分支
- 7、低版本 cursor 只支持 json格式配置MCP
1、简单回顾 sequentialthinking 的安装
我们已经在上一篇文章中安装了 sequentialthinking MCP
这个 MCP 是一个可以自己思考并且自主调度其它 MCP Tool
2、提出问题:如何在 cursor 配置 github mcp 呢
在 sequentialthinking MCP server 状态正常的前提下
在 agent 模式下提出问题:如何在 cursor 配置 github mcp 呢
可以看到,自动调用了 MCP tool sequentialthinking,思考了 5 步
3、结果如下
How to Configure GitHub MCP in Cursor
GitHub MCP (Model Context Protocol) integration in Cursor allows you to interact with
GitHub directly from your IDE, enabling features like creating PRs,
branches, finding code, and more. Here’s a step-by-step guide to set it up:
Prerequisites
- Make sure you have the latest version of Cursor installed (0.46 or later)
- A GitHub account with repositories you want to connect to
Step 1: Update Cursor (if needed)
Some users report not seeing the MCP section in older versions of Cursor. If you don’t see it, update to the latest version.
Step 2: Generate a GitHub Personal Access Token
- Go to GitHub and navigate to Settings → Developer Settings → Personal Access Tokens → Tokens (classic)
- Click Generate New Token (classic)
- Give your token a descriptive name (e.g., “Cursor MCP Integration”)
- Select the necessary scopes (recommended:
repo
,workflow
) - Click Generate Token and copy the token immediately (you won’t be able to see it again)
Step 3: Open Cursor MCP Settings
- Open Cursor
- Use the keyboard shortcut Cmd + Shift + J (Mac) or open Cursor settings through the menu
- Look for the MCP tab in the settings sidebar
Note: Don’t use the VS Code settings shortcut (Cmd + ,), as it won’t show the MCP section.
Step 4: Add GitHub MCP Server
There are two main ways to configure GitHub MCP:
Option 1: Using Smithery (Recommended)
- Visit Smithery
- Locate the GitHub MCP tool
- Paste your GitHub Personal Access Token
- Click Generate Command and copy the command provided
Option 2: Manual Configuration
Create a .cursor/mcp.json
file in your project directory (for project-specific configuration) or ~/.cursor/mcp.json
in your home directory (for global configuration) with the following content:
{"mcpServers": {"github": {"command": "npx","args": ["-y", "mcp-server-github"],"env": {"GITHUB_TOKEN": "your-github-token-here"}}}
}
Replace your-github-token-here
with your actual GitHub token.
Step 5: Add the MCP Server in Cursor
- Go back to Cursor Settings → MCP
- Click Add New MCP Server
- Enter a name (e.g., “GitHub MCP”)
- Set Type to Command
- Paste the command copied from Smithery or use your custom command
- Click Add
- Click Refresh - the GitHub MCP tool should appear in the list of tools
Step 6: Test the GitHub MCP Integration
- Open Cursor Chat
- Ask the AI assistant to perform a GitHub-related task, such as:
- “Create a new branch called feature/test-mcp”
- “List my recent commits”
- “Check the status of my current repository”
Troubleshooting
- MCP section not visible: Update Cursor to the latest version
- “Client closed” error: Try restarting Cursor or check your GitHub token
- No tools found: Make sure your GitHub token has the correct permissions
- Connection issues: Check your internet connection and GitHub status
By following these steps, you should be able to successfully configure GitHub MCP in Cursor and start leveraging its powerful GitHub integration features to streamline your development workflow.
4、操作
Step4 中我们选择 Option1
需要注意的是,
-
token 获取方法:Settings/Developer settings/Personal access tokens (直接跳转 token 配置页)
此外,需要按照细节权限选择授权的范围,默认都是不允许,此时获取token 是没有意义的
-
Github 最火爆的 MCP server (直接跳转 github MCP 页面)
-
首次进来,把 token 粘贴进去,点击 Connect
-
选择 Cursor,Copy 获取得到
npx -y @smithery/cli@latest install @smithery-ai/github --client cursor --config '"{\"githubPersonalAccessToken\":\"aaaaaaaaaa\"}"' --key xxxxxxxx-f937-4a71-b723-ccxxxxxxxxxx
- 去Cursor 配置 github MCP Server
有一定概率网络不通, 解决网络问题 里有提到过如何处理
把下面 @smithery/cli@latest 替换为 github MCP 开源项目 说明中的服务器地址
npx -y @smithery/cli@latest install @smithery-ai/github --client cursor --config '"{\"githubPersonalAccessToken\":\"github_pat_aaaaaaaaaa\"}"' --key xxxxxxxx-f937-4a71-b723-ccxxxxxxxxxx
变为
npx -y @modelcontextprotocol/server-github install @smithery-ai/github --client cursor --config '"{\"githubPersonalAccessToken\":\"github_pat_aaaaaaaaaa\"}"' --key xxxxxxxx-f937-4a71-b723-ccxxxxxxxxxx
- Cursor 选择 command 类型
5、配置成功
npx -y @modelcontextprotocol/server-github install @smithery-ai/github --client cursor --config '"{\"githubPersonalAccessToken\":\"github_pat_aaaaaaaaaa\"}"' --key xxxxxxxx-f937-4a71-b723-ccxxxxxxxxxx
6、测试下新建分支
还提示我确认下用户名一类的
7、低版本 cursor 只支持 json格式配置MCP
可以直接用下面的内容整体复制
配置完如下