Skip to main content
Glama

GithubMCP

一个生产级个人开发者助手 MCP 服务器

License: MIT Python: 3.11+ Managed by: uv MCP Compatible Code style: ruff Type checked with: mypy

将 AI 模型(Claude、Cursor 等)无缝连接到你的 GitHub 工作流、CI/CD 流水线、本地工作区上下文和代码分析工具。


概述

GithubMCP 是一个面向开发者的 Model Context Protocol(MCP)服务器。它将 AI 助手直接与你的开发环境连接,使其能够:

  • 检查公共和私有仓库中的 GitHub 仓库、Pull Request、Issue、提交及代码。

  • 直接通过对话管理仓库的隐私与可见性(公开/私有)。

  • 监控 CI/CD 工作流的运行状态,并解析 GitHub Actions 中失败构建的步骤。

  • 在用户定义的允许路径范围内,安全地检查本地文件系统工作区。

  • 分析代码质量、评估复杂度指标、查找 TODO 注释,并检测安全隐患(如硬编码密钥)。

支持 STDIO(Claude Desktop、Cursor)和 SSE(Server-Sent Events,供 Web 客户端使用)两种传输模式。


Related MCP server: GitHub MCP Server

工具套件参考

GithubMCP 提供 13 个专用工具

Category

Tool Name

Description

GitHub

search_repos

搜索用户/组织的公共与私有仓库,支持语言和排序过滤。

GitHub

inspect_pr

获取 PR 详情、变更文件、增删统计和审查评论。

GitHub

inspect_issue

查看 issue 状态、指派对象、关联的 PR 标签和近期评论。

GitHub

search_code

跨仓库搜索代码模式,并支持文件扩展名过滤。

GitHub

recent_commits

获取最近提交历史,附带 diff 统计和提交者信息。

GitHub

update_repo_visibility

将仓库可见性在私有公开之间切换。

CI/CD

check_ci_status

监控 GitHub Actions 状态(成功/失败/进行中)并获取失败步骤的日志。

文件系统

read_file

安全读取本地文件内容,包含 MIME 类型检测和大小校验。

文件系统

list_directory

列出目录树结构,包含文件大小、修改时间和 glob 过滤。

文件系统

search_local_files

异步对文件执行 grep 正则/模式匹配,并返回上下行内容。

文件系统

get_project_context

检测项目技术栈(Node、Python、Rust、Go、Docker)及开发命令。

分析

generate_change_summary

比较 git refs,并将提交归类为 Feature、Fix、Breaking Change 等。

分析

analyze_code_quality

计算代码行数、复杂度估算、TODO 注释,并识别可疑密钥等安全威胁。


快速开始

1. 环境要求

  • Python 3.11+

  • uv(更快的 Python 包管理器)

安装 uv(如果尚未安装):

# Windows (PowerShell)
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

# macOS / Linux
curl -LsSf https://astral.sh/uv/install.sh | sh

2. 克隆与配置

git clone https://github.com/Dhananjayrbiraris/github-mcp.git
cd github-mcp

# Install dependencies and sync virtual environment
uv sync

3. 环境变量配置

.env.example 模板复制为 .env

cp .env.example .env

.env 中填入你的 GitHub Personal Access Token:

# GitHub Personal Access Token (Classic PAT with 'repo', 'workflow', 'read:user' scopes)
GITHUB_TOKEN=ghp_your_github_token_here

# Default GitHub Username (Optional)
GITHUB_USERNAME=your_username

# Sandboxed directories allowed for local filesystem operations
ALLOWED_PATHS=["~/projects", "~/workspace", "."]

# Max file size limit in MB for reading files
MAX_FILE_SIZE_MB=10

# Default Transport mode: "stdio" or "sse"
TRANSPORT=stdio

生成你的 GitHub Token: 前往 GitHub Settings -> Developer Settings -> Personal access tokens (classic) 生成一个具备 repoworkflowread:user 权限范围的 token。


客户端配置指南

A. Claude Desktop

