Back to .md Directory

GitHub MCP Server

The GitHub MCP Server connects AI tools directly to GitHub's platform, giving AI agents the ability to read repositories and code files, manage issues and PRs, analyze code, and automate workflows through natural language interactions.

May 2, 2026
0 downloads
0 views
ai agent mcp copilot workflow automation
View source

GitHub MCP Server

Overview

The GitHub MCP Server connects AI tools directly to GitHub's platform, giving AI agents the ability to read repositories and code files, manage issues and PRs, analyze code, and automate workflows through natural language interactions.

Remote Server Endpoint: https://api.githubcopilot.com/mcp/

Authentication: OAuth or Personal Access Token

Use Cases

  • Repository Management: Browse and query code, search files, analyze commits, and understand project structure
  • Issue & PR Automation: Create, update, and manage issues and pull requests, triage bugs, review code changes
  • CI/CD & Workflow Intelligence: Monitor GitHub Actions workflow runs, analyze build failures, manage releases
  • Code Analysis: Examine security findings, review Dependabot alerts, understand code patterns
  • Team Collaboration: Access discussions, manage notifications, analyze team activity

Integration with ContextForge

There are two ways to use the GitHub MCP Server with ContextForge:

Option 1: Remote GitHub MCP Server (Recommended)

The remote server is hosted by GitHub at https://api.githubcopilot.com/mcp/ and provides the easiest setup method.

Using OAuth Authentication

# Register the GitHub MCP server with ContextForge
curl -X POST http://localhost:4444/gateways \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${MCPGATEWAY_BEARER_TOKEN}" \
  -d '{
    "name": "github-remote",
    "url": "https://api.githubcopilot.com/mcp/",
    "transport": "http",
    "description": "Remote GitHub MCP Server (OAuth)"
  }'

Using Personal Access Token

  1. Create a GitHub Personal Access Token at GitHub Settings > Developer settings > Personal access tokens
  2. Select the appropriate scopes for your needs
# Register with PAT authentication
curl -X POST http://localhost:4444/gateways \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${MCPGATEWAY_BEARER_TOKEN}" \
  -d '{
    "name": "github-remote",
    "url": "https://api.githubcopilot.com/mcp/",
    "transport": "http",
    "auth_config": {
      "type": "bearer",
      "token": "'${GITHUB_PAT}'"
    },
    "description": "Remote GitHub MCP Server (PAT)"
  }'

Option 2: Local GitHub MCP Server (Docker)

Run the GitHub MCP server locally using Docker and expose it through ContextForge.

Prerequisites

  • Docker installed and running
  • GitHub Personal Access Token

Setup

  1. Start the local server with translate:
# Using mcpgateway.translate to expose the Docker container
python3 -m mcpgateway.translate --stdio \
  "docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN=${GITHUB_PAT} ghcr.io/github/github-mcp-server" \
  --port 9001
  1. Register with ContextForge:
curl -X POST http://localhost:4444/gateways \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${MCPGATEWAY_BEARER_TOKEN}" \
  -d '{
    "name": "github-local",
    "url": "http://localhost:9001",
    "transport": "sse",
    "description": "Local GitHub MCP Server"
  }'

Tool Configuration

The GitHub MCP Server supports enabling or disabling specific groups of tools via environment variables or command-line flags.

Available Toolsets

ToolsetDescription
contextStrongly recommended: Tools that provide context about current user and GitHub environment
actionsGitHub Actions workflows and CI/CD operations
code_securityCode security related tools (Code Scanning)
dependabotDependabot tools
discussionsGitHub Discussions
experimentsExperimental features (not stable)
gistsGitHub Gist operations
issuesGitHub Issues
notificationsGitHub Notifications
orgsGitHub Organization tools
pull_requestsGitHub Pull Request operations
reposGitHub Repository tools
secret_protectionSecret scanning and protection
security_advisoriesSecurity advisories
usersGitHub User tools

Configuring Toolsets

For Local Docker Server

# Enable specific toolsets
docker run -i --rm \
  -e GITHUB_PERSONAL_ACCESS_TOKEN=${GITHUB_PAT} \
  -e GITHUB_TOOLSETS="repos,issues,pull_requests,actions,code_security" \
  ghcr.io/github/github-mcp-server

