Skip to main content
Glama

GitHub MCP Server

A Model Context Protocol (MCP) server that integrates with GitHub's API to provide tools for automation and workflow orchestration. This server enables triggering repository dispatch events, creating issues, and retrieving repository information.

Features

  • ๐ŸŽฏ Repository Dispatch: Trigger GitHub repository_dispatch events with custom event types and JSON payloads (with full ๆ—ฅๆœฌ่ชž support)

  • ๐Ÿ› Issue Creation: Create GitHub issues as a fallback mechanism

  • ๐Ÿ“Š Repository Information: Retrieve detailed repository metadata

  • ๐Ÿ” Secure Authentication: PAT-based authentication with environment variable management

  • ๐Ÿงช Comprehensive Testing: Full pytest coverage with unit tests

  • ๐Ÿ“ Japanese Language Support: Handle Japanese characters in payloads and metadata

Related MCP server: GitHub MCP Server

Prerequisites

  • Python 3.9+

  • A GitHub Personal Access Token (PAT) with repo and workflow scopes

  • git for version control

Installation

From Source

git clone https://github.com/ai-info-x/github-mcp-server.git
cd github-mcp-server
pip install -e .

With Development Dependencies

pip install -e ".[dev]"

Authentication Setup

Step 1: Generate GitHub Personal Access Token

  1. Go to https://github.com/settings/tokens

  2. Click Generate new token (classic)

  3. Give it a descriptive name: github-mcp-server

  4. Select required scopes:

    • โœ“ repo (full control of private repositories)

    • โœ“ workflow (update GitHub Action workflows)

  5. Set expiration (90 days recommended)

  6. Click Generate token and copy the token immediately

Step 2: Configure Environment

Option A: Using .env File (Recommended)

# Copy the template
cp .env.template .env

# Edit .env with your token
# GITHUB_TOKEN=ghp_your_token_here

Option B: Export Environment Variable

export GITHUB_TOKEN="ghp_your_token_here"

Option C: System-wide Configuration

# Permanently set in ~/.bashrc or ~/.zshrc
echo 'export GITHUB_TOKEN="ghp_your_token_here"' >> ~/.bashrc
source ~/.bashrc

โš ๏ธ Security Note: Never commit .env to version control. The .gitignore already excludes it.

Usage

Running the MCP Server

# With environment variable set
GITHUB_TOKEN=ghp_your_token_here python -m src.github_mcp_server

# Or with .env file
python -m src.github_mcp_server

Available Tools

1. trigger_repository_dispatch

Trigger a custom repository dispatch event.

Parameters:

  • owner (string, required): Repository owner (username or organization)

  • repo (string, required): Repository name

  • event_type (string, required): Event type identifier (e.g., my-event, build-trigger)

  • payload (object, optional): Event payload as JSON object

Example:

{
    "owner": "ai-info-x",
    "repo": "my-repo",
    "event_type": "build-release",
    "payload": {
        "version": "v1.0.0",
        "message": "Release build initiated",
        "็’ฐๅขƒ": "ๆœฌ็•ช"  # Japanese characters supported
    }
}

Response:

{
    "success": true,
    "message": "Repository dispatch 'build-release' triggered successfully",
    "owner": "ai-info-x",
    "repo": "my-repo",
    "event_type": "build-release",
    "payload": {
        "version": "v1.0.0",
        "message": "Release build initiated",
        "็’ฐๅขƒ": "ๆœฌ็•ช"
    }
}

2. create_issue

Create a GitHub issue (useful as a fallback when dispatch fails).

Parameters:

  • owner (string, required): Repository owner

  • repo (string, required): Repository name

  • title (string, required): Issue title

  • body (string, optional): Issue description

  • labels (array, optional): Issue labels (e.g., ["bug", "urgent"])

Example:

{
    "owner": "ai-info-x",
    "repo": "my-repo",
    "title": "Auto-generated notification",
    "body": "This issue was created as a fallback notification",
    "labels": ["automated", "notification"]
}

Response:

{
    "success": true,
    "message": "Issue created successfully",
    "issue_number": 42,
    "issue_url": "https://github.com/ai-info-x/my-repo/issues/42",
    "title": "Auto-generated notification"
}

3. get_repository_info

Retrieve comprehensive repository information.

