当前位置: 首页 > 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、测试下新建分支
  • 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

  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 配置页)
    此外,需要按照细节权限选择授权的范围,默认都是不允许,此时获取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

可以直接用下面的内容整体复制
在这里插入图片描述
配置完如下
在这里插入图片描述
在这里插入图片描述


http://www.mrgr.cn/news/100498.html

相关文章:

  • 【3DMax脚本MaxScript开发:创建高效模型虚拟体绑定和材质管理系统,从3DMax到Unreal和Unity引擎_系列第一篇】
  • 【RabbitMQ消息队列】详解(一)
  • 从视频中学习:从Humanoid-X、UH-1的自动打字幕,到首个人形VLA Humanoid-VLA(自监督数据增强且整合第一人称视角)
  • WPF常用技巧汇总 - Part 2
  • DeepSeek 多头潜在注意力(Multi-Head Latent Attention, MLA)技术
  • STM32F103_HAL库+寄存器学习笔记21 - CAN接收过滤器:CPU减负神器,提升系统效率的第一道防线
  • Drivestduio 代码笔记与理解
  • 论文检索相关网站
  • 大模型API密钥的环境变量配置(大模型API KEY管理)(将密钥存储在环境变量)(python-dotenv)(密钥管理)环境变量设置环境变量
  • 新能源汽车运动控制器核心芯片选型与优化:MCU、DCDC与CANFD协同设计
  • T检验、F检验及样本容量计算学习总结
  • Simulink与C的联合仿真调试
  • Servlet (简单的servlet的hello world程序)
  • 小白自学python第一天
  • 鸿蒙NEXT开发正则工具类RegexUtil(ArkTs)
  • 数据库3,
  • 深度解析:具身AI机器人领域最全资源指南(含人形机器人,多足机器人,灵巧手等精选资源)
  • AUTOSAR图解==>AUTOSAR_RS_FeatureModelExchangeFormat
  • 基于esp32实现键值对存储读写c程序例程
  • C++如何使用调试器(如GDB、LLDB)进行程序调试保姆级教程(2万字长文)