Back to MCP directory
publicPublicdnsLocal runtime

GitHub

一个基于TypeScript的GitHub MCP服务器项目,允许兼容MCP协议的LLM(如Claude)通过该服务器与GitHub API交互。

article

README

🚀 GitHub MCP(模型上下文协议)服务器

这是一个GitHub MCP服务器,允许与MCP兼容的LLLM(如Claude)通过此MCP服务器与GitHub API进行交互,为开发者提供了便捷的操作途径。

🚀 快速开始

需求

  • TypeScript(编程语言)
  • Octokit(用于向GitHub发送API请求)
  • 模型上下文协议SDK

在本地设置项目

  1. 克隆仓库。
  2. 运行 npm install
  3. 根据 .env.example 文件创建一个 .env 文件。
  4. 为了将TypeScript文件编译为JavaScript,运行 npx tsc
  5. 最终运行项目时,运行 node build/index.js

测试方法

你有2种方式可以测试你的MCP服务器:

  • MCP检查器
  • Claude Desktop

使用MCP检查器测试

  1. 在终端中运行 npx @modelcontextprotocol/inspector node build/index.js
  2. 打开 http://localhost:5173。
  3. 现在你可以看到MCP检查器并进行测试。

使用Claude Desktop测试

  1. 这里下载并安装Claude Desktop。
  2. 转到 File > Settings... > Developer > Edit Config(文件 > 设置... > 开发者 > 编辑配置)。
  3. 它会打开 claude_desktop_config.json 文件的位置。
  4. 在代码编辑器中打开该文件,并添加以下内容:
{
  "mcpServers": {
    "gh": {
      "command": "node",
      "args": ["绝对\\路径\\到\\你的\\index.js\\文件"],
      "env": {
        "GITHUB_TOKEN": "你的GitHub个人访问令牌"
      }
    }
  }
}
  1. 退出并重新打开Claude Desktop。

✨ 主要特性

MCP主要支持两个功能:

  • 工具(4个)
    • create-issue:在GitHub仓库中创建新问题。
    • get-repo-info:获取特定GitHub仓库的信息。
    • list-issues:列出GitHub仓库中的问题。
    • search-repos:搜索GitHub仓库。
  • 提示(5个)
    • create-issue-description:为GitHub问题生成描述。
    • create-pull-request-description:为GitHub拉取请求生成描述。
    • search-repos-prompt:为搜索GitHub仓库生成查询。
    • create-issue-prompt:为创建GitHub问题生成参数。
    • enhance-github-response:格式化并增强原始GitHub API响应数据。

你可以编写自己的提示,或从“选择集成”选项的MCP下拉菜单中选择合适的提示进行测试。

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