Parameters:

  • owner (string, required): Repository owner

  • repo (string, required): Repository name

Example:

{
    "owner": "ai-info-x",
    "repo": "github-mcp-server"
}

Response:

{
    "success": true,
    "name": "github-mcp-server",
    "full_name": "ai-info-x/github-mcp-server",
    "description": "MCP Server with GitHub repository_dispatch API integration",
    "url": "https://github.com/ai-info-x/github-mcp-server",
    "clone_url_https": "https://github.com/ai-info-x/github-mcp-server.git",
    "clone_url_ssh": "git@github.com:ai-info-x/github-mcp-server.git",
    "private": false,
    "stars": 5,
    "forks": 2,
    "language": "Python",
    "default_branch": "main"
}

Testing

Run All Tests

pytest

Run with Coverage

pytest --cov=src --cov-report=html

Run Specific Test

pytest tests/test_github_mcp.py::TestTriggerRepositoryDispatch::test_trigger_dispatch_success -v

Project Structure

github-mcp-server/
โ”œโ”€โ”€ src/
โ”‚   โ””โ”€โ”€ github_mcp_server.py       # Main MCP server implementation
โ”œโ”€โ”€ tests/
โ”‚   โ””โ”€โ”€ test_github_mcp.py         # Test suite
โ”œโ”€โ”€ README.md                      # This file
โ”œโ”€โ”€ .env.template                  # Environment template
โ”œโ”€โ”€ .gitignore                      # Git ignore rules
โ”œโ”€โ”€ pyproject.toml                 # Project configuration & dependencies
โ””โ”€โ”€ .git/                           # Git repository

Development

Setting Up Development Environment

# Clone and install
git clone https://github.com/ai-info-x/github-mcp-server.git
cd github-mcp-server

# Create virtual environment (optional)
python -m venv venv
source venv/bin/activate  # or `venv\Scripts\activate` on Windows

# Install with dev dependencies
pip install -e ".[dev]"

Code Style

This project uses black for code formatting and flake8 for linting.

# Format code
black src/ tests/

# Check linting
flake8 src/ tests/

Type Checking

mypy src/

Error Handling

All tools return consistent JSON responses with success flag and error information:

Success Response:

{
    "success": true,
    "message": "Operation successful",
    ...
}

Error Response:

{
    "success": false,
    "error": "Error description",
    "status": 404
}

Common GitHub API errors:

  • 404 Not Found: Repository or user doesn't exist

  • 401 Unauthorized: Invalid or expired token

  • 403 Forbidden: Insufficient permissions

  • 422 Unprocessable Entity: Invalid payload or parameters

Troubleshooting

"GITHUB_TOKEN environment variable is required"

Ensure your token is set:

# Check if set
echo $GITHUB_TOKEN

# If not set, export it
export GITHUB_TOKEN="ghp_your_token_here"

"401 Unauthorized"

Your token may be invalid or expired:

  1. Check token at https://github.com/settings/tokens

  2. Regenerate if necessary

  3. Update environment variable

"403 Forbidden"

Your token lacks required scopes:

  1. Go to https://github.com/settings/tokens

  2. Edit the token

  3. Ensure repo and workflow scopes are enabled

"Repository not found"

Verify:

  • Repository exists and is accessible

  • Correct owner/repo names

  • Owner is username (not organization) if querying user repos

Repository URLs

License

MIT License - See LICENSE file for details

Contributing

Contributions are welcome! Please:

  1. Fork the repository

  2. Create a feature branch (git checkout -b feature/your-feature)

  3. Commit changes with clear messages

  4. Write/update tests for new functionality

  5. Ensure all tests pass (pytest)

  6. Push to your fork

  7. Create a Pull Request

Support

For issues, questions, or suggestions:

Changelog

v0.1.0 (Initial Release)

  • โœจ Repository dispatch event triggering

  • โœจ Issue creation with labels

  • โœจ Repository information retrieval

  • โœจ Japanese language support in payloads

  • โœจ Comprehensive test suite

  • ๐Ÿ“ Complete documentation

A
license - permissive license
Not graded
quality - not tested
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.

  • GitHub MCP โ€” wraps the GitHub public REST API (no auth required for public endpoints)

  • GitHub Private MCP Pack โ€” access private repos, org data via OAuth.

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/ai-info-x/github-mcp-server'

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