Skip to main content
Glama

GitHub MCP 服务器

用于安全 GitHub 开发工作流的本地 OpenCode MCP 服务器:拉取 main,创建功能分支,推送分支,并开启待评审的拉取请求。

环境

在 shell 中设置这些变量。请勿提交真实的密钥。

export GH_TOKEN="your_github_token_here"
export GITHUB_MCP_ALLOWED_ROOTS="/Users/matiasbinagora/Projects"
export GITHUB_MCP_DEFAULT_BASE_BRANCH="main"
export GITHUB_MCP_DEFAULT_REMOTE="origin"
export GITHUB_MCP_REQUIRE_CLEAN_WORKTREE="true"

建议设置 GH_TOKEN。如果未设置,当 gh 已在本地完成身份验证时,服务器仍可正常工作。

Related MCP server: GitHub MCP Server

构建

npm install
npm run build

冒烟测试

此操作会创建一个临时的本地裸仓库,拉取 main,创建一个测试分支,提交一个文件,推送该分支,并验证远程分支是否存在。

npm run smoke

GitHub 集成测试

此操作会在配置的测试仓库中创建一个真实的分支和待评审的 PR。

export GITHUB_MCP_SMOKE_REPO_PATH="/Users/matiasbinagora/Projects/binagora"
npm run smoke:github

OpenCode 配置

将其添加到 ~/.config/opencode/opencode.json 的全局 OpenCode 配置中。

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "github": {
      "type": "local",
      "command": ["node", "/Users/matiasbinagora/Projects/github-mcp/dist/index.js"],
      "enabled": true,
      "environment": {
        "GH_TOKEN": "{env:GH_TOKEN}",
        "GITHUB_MCP_ALLOWED_ROOTS": "/Users/matiasbinagora/Projects",
        "GITHUB_MCP_DEFAULT_BASE_BRANCH": "main",
        "GITHUB_MCP_DEFAULT_REMOTE": "origin",
        "GITHUB_MCP_REQUIRE_CLEAN_WORKTREE": "true"
      }
    }
  }
}

如果 OpenCode 在你的 shell 导出 GH_TOKEN 之前启动,请改用此命令,以便 MCP 服务器在启动前加载 ~/.zshrc

"command": [
  "zsh",
  "-lc",
  "source \"$HOME/.zshrc\" >/dev/null 2>&1; exec node \"/Users/matiasbinagora/Projects/github-mcp/dist/index.js\""
]

工具

  • github_repo_status

  • github_pull_main

  • github_create_feature_branch

  • github_push_feature_branch

  • github_create_pull_request

  • github_prepare_feature_workflow

安全说明

  • 仓库必须位于 GITHUB_MCP_ALLOWED_ROOTS 内部。

  • 不会暴露通用的 shell 执行工具。

  • 拒绝直接推送到 mainmaster

  • 未实现强制推送和分支删除功能。

  • 默认情况下,在拉取、创建分支和创建 PR 之前,要求工作区必须是干净的。

  • 分支名称通过 git check-ref-format --branch 进行验证。

Install Server
A
license - permissive license
A
quality
D
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

  • F
    license
    Not graded
    quality
    D
    maintenance
    Standalone MCP server for GitHub that enables repository management, branch operations, pull request handling, and commit retrieval via tools listed in the README.
    1
  • A
    license
    Not graded
    quality
    D
    maintenance
    A lightweight MCP server that handles git operations on behalf of AI coding assistants, running as a local HTTP service without external network exposure by default.
    MIT
  • F
    license
    B
    quality
    B
    maintenance
    A lightweight MCP server that acts as a secure proxy for AI assistants to run local Git operations and GitHub API macros simultaneously.
    1

View all related MCP servers

Related MCP Connectors

  • A MCP server built for developers enabling Git based project management with project and personal…

  • An MCP server that gives your AI access to the source code and docs of all public github repos

  • MCP server for secureFlows: token-free URL builders and integration-linting tools for AI agents.

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/matiasnjacob/github-mcp'

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