1. 打开 Claude Desktop 配置文件:

  • Windows%APPDATA%\Claude\claude_desktop_config.json

  • macOS~/Library/Application Support/Claude/claude_desktop_config.json

  • Linux~/.config/Claude/claude_desktop_config.json

2. 添加 github-mcp 服务器:

{
  "mcpServers": {
    "github-mcp": {
      "command": "uv",
      "args": [
        "--directory",
        "/absolute/path/to/github-mcp",
        "run",
        "python",
        "-m",
        "github_mcp.main",
        "--transport",
        "stdio"
      ],
      "env": {
        "GITHUB_TOKEN": "ghp_your_personal_access_token_here"
      }
    }
  }
}

(在 Windows 上,请使用反斜杠,如 C:\Users\yourname\path\to\github-mcp,或使用正斜杠。)

3. 重启 Claude Desktop

启动 Claude Desktop — 点击提示框右下角的 Tools 图标,即可查看所有已连接的 GithubMCP 工具。


B. Cursor IDE

在 Cursor 中:

  1. 进入 Cursor Settings -> Features -> MCP

  2. 点击 + Add New MCP Server

  3. 填写以下内容:

    • Name: github-mcp

    • Type: command

    • Command: uv --directory /path/to/github-mcp run python -m github_mcp.main --transport stdio


C. Server-Sent Events(SSE)模式 / Web 客户端

以 HTTP / Server-Sent Events 方式运行 MCP 服务器:

uv run python -m github_mcp.main --transport sse --host 0.0.0.0 --port 8000

SSE 端点地址为:http://localhost:8000/sse


安全与沙箱

  1. 路径沙箱: 本地文件系统工具(read_filelist_directorysearch_local_filesget_project_context)会严格按照 ALLOWED_PATHS 强制进行路径穿越校验。访问范围之外的路径会抛出 SecurityError

  2. 密钥管理: Token 与前缀密钥不会被记录或暴露到日志。

  3. 限流容错: 面对 GitHub API 触发限流时,会自动指数退避重试。


开发与测试

运行完整的测试与质量检查套件:

# Run pytest unit tests
uv run pytest

# Run linter
uv run ruff check .

# Check code formatting
uv run ruff format --check .

# Run strict type checking
uv run mypy src/

仓库结构

github-mcp/
├── .github/workflows/ci.yml # GitHub Actions CI workflow
├── src/github_mcp/
│   ├── __init__.py
│   ├── main.py              # Server entrypoint & MCP tool registrations
│   ├── config.py            # Pydantic Settings model
│   ├── github_tools.py      # GitHub API integrations & visibility controls
│   ├── file_tools.py        # Sandboxed local filesystem operations
│   ├── ci_tools.py          # GitHub Actions CI/CD monitoring
│   ├── analysis_tools.py    # Diff categorization & code quality analyzer
│   └── utils.py             # Path safety, error handling, rate limiting
├── tests/
│   ├── conftest.py          # Pytest fixtures and mocks
│   ├── test_github.py       # GitHub tools unit tests
│   ├── test_files.py        # Filesystem tools unit tests
│   └── test_ci.py           # CI status tools unit tests
├── docs/
│   ├── architecture.md      # System architecture & data flow
│   └── tools_reference.md   # Complete API schemas for all 13 tools
├── pyproject.toml           # Project dependencies & tool configurations
├── .env.example             # Environment variable template
├── CONTRIBUTING.md          # Open-source contribution guidelines
├── SECURITY.md              # Security policy & vulnerability reporting
└── LICENSE                  # MIT License

许可证

本项目基于 MIT License 许可 — 允许个人与商业免费使用。


Install Server
A
license - permissive license
A
quality
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

View all related MCP servers

Related MCP Connectors

  • Connect AI assistants to GitHub - manage repos, issues, PRs, and workflows through natural language.

  • Connect AI assistants to your GitHub-hosted Obsidian vault to seamlessly access, search, and analy…

  • Screens public GitHub repos and PRs to generate risk maps, findings, and merge-readiness signals.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Dhananjayrbiraris/github-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server