The GitHub MCP Server enables Git operations through the GitHub API, providing file management, repository functions, search capabilities, and moreāall without requiring a local Git installation.
To use the GitHub MCP Server, you'll need a GitHub Personal Access Token with the appropriate permissions.
repo
scope for full repository access (or public_repo
for public repositories only)To integrate the GitHub MCP Server with Claude Desktop, update your claude_desktop_config.json
file using one of the following methods:
{
"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>"
}
}
}
}
The GitHub MCP Server provides numerous tools for interacting with GitHub repositories. Here are the main functions:
create_or_update_file({
owner: "username",
repo: "repository-name",
path: "path/to/file.txt",
content: "File content goes here",
message: "Commit message",
branch: "main"
})
get_file_contents({
owner: "username",
repo: "repository-name",
path: "path/to/file.txt",
branch: "main" // optional
})
push_files({
owner: "username",
repo: "repository-name",
branch: "feature-branch",
files: [
{
path: "file1.txt",
content: "Content for file 1"
},
{
path: "file2.txt",
content: "Content for file 2"
}
],
message: "Add multiple files"
})
create_repository({
name: "new-repo",
description: "My new repository",
private: false,
autoInit: true
})
create_branch({
owner: "username",
repo: "repository-name",
branch: "new-feature",
from_branch: "main" // optional
})
fork_repository({
owner: "original-owner",
repo: "repository-name",
organization: "my-organization" // optional
})
list_commits({
owner: "username",
repo: "repository-name",
page: "1", // optional
per_page: "30", // optional
sha: "main" // optional, branch name
})
create_issue({
owner: "username",
repo: "repository-name",
title: "Bug in login function",
body: "The login function throws an error when...",
assignees: ["developer1", "developer2"], // optional
labels: ["bug", "priority-high"], // optional
milestone: 1 // optional
})
create_pull_request({
owner: "username",
repo: "repository-name",
title: "Add login feature",
body: "This PR implements the login functionality...",
head: "feature-login",
base: "main",
draft: false, // optional
maintainer_can_modify: true // optional
})
get_pull_request({
owner: "username",
repo: "repository-name",
pull_number: 123
})
merge_pull_request({
owner: "username",
repo: "repository-name",
pull_number: 123,
commit_title: "Merge login feature", // optional
commit_message: "This adds the login functionality", // optional
merge_method: "squash" // optional: 'merge', 'squash', 'rebase'
})
The GitHub MCP Server supports powerful search capabilities:
search_repositories({
query: "machine learning language:python stars:>1000",
page: 1, // optional
perPage: 50 // optional
})
search_code({
q: "import express language:typescript path:src/",
sort: "indexed", // optional
order: "desc", // optional
per_page: 50, // optional
page: 1 // optional
})
search_issues({
q: "memory leak is:issue is:open label:bug",
sort: "created", // optional
order: "desc", // optional
per_page: 50, // optional
page: 1 // optional
})
search_users({
q: "fullstack developer location:London followers:>100",
sort: "followers", // optional
order: "desc", // optional
per_page: 50, // optional
page: 1 // optional
})
language:javascript
- Search by programming languagerepo:owner/name
- Search in specific repositorypath:app/src
- Search in specific pathextension:js
- Search by file extensionis:issue
or is:pr
- Filter by typeis:open
or is:closed
- Filter by statelabel:bug
- Search by labelauthor:username
- Search by authortype:user
or type:org
- Filter by account typefollowers:>1000
- Filter by followerslocation:London
- Search by locationFor complete search syntax documentation, 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.