Skip to main content

GitHub MCP Server

Create a powerful Model Context Protocol (MCP) server for GitHub in minutes with our AI Gateway. This guide walks you through setting up seamless GitHub integration with enterprise-grade security and instant OAuth authentication.

About GitHub API

GitHub is the world's leading software development platform, hosting over 100 million repositories. The GitHub API provides comprehensive access to repositories, issues, pull requests, and more:

  • Repository Management: Create, configure, and manage repositories
  • Code Operations: Access files, commits, branches, and tags
  • Pull Requests: Create, review, merge, and manage PRs
  • Issues & Projects: Track issues, manage projects, and milestones
  • Actions & Workflows: Trigger and monitor CI/CD pipelines
  • User & Organization: Manage users, teams, and permissions
  • Gists & Wikis: Create and manage code snippets and documentation
  • Webhooks & Events: Subscribe to repository and organization events

Key Features

  • REST API v3: Comprehensive RESTful interface
  • GraphQL API v4: Flexible queries with single endpoint
  • Rate Limiting: 5,000 requests per hour for authenticated requests
  • Webhooks: Real-time event notifications
  • GitHub Apps: Fine-grained permissions and multiple installations
  • OAuth Apps: User-centric authorization flow
  • Search API: Code, repositories, issues, and users
  • Git Database: Low-level Git object access

What You Can Do with GitHub MCP Server

The MCP server transforms GitHub's API into a natural language interface, enabling AI agents to:

Repository Management

  • Smart Repository Operations

    • "Create a new private repository for the machine learning project"
    • "Archive all repositories that haven't been updated in 6 months"
    • "Clone the repository structure from our template repo"
    • "Update repository settings to require PR reviews"
  • Branch & Tag Management

    • "Create a release branch from the current main"
    • "Tag the current commit as v2.0.0 with release notes"
    • "Protect the main branch with required status checks"
    • "List all branches with unmerged changes"
  • Collaborator Management

    • "Add the new team members as contributors"
    • "Update Sarah's permissions to admin on all frontend repos"
    • "Remove access for users who left the company"

Pull Request Automation

  • PR Management

    • "Create a PR from feature/login to main with description"
    • "Find all PRs waiting for my review"
    • "Merge all approved PRs that pass CI checks"
    • "Request review from the backend team on PR #123"
  • Code Review Intelligence

    • "Summarize changes in the latest PR"
    • "Find PRs with merge conflicts"
    • "List PRs with failing tests"
    • "Show PRs that have been open for more than a week"
  • Automated Workflows

    • "Auto-assign reviewers based on code ownership"
    • "Label PRs based on files changed"
    • "Create draft PRs for work in progress"

Issue Tracking & Projects

  • Issue Management

    • "Create a bug report for the login page issue"
    • "Find all critical bugs opened this week"
    • "Assign unassigned issues to team members by expertise"
    • "Close issues fixed in the latest release"
  • Project Boards

    • "Move issue #456 to 'In Progress' column"
    • "Create a new project board for Q1 features"
    • "Show all issues in the current sprint"
    • "Generate sprint report with completed items"
  • Labeling & Organization

    • "Label all issues mentioning performance as 'optimization'"
    • "Create milestone for version 3.0 release"
    • "Organize issues by priority and effort"

CI/CD & Automation

  • GitHub Actions

    • "Trigger the deployment workflow for production"
    • "Show status of all running workflows"
    • "Re-run failed CI jobs from the last commit"
    • "Create a workflow for automated testing"
  • Release Management

    • "Create a new release with changelog from merged PRs"
    • "Generate release notes from commit messages"
    • "Deploy the latest tag to staging environment"
    • "Schedule releases for specific dates"

Analytics & Insights

  • Code Intelligence

    • "Show commit activity for the past month"
    • "Find who contributed most to the auth module"
    • "Analyze code churn in the frontend directory"
    • "List most active contributors this quarter"
  • Repository Insights

    • "Generate contribution statistics for the team"
    • "Show language breakdown across all repos"
    • "Find repositories with security vulnerabilities"
    • "Track star and fork trends"

Search & Discovery

  • Code Search

    • "Find all API keys in the codebase"
    • "Search for TODO comments in JavaScript files"
    • "Locate usage of deprecated functions"
    • "Find files containing specific error messages"
  • Cross-Repository Operations

    • "Update GitHub Actions across all repositories"
    • "Find all repos using React version 16"
    • "Search for specific dependencies in package.json files"

Prerequisites

  • Access to Cequence AI Gateway
  • GitHub account with appropriate permissions
  • Ability to create OAuth Apps or GitHub Apps
  • Repository access for desired operations

