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

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

http://www.xdnf.cn/news/171361.html

相关文章:

  • 基于ArcGIS的洪水灾害普查、风险评估及淹没制图技术研究​
  • docker(3) -- 图形界面
  • ReACT Agent 实战
  • 面试:结构体默认是对齐的嘛?如何禁止对齐?
  • 遥控器信号传输与信号灯指示要点!
  • 解决新搭建的centos虚拟器,yum下载不了的问题
  • 【音视频】SDL窗口显示
  • DIFY教程第一集:安装Dify配置环境
  • 广度优先搜索(BFS)算法详解
  • 23种设计模式-行为型模式之命令模式(Java版本)
  • 鸿蒙系统应用开发全栈指南
  • HarmonyOS Next~鸿蒙系统流畅性技术解析:预加载与原生架构的协同进化
  • 神经编译革命:如何用脑机接口直接编程量子计算机?
  • 用Function Calling让GPT查询数据库(含示例)
  • 【Git】初始Git及入门命令行
  • 03.使用spring-ai玩转MCP
  • IdeaVim 配置与使用指南
  • 【Part 2安卓原生360°VR播放器开发实战】第二节|基于等距圆柱投影方式实现全景视频渲染
  • 位置差在坐标系间的相互转换
  • C++类和对象(上)
  • Spark SQL开发实战:从IDEA环境搭建到UDF/UDAF自定义函数实现
  • 《TVM模式匹配实战:从DFPatternNode到DFPattern的高级用法》
  • OceanBase数据库-学习笔记2-C#/C++程序如何访问
  • C++如何使用调试器(如GDB、LLDB)进行程序调试保姆级教程(2万字长文)
  • 使用 Autofac 实现依赖注入
  • 嵌入式软件--stm32 DAY 4 中断系统
  • Linux日志处理命令多管道实战应用
  • Python爬虫实战:获取网yi云音乐飙升榜的歌曲数据并作分析,为歌单推荐做参考
  • Spark SQL核心概念与编程实战:从DataFrame到DataSet的结构化数据处理
  • 《一键式江湖:Docker Compose中间件部署108式》开篇:告别“配置地狱”,从此笑傲云原生武林!》