当前位置: 首页 > news >正文

在 Cursor 中 配置 GitHub MCP Server

文章目录

  • 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、测试下新建分支

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

  1. Make sure you have the latest version of Cursor installed (0.46 or later)
  2. 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

  1. Go to GitHub and navigate to SettingsDeveloper SettingsPersonal Access TokensTokens (classic)
  2. Click Generate New Token (classic)
  3. Give your token a descriptive name (e.g., “Cursor MCP Integration”)
  4. Select the necessary scopes (recommended: repo, workflow)
  5. Click Generate Token and copy the token immediately (you won’t be able to see it again)

Step 3: Open Cursor MCP Settings

  1. Open Cursor
  2. Use the keyboard shortcut Cmd + Shift + J (Mac) or open Cursor settings through the menu
  3. 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)

  1. Visit Smithery
  2. Locate the GitHub MCP tool
  3. Paste your GitHub Personal Access Token
  4. 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

  1. Go back to Cursor Settings → MCP
  2. Click Add New MCP Server
  3. Enter a name (e.g., “GitHub MCP”)
  4. Set Type to Command
  5. Paste the command copied from Smithery or use your custom command
  6. Click Add
  7. Click Refresh - the GitHub MCP tool should appear in the list of tools

Step 6: Test the GitHub MCP Integration

  1. Open Cursor Chat
  2. 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 配置页)

  • 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、测试下新建分支

还提示我确认下用户名一类的
在这里插入图片描述

相关文章:

  • AI 应用同质化:一场看不见的资源 “吞噬战”
  • 软考:软件设计师考试数据结构知识点详解
  • HTML5 新特性详解:语义化标签、表单与音视频嵌入
  • 底层源码和具体测试解析HotSpot JVM的notify唤醒有序性(5000字详解)
  • JimuBI 积木报表 v1.9.5发布,大屏和仪表盘,免费数据可视化
  • 当AI浏览器和AI搜索替代掉传统搜索份额时,老牌的搜索引擎市场何去何从。
  • ubuntu 日志文件清空方式的解读
  • Ubuntu22.04/24.04 P104-100 安装驱动和 CUDA Toolkit
  • FFmpeg之三 录制音频并保存, API编解码从理论到实战
  • C++初阶-STL简介
  • Unity 和 Unreal Engine(UE) 两大主流游戏引擎的核心使用方法
  • 司法大模型构建指南
  • 模方ModelFun工程操作教程
  • Deep Dark Sea 局域網文件共享即時匿名聊天去數據庫部署
  • 1、Linux操作系统下,ubuntu22.04版本切换中英文界面
  • mAh 与 Wh:电量单位的深度解析
  • 学习海康VisionMaster之路径提取
  • self-attention计算过程
  • JavaEE-多线程实战02
  • 计算机图形学(一):基础
  • 现场丨在胡适施蛰存等手札与文献间,再读百年光华
  • 微软宣布全球裁员约3%:涉及约6000人,侧重经理层
  • 经济日报评外卖平台被约谈:行业竞争不能背离服务本质
  • 中国科学院院士、我国航天液体火箭技术专家朱森元逝世
  • 小耳朵等来了春天:公益义诊筛查专家走进安徽安庆
  • 联合国第二届运动会闭幕,刘国梁受邀成为“联合国运动会大使”