Back to MCP directory
publicPublicdnsLocal runtime

github-mcp-server-sse

GitHub MCP服务器是一个提供标准化接口的集成服务,使LLM应用能够通过Model Context Protocol与GitHub API进行交互,支持仓库管理、文件操作和PR处理等功能。

article

README

🚀 GitHub MCP 服务器

GitHub MCP 服务器是基于 Model Context Protocol (MCP) 的集成服务器,为 LLM(大语言模型)应用程序提供了与 GitHub API 通信的标准接口,极大地简化了相关操作。

🚀 快速开始

本服务器为LLM应用程序与GitHub API的交互提供了便利,通过标准接口可轻松实现各类仓库操作。

✨ 主要特性

此服务器提供以下丰富功能:

  • 搜索仓库
  • 创建新仓库
  • 获取文件内容
  • 创建或更新文件
  • 一次推送多个文件
  • 叉仓库
  • 创建 Pull Request
  • 获取 Pull Request 详情
  • 添加对 Pull Request 的评论

📦 安装指南

使用以下命令进行安装:

go get github.com/yamagai/github-mcp-server-sse

💻 使用示例

基础用法

标准输入输出模式 (Stdio)

# 通过环境变量设置GitHub令牌
export GITHUB_TOKEN=your_github_token

# 启动服务器(默认为标准输入输出模式)
github-mcp

# 或者显式指定标准输入输出模式
github-mcp -t stdio

SSE 模式

# 通过环境变量设置GitHub令牌(或在每个请求的Authorization头中指定)
export GITHUB_TOKEN=your_github_token

# 在默认端口(8080)上启动SSE服务器
github-mcp -t sse

# 使用自定义端口启动SSE服务器
github-mcp -t sse -p 3000

在 SSE 模式下,您也可以通过 HTTP 请求的 Authorization 头包含 GitHub 令牌:

curl -H "Authorization: Bearer YOUR_GITHUB_TOKEN" http://localhost:8080/events

高级用法

Docker 容器使用

SSE 模式下运行服务器的 Docker 容器提供。

构建方法
# 构建Docker镜像
docker build -t github-mcp-server-sse .
运行方法
# 设置环境变量 GitHub 令牌并运行容器
docker run -p 8080:8080 -e GITHUB_TOKEN=your_github_token github-mcp-server-sse

# 使用自定义端口运行(通过环境变量指定)
docker run -p 3000:3000 -e GITHUB_TOKEN=your_github_token -e PORT=3000 github-mcp-server-sse

📚 详细文档

工具列表

| 工具名 | 描述 | |--------------|--------------------------| | search_repositories | 搜索 GitHub 仓库 | | create_repository | 创建新的 GitHub 仓库 | | get_file_contents | 从 GitHub 仓库获取文件内容| | create_or_update_file | 在 GitHub 仓库中创建或更新文件| | push_files | 一次推送多个文件到 GitHub 仓库| | fork_repository | 叉取 GitHub 仓库 | | create_pull_request | 创建新的 Pull Request | | get_pull_request | 获取 GitHub 仓库中的 Pull Request 详情| | create_pull_request_review | 在 Pull Request 中添加评论|

开发

# 解决依赖关系
go mod tidy

# 编译
go build

# 测试
go test ./...

命令行选项

| 选项 | 短格式 | 描述 | 默认值 | |------------|--------|--------------------------|-----------| | --transport | -t | 指定运行模式(stdio 或 sse)| stdio | | --port | -p | 设置服务器端口 | 8080 |

⚠️ 重要提示

请确保在使用此服务器时,GitHub 令牌妥善保管,避免泄露。

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