
Github MCP Server
概览
MCP Server for the GitHub API, enabling file operations, repository management, search functionality, and more. - github pat is now dynamic per request and does not have to be included via environment variables, but still falls back to environment variables. - name: mcp-github - : When creating/updating files or pushing changes, branches are automatically created if they don't exist - : Clear error messages for common issues - : Operations maintain proper Git history without force pushing - : Support for both single-file and multi-file operations - : Support for searching code, issues/PRs, and users 1.
README
以下为原文 README 节选,完整内容请查看原文。
GitHub MCP Server
MCP Server for the GitHub API, enabling file operations, repository management, search functionality, and more.
Mission Squad modifications
- github pat is now dynamic per request and does not have to be included via environment variables, but still falls back to environment variables.
- name: mcp-github
Features
- Automatic Branch Creation: When creating/updating files or pushing changes, branches are automatically created if they don’t exist
- Comprehensive Error Handling: Clear error messages for common issues
- Git History Preservation: Operations maintain proper Git history without force pushing
- Batch Operations: Support for both single-file and multi-file operations
- Advanced Search: Support for searching code, issues/PRs, and users
Tools
-
create_or_update_file- Create or update a single file in a repository
- Inputs:
owner(string): Repository owner (username or organization)repo(string): Repository namepath(string): Path where to create/update the filecontent(string): Content of the filemessage(string): Commit messagebranch(string): Branch to create/update the file insha(optional string): SHA of file being replaced (for updates)
- Returns: File content and commit details
-
push_files- Push multiple files in a single commit
- Inputs:
owner(string): Repository ownerrepo(string): Repository namebranch(string): Branch to push tofiles(array): Files to push, each withpathandcontentmessage(string): Commit message
- Returns: Updated branch reference
-
search_repositories- Search for GitHub repositories
- Inputs:
query(string): Search querypage(optional number): Page number for paginationperPage(optional number): Results per page (max 100)
- Returns: Repository search results
-
create_repository- Create a new GitHub repository
- Inputs:
name(string): Repository namedescription(optional string): Repository descriptionprivate(optional boolean): Whether repo should be privateautoInit(optional boolean): Initialize with README
- Returns: Created repository details
-
get_file_contents- Get contents of a file or directory
- Inputs:
owner(string): Repository ownerrepo(string): Repository namepath(string): Path to file/directorybranch(optional string): Branch to get contents from
- Returns: File/directory contents
-
create_issue- Create a new issue
- Inputs:
owner(string): Repository ownerrepo(string): Repository nametitle(string): Issue titlebody(optional string): Issue descriptionassignees(optional string[]): Usernames to assignlabels(optional string[]): Labels to add
安装
docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN mcp/github配置
{
"mcpServers": {
"github": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"GITHUB_PERSONAL_ACCESS_TOKEN",
"mcp/github"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>"
}
}
}
}