github-mcp-server

Megh-Zyke/github-mcp-server

3.2

If you are the rightful owner of github-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

A Model Context Protocol (MCP) server implementation for GitHub, enabling AI agents and LLMs to interact with GitHub repositories programmatically via standardized JSON-RPC tools.

Tools
15
Resources
0
Prompts
0

GitHub MCP Server

A Model Context Protocol (MCP) server implementation for GitHub, enabling AI agents and LLMs to interact with GitHub repositories programmatically via standardized JSON-RPC tools.


Overview

This MCP server provides access to key GitHub repository features via a set of tools, including:

  • Retrieving repository metadata (stars, forks, etc.)
  • Querying commits and comparing commits
  • Managing GitHub issues: listing, creating, commenting, labeling, assigning, and closing

By exposing these functions over MCP, any MCP-compatible client or large language model (LLM) can seamlessly use GitHub as a contextual data source and tool.


Features

Tool NameDescription
get_repo_infoFetch basic repository info (stars, forks, name)
get_total_number_of_commitsGet the total number of commits in a repository
get_commit_numbersList commit SHA hashes
get_commit_detailsRetrieve details about a specific commit
compare_commitsCompare two commits and return file-level changes
get_all_issuesList all issues with details
get_issue_by_numberGet details of a specific issue
create_issueCreate a new issue
comment_on_issueAdd a comment to an issue
get_issue_commentsRetrieve all comments on an issue
add_issue_labelsAdd labels to an issue
remove_issue_labelsRemove labels from an issue
assign_issueAssign users to an issue
unassign_issueRemove assignees from an issue
close_issueClose an issue

Setup and Usage

Prerequisites

  • Python 3.8+
  • GitHub Personal Access Token (PAT) with repo and issue scopes
  • FastMCP
  • PyGithub library
  • python-dotenv for environment variable management

Installation

  1. Clone the repository (or create your own project).

  2. Install dependencies:

pip install PyGithub python-dotenv mcp-server-fastmcp
  1. Create a .env file with your GitHub token:
GITHUB_TOKEN_1=your_personal_access_token_here
  1. Run the MCP server:
python github_mcp_server.py

This will start the MCP server listening on standard input/output (stdio) by default.


Authentication

This server uses a GitHub Personal Access Token loaded from the environment variable GITHUB_TOKEN_1. Make sure the token has sufficient permissions to read repositories and manage issues.


How It Works

  • Each tool function is decorated with @mcp.tool() to expose it via MCP.
  • The server listens for JSON-RPC requests from an MCP client.
  • On receiving a request, it calls the appropriate tool and returns the result.
  • Errors during API calls are returned as error strings (future versions will improve error handling).

Future Improvements

  • Structured JSON responses for better LLM parsing
  • Enhanced error handling with MCP-standard errors
  • Permission and rate limit handling
  • Expanded GitHub API coverage: pull requests, branches, contributors
  • OAuth-based authentication flows