Back to MCP directory
publicPublicdnsLocal runtime

cursor-mcp-guide

MCP(模型上下文协议)是一种标准化协议,使AI代理能无缝与各种工具和服务通信,GitHub集成提供仓库管理、代码操作、问题管理和协作功能。

article

README

🚀 了解 MCP(模型上下文协议)与 GitHub 集成

模型上下文协议 (MCP) 是一种革命性的标准化协议,它让 AI 代理能够与各类工具和服务实现无缝通信。简单来说,它就如同一个通用翻译器,解决了 AI 代理与多工具集成的难题。

🚀 快速开始

在深入了解 MCP 与 GitHub 集成之前,我们先来整体认识一下 MCP 的作用和优势。

✨ 主要特性

什么是 MCP?

模型上下文协议 (MCP) 是一种革命性的标准化协议,使 AI 代理能够与各种工具和服务无缝通信。想象一下,它就像一个通用翻译器:

  • 无 MCP:每个工具都有自己的语言,使得 AI 代理难以集成到多个工具中。
  • 有 MCP:所有工具都使用同一种语言,实现轻松集成和通信。

实际案例

假设你有十位专家顾问,每位都说不同的语言:

  • 无 MCP:你需要十种不同的翻译器。
  • 有 MCP:所有人说共同的语言,使合作变得轻而易举。

这种标准化使 AI 代理能够:

  • 连接数据库
  • 与 GitHub 交互
  • 访问云服务
  • 管理文件和文档
  • 以及更多!

GitHub MCP 功能

GitHub MCP 集成提供了强大的与 GitHub 仓库交互的功能:

仓库管理

  • 创建新仓库
  • 叉取现有仓库
  • 克隆仓库
  • 管理分支
  • 创建和合并拉取请求

代码操作

  • 搜索代码
  • 创建和编辑文件
  • 提交更改
  • 审查拉取请求
  • 添加评论和审查

问题管理

  • 创建和更新问题
  • 添加问题评论
  • 搜索问题
  • 应用标签和指定人
  • 跟踪里程碑

协作功能

  • 管理项目面板
  • 处理讨论
  • 审查评论
  • 管理仓库设置
  • 控制访问权限

📦 安装指南

先决条件:Node.js 设置

  1. 访问 Node.js 网站
  2. 下载相应版本:
    • 对于 M1/M2 Mac:macOS ARM64
    • 对于 Intel Mac:macOS x64
  3. 运行安装程序并按照提示操作

安装 GitHub MCP

方法 1:使用 Smithery CLI(推荐)

npx -y @smithery/cli@latest install @smithery-ai/github \
  --client cursor \
  --config '{"githubPersonalAccessToken":"your_token_here"}'

方法 2:手动配置

  1. 打开 ~/.cursor/mcp.json
  2. 添加以下配置:
{
  "mcp_servers": {
    "github": {
      "command": "npx @smithery/github-mcp --token your_github_token"
    }
  }
}

💻 使用示例

基础用法

安装完成后,你可以使用 GitHub MCP 来:

  1. 创建和管理仓库
  2. 处理问题和拉取请求
  3. 搜索代码
  4. 管理文件和分支
  5. 与团队成员协作

在 Smithery 上查找 MCP 服务器

  1. 访问 Smithery
  2. 浏览可用的 MCP 服务器:
    • 按类别过滤
    • 按流行度排序
    • 搜索名称或功能
  3. 选择“GitHub MCP”
  4. 遵循安装说明

添加到 Cursor

方法 1:命令行安装

# 使用 Smithery CLI
npx @smithery/cli install @smithery-ai/github

方法 2:手动配置

  1. 打开 Cursor 设置:
    • 使用 ⌘ + Shift + P(macOS)或 Ctrl + Shift + P(Windows)
    • 输入“Cursor 设置”
    • 选择“MCP”
  2. 添加 MCP 服务器:
    • 点击“添加新的全局 MCP 服务器”
    • 使用提供的 JSON 结构进行配置

方法 3:直接 JSON 配置

  1. 转到 ~/.cursor/mcp.json
  2. 手动添加服务器配置:
{
  "mcp_servers": {
    "github": {
      "command": "npx @smithery/github-mcp --token your_github_token"
    }
  }
}
help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client