GitHub - github/github-mcp-server: GitHub's official MCP Server
Service

GitHub - github/github-mcp-server: GitHub's official MCP Server

github
2025.04.14
ยทGitHubยทby Anonymous
#AI#GitHub#Agent#LLM#Automation

Key Points

  • 1The GitHub MCP Server is an official tool enabling AI agents to interact with GitHub via natural language for tasks such as repository management, issue automation, and code analysis.
  • 2Users can deploy the server remotely with compatible MCP hosts or locally via Docker, requiring a GitHub Personal Access Token (PAT) for secure authentication.
  • 3The server's functionality is highly customizable through toolsets and individual tools, allowing precise control over which GitHub API capabilities are exposed to AI models.

The GitHub MCP Server is an official GitHub project designed to bridge artificial intelligence (AI) tools directly with the GitHub platform. It empowers AI agents, assistants, and chatbots to interact with GitHub functionalities through natural language, enabling operations such as reading repositories and code files, managing issues and pull requests, analyzing code, and automating workflows.

The server facilitates a range of use cases:

  • Repository Management: Enables browsing, querying, searching files, analyzing commits, and understanding project structures across accessible repositories.
  • Issue & PR Automation: Supports creation, updating, and management of issues and pull requests, aiding in bug triage, code reviews, and project board maintenance.
  • CI/CD & Workflow Intelligence: Provides capabilities for monitoring GitHub Actions workflow runs, analyzing build failures, managing releases, and gaining insights into development pipelines.
  • Code Analysis: Allows examination of security findings, review of Dependabot alerts, understanding code patterns, and obtaining comprehensive codebase insights.
  • Team Collaboration: Offers access to discussions, notification management, and analysis of team activities.

The GitHub MCP Server offers two primary deployment methods:

  1. Remote GitHub MCP Server: This is a GitHub-hosted solution, providing the simplest setup. It requires a compatible MCP host application (e.g., VS Code 1.101+, Claude Desktop, Cursor, Windsurf). Installation typically involves one-click integrations or manual configuration by adding JSON blocks to the host's configuration, specifying the server type as "http" and the url as https://api.githubcopilot.com/mcp/. Authentication can be managed via OAuth (where supported by the host and GitHub App/OAuth App configuration) or by providing a GitHub Personal Access Token (PAT) via a Bearer token in the Authorization header, often prompted via an input type promptString. GitHub Enterprise Cloud with data residency (ghe.com) can also utilize the remote server by adjusting the url to its specific Copilot API endpoint, for example, https://copilot-api.octocorp.ghe.com/mcp.
  1. Local GitHub MCP Server: This method involves self-hosting the server, typically within a Docker container.
    • Prerequisites: Docker must be installed and running, and a GitHub Personal Access Token (PAT) with appropriate scopes must be created.
    • Docker Deployment: The server's Docker image is publicly available at ghcr.io/github/github-mcp-server. Local installation configurations for MCP hosts involve defining a server entry with command: "docker" and args to run the image, passing the GITHUB_PERSONAL_ACCESS_TOKEN as an environment variable (e.g., -e GITHUB_PERSONAL_ACCESS_TOKEN).
    • Building from Source: Alternatively, users can build the server binary from source using Go (e.g., go build -o /path/to/github-mcp-server cmd/github-mcp-server). The resulting executable is then configured as the command in the host's MCP settings, typically running with the stdio argument, and the GITHUB_PERSONAL_ACCESS_TOKEN is supplied as an environment variable to the executable.

Authentication and Security:
Authentication primarily relies on GitHub Personal Access Tokens (PATs) or OAuth. For PATs, security best practices are emphasized:

  • Minimum Scopes: Granting only necessary permissions (e.g., repo, read:packages, read:org).
  • Separate Tokens: Using distinct PATs for different projects or environments.
  • Regular Rotation: Updating tokens periodically.
  • Never Commit: Keeping tokens out of version control systems (e.g., via .gitignore for .env files).
  • File Permissions: Restricting access to configuration files containing tokens (e.g., chmod 600).
PATs should ideally be handled via environment variables (e.g., exportGITHUBPAT=yourtokenhereexport GITHUB_PAT=your_token_here or in a .env file) for security and reusability, though some hosts might require hardcoded tokens. The server also supports GitHub Enterprise Server instances, which require specifying the GITHUB_HOST environment variable or --gh-host flag with the full https:// URI.

Tool Configuration:
The server's functionality is exposed through "toolsets" and individual "tools," allowing granular control over which GitHub API capabilities are accessible to AI agents.

  • Toolsets: Collections of related tools that can be enabled or disabled. When no toolsets are specified, a "default" set (context, repos, issues, pull_requests, users) is used. Toolsets can be specified via the --toolsets command-line argument or GITHUB_TOOLSETS environment variable (e.g., repos,issues,pull_requests). The all toolset enables all available functionalities.
  • Individual Tools: Specific functions within the GitHub API (e.g., get_file_contents, issue_read, create_pull_request). These can be specified via --tools or GITHUB_TOOLS.
  • Additive Configuration: Toolsets and individual tools can be combined; specifying both will add the individual tools to those provided by the selected toolsets.
  • Dynamic Toolsets: An option to enable tools for discovering and managing toolsets themselves.
  • Read-Only Mode: A --read-only flag overrides all write operations, ensuring only read tools are enabled.

Examples of available toolsets include context, actions, code_security, dependabot, discussions, gists, git, issues, labels, notifications, orgs, projects, pull_requests, repos, secret_protection, security_advisories, stargazers, and users. Additionally, the remote server provides copilot and copilot_spaces toolsets. Each tool within these toolsets typically lists its required OAuth scopes and parameters. For instance, within the actions toolset, tools like cancel_workflow_run, delete_workflow_run_logs, download_workflow_run_artifact, get_job_logs, get_workflow_run, get_workflow_run_logs, get_workflow_run_usage, list_workflow_jobs, list_workflow_run_artifacts, list_workflow_runs, list_workflows, rerun_failed_jobs, rerun_workflow_run, and run_workflow are available, each requiring the repo OAuth scope and specific input parameters (e.g., owner, repo, run_id, job_id, workflow_id).