GitHub Integration
STDIOMCP server implementing tools for LLM agents to interact with GitHub repositories and resources.
MCP server implementing tools for LLM agents to interact with GitHub repositories and resources.
This project implements a Model Context Protocol (MCP) server for GitHub API access. It provides a set of tools that allow LLM agents to interact with GitHub repositories, issues, pull requests, and other GitHub resources.
The server provides the following GitHub operations:
Repository Management
Issue Management
Pull Request Management
Branch Management
Commit Management
Content Management
These operations are exposed as tools for Large Language Models using the Model Context Protocol (MCP), allowing AI systems to safely interact with GitHub through its API.
Build the project using Maven:
mvn clean package
Run the server using the following command:
java -jar target/GitHubMCP-1.0-SNAPSHOT.jar
The server can use STDIO for communication with MCP clients or can be run as a web server.
The GitHub MCP server supports the following environment variables for authentication:
GITHUB_TOKEN
or GITHUB_PERSONAL_ACCESS_TOKEN
: Your GitHub personal access tokenGITHUB_HOST
: The base URL of your GitHub instance (e.g., github.com
or github.mycompany.com
for GitHub Enterprise)GITHUB_REPOSITORY
: Default repository to use if not specified in API calls (e.g., owner/repo
)You can set these environment variables when launching the MCP server, and the GitHub services will use them as default values. This allows you to avoid having to provide authentication details with every API call.
Edit your claude_desktop_config.json file with the following:
{ "mcpServers": { "github": { "command": "java", "args": [ "-Dspring.ai.mcp.server.stdio=true", "-Dspring.main.web-application-type=none", "-Dlogging.pattern.console=", "-jar", "/path/to/GitHubMCP/target/GitHubMCP-1.0-SNAPSHOT.jar" ], "env": { "GITHUB_TOKEN": "your-github-token-here", "GITHUB_HOST": "github.com", "GITHUB_REPOSITORY": "your-username/your-repository" } } } }
GitHub
(or any descriptive name)STDIO
-Dspring.ai.mcp.server.stdio=true
-Dspring.main.web-application-type=none
-Dlogging.pattern.console=
-jar
/path/to/GitHubMCP/target/GitHubMCP-1.0-SNAPSHOT.jar
GITHUB_TOKEN=your-github-token-here
GITHUB_HOST=github.com
GITHUB_REPOSITORY=your-username/your-repository
When using this server, be aware that:
If you've configured the MCP server with environment variables, you can simply ask:
Can you get a list of open issues in my GitHub repository?
Claude will use the GitHub services with the pre-configured authentication details to fetch the open issues from your GitHub repository and summarize them.
You can override the default repository by specifying it in your request:
Can you list the pull requests for the anthropics/claude-playground repository?
The GitHub service will use your authentication token but query the specified repository instead of the default one.
The GitHub MCP server is organized into several service classes, each providing different functionality:
RepositoryService
listRepositories
: List repositories for the authenticated usergetRepository
: Get detailed information about a specific repositorysearchRepositories
: Search for repositories matching a queryIssueService
listIssues
: List issues for a repository with filtering optionsgetIssue
: Get detailed information about a specific issuecreateIssue
: Create a new issue in a repositoryaddIssueComment
: Add a comment to an issuesearchIssues
: Search for issues matching a queryPullRequestService
listPullRequests
: List pull requests for a repository with filtering optionsgetPullRequest
: Get detailed information about a specific pull requestcreatePullRequestComment
: Add a comment to a pull requestmergePullRequest
: Merge a pull request with specified merge methodBranchService
listBranches
: List branches in a repository with filtering optionscreateBranch
: Create a new branch from a specified referenceCommitService
getCommitDetails
: Get detailed information about a specific commitlistCommits
: List commits in a repository with filtering optionsfindCommitByMessage
: Search for commits containing specific text in their messagesContentService
getFileContents
: Get the contents of a file in a repositorylistDirectoryContents
: List contents of a directory in a repositorycreateOrUpdateFile
: Create or update a file in a repositorysearchCode
: Search for code within repositoriesEach service provides methods that can be called by LLM agents through the MCP protocol, allowing them to interact with GitHub in a structured and controlled manner.
This MCP server supports both GitHub.com and GitHub Enterprise instances. To use with GitHub Enterprise, set the GITHUB_HOST
environment variable to your enterprise GitHub URL.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.