Create or update a single file in a repository
Push multiple files in a single commit
Search for GitHub repositories
Create a new GitHub repository
Get contents of a file or directory
Create a new issue
Create a new pull request
Fork a repository
Create a new branch
List and filter repository issues
Update an existing issue
Add a comment to an issue
Search for code across GitHub repositories
Search for issues and pull requests
Search for GitHub users
Gets commits of a branch in a repository
Gets the contents of an issue within a repository
Get details of a specific pull request
List and filter repository pull requests
The GitHub API MCP server provides a comprehensive interface for interacting with GitHub repositories and resources. It enables file operations, repository management, issue tracking, pull request handling, and advanced search functionality. With features like automatic branch creation, batch operations, and proper Git history preservation, this MCP server makes it easy to integrate GitHub workflows into your AI-powered applications.
The GitHub API MCP server provides a powerful interface to interact with GitHub repositories, issues, pull requests, and more through the GitHub API. This server enables AI assistants to perform a wide range of GitHub operations, from creating and updating files to searching code and managing issues.
To use the GitHub API MCP server, add the following configuration to your MCP client:
"mcpServers": {
"github": {
"url": "https://github-mcp-server.example.com"
}
}
For local development, you can run the server using Docker:
docker pull modelcontextprotocol/github-server
docker run -p 3000:3000 -e GITHUB_TOKEN=your_github_token modelcontextprotocol/github-server
Then update your MCP client configuration to point to your local server:
"mcpServers": {
"github": {
"url": "http://localhost:3000"
}
}
The GitHub API MCP server requires a GitHub personal access token with appropriate permissions for the operations you want to perform. You can create a token in your GitHub account settings under Developer Settings > Personal Access Tokens.
For repository operations, you'll need the repo
scope. For user operations, you'll need the user
scope. For organization operations, you'll need the admin:org
scope.
// Create or update a file in a repository
const result = await github.create_or_update_file({
owner: "username",
repo: "repository-name",
path: "path/to/file.txt",
content: "File content goes here",
message: "Add or update file",
branch: "main"
});
// Create a pull request
const pr = await github.create_pull_request({
owner: "username",
repo: "repository-name",
title: "Add new feature",
body: "This PR adds a new feature",
head: "feature-branch",
base: "main"
});
// Search for code
const searchResults = await github.search_code({
q: "function in:file language:javascript repo:username/repository-name"
});
The GitHub API MCP server provides detailed error messages for common issues. If you encounter an error, check the error message for details on what went wrong and how to fix it.
Common errors include: