The GitHub MCP Server allows LLM agents to interact with GitHub repositories, issues, pull requests, branches, files, and releases through a standardized Model Context Protocol (MCP) interface. It acts as a bridge between AI models and the GitHub API, providing a set of well-defined tools for GitHub operations.
Clone the repository:
git clone https://github.com/cyanheads/github-mcp-server.git
cd github-mcp-server
Install dependencies:
npm install
Create a .env
file in the project root with your GitHub token:
GITHUB_TOKEN=your_github_personal_access_token
LOG_LEVEL=info
SERVER_NAME=github-mcp-server
Build the project:
npm run build
Start the server:
node build/index.js
The server can be configured through environment variables:
Environment Variable | Description | Default |
---|---|---|
GITHUB_TOKEN |
GitHub personal access token (required) | - |
LOG_LEVEL |
Logging level (debug, info, warn, error, fatal) | info |
SERVER_NAME |
MCP server name | github-mcp-server |
SERVER_VERSION |
MCP server version | 0.1.0 |
API_TIMEOUT_MS |
Timeout for API calls in milliseconds | 10000 |
RATE_LIMITING_ENABLED |
Whether rate limiting is enabled | true |
RATE_LIMITING_MIN_REMAINING |
Minimum remaining requests before throttling | 100 |
RATE_LIMITING_RESET_BUFFER_MS |
Time buffer to add to rate limit reset time | 5000 |
Add to your MCP client settings:
{
"mcpServers": {
"github": {
"command": "node",
"args": ["/path/to/github-mcp-server/build/index.js"],
"env": {
"GITHUB_TOKEN": "your_github_personal_access_token",
"LOG_LEVEL": "info",
"SERVER_NAME": "github-mcp-server"
}
}
}
}
GitHub MCP Server provides tools organized by functionality:
Tool | Description |
---|---|
get_repository |
Get detailed information about a specific repository Parameters: owner , repo |
list_repositories |
List repositories for the authenticated user Parameters: type (optional), sort (optional) |
create_repository |
Create a new GitHub repository Parameters: name , description (optional), private (optional) |
Tool | Description |
---|---|
list_branches |
List branches in a repository Parameters: owner , repo , protected (optional), per_page (optional) |
create_branch |
Create a new branch Parameters: owner , repo , branch , sha |
delete_branch |
Delete a branch Parameters: owner , repo , branch |
Tool | Description |
---|---|
create_issue |
Create a new issue in a repository Parameters: owner , repo , title , body (optional), labels (optional) |
list_issues |
List issues in a repository Parameters: owner , repo , state (optional), labels (optional) |
Tool | Description |
---|---|
create_pull_request |
Create a new pull request Parameters: owner , repo , title , head , base , body (optional) |
merge_pull_request |
Merge a pull request Parameters: owner , repo , pull_number , commit_title (optional), commit_message (optional), merge_method (optional) |
update_pull_request |
Update an existing pull request Parameters: owner , repo , pull_number , title (optional), body (optional), state (optional), base (optional), maintainer_can_modify (optional) |
list_pull_requests |
List pull requests in a repository Parameters: owner , repo , state (optional), head (optional), base (optional), sort (optional), direction (optional) |
Tool | Description |
---|---|
update_file |
Create or update a file in a repository Parameters: owner , repo , path , message , content , sha (optional), branch (optional) |
Tool | Description |
---|---|
create_release |
Create a new release Parameters: owner , repo , tag_name , name (optional), body (optional), draft (optional), prerelease (optional) |
The server implements comprehensive error handling with:
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.