在 Cursor 中 配置 GitHub MCP Server

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

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

<think>好的,我现在需要回答用户关于如何配置MCP(Modular Configuration Provider)服务器的问题。首先,我需要确认用户提到的MCP Server具体指什么。因为在Java生态中,MCP可能有不同的上下文,比如Minecraft Coder Pack,或者是某个特定框架中的组件,比如Istio中的MCP(Management Control Plane)。不过根据常见的Java相关配置,更可能是指与微服务配置相关的,比如Spring Cloud Config Server,或者是其他自定义的配置服务器。 假设用户指的是配置一个配置服务器,比如Spring Cloud Config Server,那么我需要解释如何配置这样的服务器。首先,我需要确定用户是否使用Spring Cloud,因为配置步骤会依赖于这个框架。如果用户确实是指Spring Cloud Config Server,那么步骤大致包括创建项目、添加依赖、配置application.properties或application.yml、启用Config Server注解,以及设置Git仓库作为配置存储。 接下来,我需要确保给出的代码示例正确,包括pom.xml中的依赖、主类上的@EnableConfigServer注解,以及配置文件中的设置。同时,需要说明如何访问配置,比如通过HTTP端点获取配置信息。 此外,用户的问题中提到“cursor”,可能是指配置过程中的某个光标位置或者配置项,但不太确定。可能需要进一步澄清,但根据现有信息,先按照常见的配置服务器来解答。 最后,按照用户的要求,生成相关问题,这些问题应该围绕配置服务器、Spring Cloud Config、安全性、动态刷新等主题。确保问题与回答内容相关,并且符合用户要求的格式。</think><< 要配置MCP(Modular Configuration Provider)服务器(假设基于Spring Cloud Config Server),以下是关键步骤和代码示例: ### 1. 创建Spring Boot项目 使用Spring Initializr创建项目,添加`Config Server`依赖。 ### 2. 添加依赖 在`pom.xml`中配置依赖: ```xml <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-config-server</artifactId> </dependency> ``` ### 3. 启用Config Server 在主类添加`@EnableConfigServer`注解: ```java @SpringBootApplication @EnableConfigServer public class ConfigServerApplication { public static void main(String[] args) { SpringApplication.run(ConfigServerApplication.class, args); } } ``` ### 4. 配置文件(application.yml) 配置Git仓库作为配置源: ```yaml server: port: 8888 spring: cloud: config: server: git: uri: https://github.com/your-repo/config-repo search-paths: '{application}' ``` ### 5. 访问配置 客户端通过`http://localhost:8888/{application}/{profile}`访问配置。 ### 问题原因 MCP服务器的核心作用是将配置集中管理,通过远程存储(如Git)实现动态配置分发,避免硬编码配置
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值