Step 1: Create GitHub OAuth App

Before setting up the MCP server, you need to create a GitHub OAuth App.

1.1 Access GitHub Settings

  1. Log in to GitHub
  2. Navigate to Settings (click your profile picture Settings)
  3. Scroll down to Developer settings in the left sidebar
  4. Click OAuth Apps

1.2 Register New OAuth App

  1. Click New OAuth App (or Register a new application)

  2. Fill in the application details:

    • Application name: "AI Gateway MCP Integration"
    • Homepage URL: https://your-company.com
    • Application description: "MCP server for GitHub integration"
    • Authorization callback URL:
      https://auth.aigateway.cequence.ai/v1/outbound/oauth/callback
    • For development, add:
      https://auth.aigateway.cequence.ai/v1/outbound/oauth/callback
  3. Click Register application

1.3 Get OAuth Credentials

  1. After registration, you'll see your app details
  2. Note down:
    • Client ID
    • Click Generate a new client secret
    • Client Secret (copy immediately - shown only once)

1.4 Configure OAuth App (Optional)

  1. Update settings if needed:
    • Add additional callback URLs
    • Upload logo
    • Update descriptions
    • Enable Device Flow if needed

Step 2: Access AI Gateway Apps

  1. Log in to your Cequence AI Gateway dashboard
  2. Navigate to Apps in the left sidebar
  3. You'll see the list of available third-party applications

Step 3: Find and Select GitHub API

  1. In the Apps section, browse through the Third-party category
  2. Look for GitHub or use the search function
  3. Click on the GitHub API card to view details

The GitHub API card shows:

  • Number of available endpoints
  • Integration capabilities
  • Quick description of functionality

Step 4: Create MCP Server

  1. Click the Create MCP Server button on the GitHub API card
  2. You'll be redirected to the MCP Server creation wizard

Step 5: Configure API Endpoints

In the App Configuration step:

  1. Base URL is pre-filled: https://api.github.com
  2. Select API endpoints to expose to your MCP server based on your needs
  3. Click Next to proceed

Step 6: MCP Server Basic Setup

Configure your MCP server details:

  1. MCP Server Name: Enter a descriptive name

    • Example: "GitHub Development Automation"
    • This name will identify your server in the dashboard
  2. Description (Optional): Add details about the server's purpose

    • Example: "Automated GitHub operations for development workflow"
  3. Production Mode: Toggle based on your needs

    • ON for production environments
    • OFF for development/testing
  4. Click Next to continue

Step 7: Configure Authentication

This is where you'll use your GitHub OAuth App credentials:

  1. Authentication Type: Select OAuth 2.0

  2. Fill in the OAuth configuration:

    • Authorization URL:
      https://github.com/login/oauth/authorize
    • Token URL:
      https://github.com/login/oauth/access_token
    • Client ID: Paste from GitHub OAuth App
    • Client Secret: Paste from GitHub OAuth App
    • Redirect URI:
      https://auth.aigateway.cequence.ai/v1/outbound/oauth/callback
  3. Scopes: Select from the available GitHub scopes (see next section)

Available GitHub OAuth Scopes

Configure the appropriate scopes based on your application needs:

Repository Access

  • repo

    • Full control of private repositories
    • Includes all repository permissions
    • Read/write access to code, issues, PRs, wikis
    • Manage webhooks and services
  • public_repo

    • Access to public repositories only
    • Read/write access to public repo code
    • Manage issues and pull requests
    • More limited than full repo scope

User Information

  • user

    • Read/write access to profile info
    • Manage user followers
    • Update user profile
    • Full user data access
  • read:user

    • Read access to user profile
    • View email addresses
    • See user metadata
    • No write permissions
  • user:email

    • Access user email addresses
    • Manage email visibility
    • Primary email information
    • Verified email status

For Basic Operations:

public_repo
read:user

For Full Repository Management:

repo
user

For Read-Only Analytics:

public_repo
read:user
user:email

Step 8: Configure Security

Set up API protection features:

  1. API Protection: Toggle ON to enable

    • Protects against bot attacks, DDoS, and threats
    • Monitors for suspicious activity
    • Rate limiting and anomaly detection
  2. Protection Features (when enabled):

    • Auto-scaling protection
    • Managed infrastructure
    • Built-in monitoring
    • Zero maintenance required
  3. Click Next to continue

Step 9: Choose Deployment Method

Select your deployment preference:

  • Fully managed deployment
  • Automatic scaling and monitoring
  • Built-in high availability
  • Features included:
    • Auto-scaling
    • Managed infrastructure
    • Built-in monitoring
    • Zero maintenance

