The GitHub MCP Server is a powerful interface to the GitHub API, enabling file operations, repository management, search functionality, and more through the Model Context Protocol. It offers comprehensive features for Git operations while maintaining proper history and providing clear error handling.
You'll need a GitHub Personal Access Token with the appropriate permissions:
repo
scope (or public_repo
for public repositories only)To use this MCP server with Claude Desktop, add the following to your claude_desktop_config.json
:
{
"mcpServers": {
"github": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"GITHUB_PERSONAL_ACCESS_TOKEN",
"mcp/github"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>"
}
}
}
}
{
"mcpServers": {
"github": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-github"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>"
}
}
}
}
For manual installation in VS Code, add the following to your User Settings (JSON) file:
{
"mcp": {
"inputs": [
{
"type": "promptString",
"id": "github_token",
"description": "GitHub Personal Access Token",
"password": true
}
],
"servers": {
"github": {
"command": "docker",
"args": ["run", "-i", "--rm", "mcp/github"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "${input:github_token}"
}
}
}
}
}
{
"mcp": {
"inputs": [
{
"type": "promptString",
"id": "github_token",
"description": "GitHub Personal Access Token",
"password": true
}
],
"servers": {
"github": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-github"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "${input:github_token}"
}
}
}
}
}
Alternatively, you can add this configuration to a .vscode/mcp.json
file in your workspace (without the mcp
key).
create_or_update_file({
owner: "username",
repo: "repository-name",
path: "path/to/file.txt",
content: "File content here",
message: "Commit message",
branch: "main"
})
push_files({
owner: "username",
repo: "repository-name",
branch: "main",
files: [
{ path: "file1.txt", content: "Content for file 1" },
{ path: "file2.txt", content: "Content for file 2" }
],
message: "Add multiple files"
})
get_file_contents({
owner: "username",
repo: "repository-name",
path: "path/to/file.txt",
branch: "main"
})
create_repository({
name: "new-repo",
description: "A new repository",
private: false,
autoInit: true
})
fork_repository({
owner: "original-owner",
repo: "repository-to-fork"
})
create_branch({
owner: "username",
repo: "repository-name",
branch: "new-feature",
from_branch: "main"
})
list_commits({
owner: "username",
repo: "repository-name",
sha: "main",
per_page: 10
})
create_issue({
owner: "username",
repo: "repository-name",
title: "Issue title",
body: "Issue description",
labels: ["bug", "critical"]
})
get_issue({
owner: "username",
repo: "repository-name",
issue_number: 42
})
list_issues({
owner: "username",
repo: "repository-name",
state: "open",
labels: ["bug"],
sort: "created",
direction: "desc"
})
update_issue({
owner: "username",
repo: "repository-name",
issue_number: 42,
title: "Updated title",
state: "closed"
})
add_issue_comment({
owner: "username",
repo: "repository-name",
issue_number: 42,
body: "New comment text"
})
create_pull_request({
owner: "username",
repo: "repository-name",
title: "Add new feature",
body: "This PR adds XYZ functionality",
head: "feature-branch",
base: "main"
})
get_pull_request({
owner: "username",
repo: "repository-name",
pull_number: 123
})
list_pull_requests({
owner: "username",
repo: "repository-name",
state: "open",
sort: "updated",
direction: "desc"
})
create_pull_request_review({
owner: "username",
repo: "repository-name",
pull_number: 123,
body: "Looks good!",
event: "APPROVE"
})
merge_pull_request({
owner: "username",
repo: "repository-name",
pull_number: 123,
merge_method: "squash"
})
get_pull_request_files({
owner: "username",
repo: "repository-name",
pull_number: 123
})
update_pull_request_branch({
owner: "username",
repo: "repository-name",
pull_number: 123
})
search_repositories({
query: "language:javascript stars:>1000",
page: 1,
perPage: 10
})
search_code({
q: "import express language:typescript path:src/",
sort: "indexed",
order: "desc",
per_page: 20
})
search_issues({
q: "is:issue is:open label:bug in:title memory leak",
sort: "created",
order: "desc"
})
search_users({
q: "location:London followers:>100 fullstack",
sort: "followers",
order: "desc"
})
q: "import React" language:javascript
q: "function" language:typescript repo:username/repo-name
q: "api" path:src/services extension:js
q: "is:issue is:open label:bug"
q: "security is:issue assignee:username"
q: "is:pr updated:>2023-01-01"
q: "location:Berlin type:user"
q: "type:org followers:>1000"
q: "fullstack developer followers:>100"
For comprehensive search syntax, refer to GitHub's searching documentation.
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.