# Or use all toolsets
docker run -i --rm \
  -e GITHUB_PERSONAL_ACCESS_TOKEN=${GITHUB_PAT} \
  -e GITHUB_TOOLSETS="all" \
  ghcr.io/github/github-mcp-server

# Run in read-only mode
docker run -i --rm \
  -e GITHUB_PERSONAL_ACCESS_TOKEN=${GITHUB_PAT} \
  -e GITHUB_READ_ONLY=1 \
  ghcr.io/github/github-mcp-server

Dynamic Tool Discovery (Beta)

Enable dynamic toolset discovery to have tools enabled on-demand based on user prompts:

docker run -i --rm \
  -e GITHUB_PERSONAL_ACCESS_TOKEN=${GITHUB_PAT} \
  -e GITHUB_DYNAMIC_TOOLSETS=1 \
  ghcr.io/github/github-mcp-server

Creating a Virtual Server

After registering the gateway peer, create a virtual server to expose the GitHub tools:

# Create virtual server
curl -X POST http://localhost:4444/servers \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${MCPGATEWAY_BEARER_TOKEN}" \
  -d '{
    "name": "github-server",
    "description": "GitHub MCP Server with repository and issue management",
    "gateway_ids": ["github-remote"],
    "tool_choice": "auto"
  }'

Using GitHub Tools

Once configured, you can access GitHub tools through ContextForge:

List Available Tools

curl -X GET "http://localhost:4444/servers/{server_id}/tools" \
  -H "Authorization: Bearer ${MCPGATEWAY_BEARER_TOKEN}"

Example Tool Invocations

Search Repositories

curl -X POST "http://localhost:4444/tools/invoke" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${MCPGATEWAY_BEARER_TOKEN}" \
  -d '{
    "server_id": "github-server",
    "tool_name": "search_repositories",
    "arguments": {
      "query": "language:python stars:>1000"
    }
  }'

Create Issue

curl -X POST "http://localhost:4444/tools/invoke" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${MCPGATEWAY_BEARER_TOKEN}" \
  -d '{
    "server_id": "github-server",
    "tool_name": "create_issue",
    "arguments": {
      "owner": "your-org",
      "repo": "your-repo",
      "title": "Bug: Application crashes on startup",
      "body": "## Description\nThe application fails to start..."
    }
  }'

List Workflow Runs

curl -X POST "http://localhost:4444/tools/invoke" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${MCPGATEWAY_BEARER_TOKEN}" \
  -d '{
    "server_id": "github-server",
    "tool_name": "list_workflow_runs",
    "arguments": {
      "owner": "your-org",
      "repo": "your-repo"
    }
  }'

GitHub Enterprise Support

For GitHub Enterprise Server or Enterprise Cloud with data residency:

Enterprise Server

docker run -i --rm \
  -e GITHUB_PERSONAL_ACCESS_TOKEN=${GITHUB_PAT} \
  -e GITHUB_HOST="https://your-github-enterprise.com" \
  ghcr.io/github/github-mcp-server

Enterprise Cloud with Data Residency

docker run -i --rm \
  -e GITHUB_PERSONAL_ACCESS_TOKEN=${GITHUB_PAT} \
  -e GITHUB_HOST="https://yoursubdomain.ghe.com" \
  ghcr.io/github/github-mcp-server

Security Considerations

  1. Token Management: Store GitHub PATs securely using environment variables or secret management systems
  2. Scope Limitation: Only grant the minimum required permissions for your use case
  3. Rate Limiting: The GitHub API has rate limits - monitor usage and implement appropriate caching
  4. Audit Logging: Enable ContextForge audit logging to track all GitHub operations

Troubleshooting

Connection Issues

# Test direct connection to GitHub MCP server
curl -X POST https://api.githubcopilot.com/mcp/ \
  -H "Authorization: Bearer ${GITHUB_PAT}" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "method": "initialize", "params": {}, "id": 1}'

Docker Container Issues

# Check if container is running
docker ps | grep github-mcp-server

# View container logs
docker logs $(docker ps -q -f ancestor=ghcr.io/github/github-mcp-server)

Authentication Errors

  • Verify PAT has correct scopes
  • Check token expiration
  • Ensure proper header format: Authorization: Bearer YOUR_TOKEN

Additional Resources

Related Documents