Option B: Deploy with Helm Chart

  • Self-managed Kubernetes deployment
  • Full control over infrastructure
  • Requires:
    • Kubernetes cluster
    • Helm 3.x installed
    • Container registry access

Click Next after selecting your deployment method.

Step 10: Review and Deploy

Review your MCP server configuration:

  • MCP Server Name: Your chosen name
  • Base URL: https://api.github.com
  • Selected Endpoints: Number of endpoints selected
  • Authentication: OAuth 2.0 (Configured)
  • API Protection: Enabled/Disabled
  • Deployment: Cequence Cloud or Helm

Click Create & Deploy to finalize the setup.

Step 11: Post-Deployment Setup

After successful deployment:

  1. Note the MCP Server URL provided

  2. Test the OAuth flow:

    • Click "Test Connection"
    • You'll be redirected to GitHub authorization
    • Review and accept permissions
    • Confirm successful connection
  3. Configure AI Agents:

    • The MCP server is now available for AI agent connections
    • Use the provided server URL in your AI agent configuration

Using Your GitHub MCP Server

With Claude Desktop

  1. Open Claude Desktop settings

  2. Add your MCP server:

    {
    "servers": {
    "github": {
    "url": "your-mcp-server-url",
    "auth": {
    "type": "oauth2",
    "client_id": "your-client-id"
    }
    }
    }
    }
  3. Start using natural language commands:

    • "Show me all open PRs assigned to me"
    • "Create an issue about the bug in the login component"
    • "Merge PR #123 if all checks are passing"
    • "Generate release notes from the last 10 merged PRs"
    • "Find all TODO comments in the src directory"

API Integration Example

// Initialize MCP client
const mcpClient = new MCPClient({
serverUrl: 'your-mcp-server-url',
auth: {
type: 'oauth2',
token: 'user-access-token'
}
});

// Get repository information
const repo = await mcpClient.github.repos.get({
owner: 'octocat',
repo: 'hello-world'
});

// Create an issue
const issue = await mcpClient.github.issues.create({
owner: 'octocat',
repo: 'hello-world',
title: 'Bug: Login page not responsive',
body: 'The login page breaks on mobile devices...',
labels: ['bug', 'high-priority']
});

// Create a pull request
const pr = await mcpClient.github.pulls.create({
owner: 'octocat',
repo: 'hello-world',
title: 'Fix: Responsive login page',
head: 'feature/fix-login',
base: 'main',
body: 'This PR fixes the responsive issues on the login page'
});

// Search code
const results = await mcpClient.github.search.code({
q: 'className:auth language:js',
sort: 'indexed',
order: 'desc'
});

Common Use Cases

Development Workflow

  • Automated PR creation and management
  • Code review assignment
  • Branch protection rules
  • Merge queue management

Project Management

  • Issue triage and labeling
  • Sprint planning with projects
  • Milestone tracking
  • Team workload distribution

DevOps Automation

  • CI/CD pipeline triggers
  • Release automation
  • Deployment tracking
  • Infrastructure as Code updates

Code Quality

  • Security vulnerability scanning
  • Code style enforcement
  • Dependency updates
  • Technical debt tracking

Security Best Practices

  1. Token Security:

    • Use minimum required scopes
    • Rotate tokens regularly
    • Never commit tokens to code
    • Use environment variables
  2. Access Control:

    • Limit repository access
    • Use GitHub Apps for better security
    • Implement IP allowlisting
    • Monitor access logs
  3. Webhook Security:

    • Validate webhook signatures
    • Use webhook secrets
    • Implement replay protection
    • Secure endpoint URLs
  4. Rate Limit Management:

    • Monitor rate limit headers
    • Implement exponential backoff
    • Cache frequently accessed data
    • Use conditional requests

Troubleshooting

Common Issues

  1. Bad Credentials (401)

    • Verify OAuth token is valid
    • Check token hasn't been revoked
    • Ensure correct scopes granted
    • Regenerate token if needed
  2. Rate Limit Exceeded (403)

    • Check X-RateLimit headers
    • Implement request throttling
    • Use authenticated requests (5000/hour vs 60/hour)
    • Consider GitHub App for higher limits
  3. Not Found (404)

    • Verify repository exists and accessible
    • Check correct owner/repo names
    • Ensure user has permissions
    • Private repo requires 'repo' scope
  4. Validation Failed (422)

    • Check required fields in request
    • Verify data types and formats
    • Review API documentation
    • Validate JSON payload

Getting Help