通过模型上下文协议(MCP)与 Github 集成,允许大型语言模型与 Github 的仓库、问题、拉取请求和搜索功能进行交互。
787 查看 · 2026-07-07 更新
简介
通过模型上下文协议(MCP)与 Github 集成,允许大型语言模型与 Github 的仓库、问题、拉取请求和搜索功能进行交互。
简介
通过模型上下文协议(MCP)与 Github 集成,允许大型语言模型与 Github 的仓库、问题、拉取请求和搜索功能进行交互。
Github MCP 服务器
一个用于 Github 的 模型上下文协议 服务器。
通过 MCP 提供与 Github 的集成,允许大型语言模型与其交互。
安装
手动安装
-
为您的 Github 账户创建或获取访问令牌:指南
-
将服务器配置添加到 Claude 桌面版中:
- MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
- Windows: 查看此指南
{ "mcpServers": { "github": { "command": "npx", "args": ["-y", "github-mcp-server"], "env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "your_personal_github_access_token" } } } }
组件
工具
-
search_repositories: Search GitHub for a repository.- Required inputs:
query(string): The query to search for repository.page(number, default: 30, max: 100): Page number for pagination.per_page(number, default: 30, max: 100): Number of results per page.
- Required inputs:
-
search_issues: Search issues from a repository.- Required inputs:
query(string): The query to search for repository.page(number, default: 1): Page number for pagination.per_page(number, default: 30, max: 100): Number of results per page.order(optional string, default:desc): Sort of order (ascordesc).sort(optional string, default:best match): Sort field (can be one of:comments,reactions,reactions-+1,reactions--1,reactions-smile,reactions-thinking_face,reactions-heart,reactions-tada,interactions,createdorupdated).
- Required inputs:
-
search_commits: Search commits from a repository.- Required inputs:
query(string): The query to search for repository.page(number, default: 1): Page number for pagination.per_page(number, default: 30, max: 100): Number of results per page.order(optional string, default:desc): Sort of order (ascordesc).sort(optional string, default:best match): Sort field (can be one of:committer-dateorauthor-date).
- Required inputs:
-
search_code: Search code from a repository.- Required inputs:
query(string): The query to search for repository.page(number, default: 1): Page number for pagination.per_page(number, default: 30, max: 100): Number of results per page.
- Required inputs:
-
search_users: Search users from a repository.- Required inputs:
query(string): The query to search for repository.page(number, default: 1): Page number for pagination.per_page(number, default: 30, max: 100): Number of results per page.order(optional string, default:desc): Sort of order (ascordesc).sort(optional string, default:best match): Sort field (can be one of:followers,repositoriesorjoined).
- Required inputs:
-
search_topics: Search topics.- Required inputs:
query(string): The query to search for repository.page(number, default: 1): Page number for pagination.per_page(number, default: 30, max: 100): Number of results per page.
- Required inputs:
-
search_labels: Search labels in a repository.- Required inputs:
query(string): The query to search for repository.page(number, default: 1): Page number for pagination.per_page(number, default: 30, max: 100): Number of results per page.order(optional string, default:desc): Sort of order (ascordesc).sort(optional string, default:best match): Sort field (can be one of:createdorupdated).
- Required inputs:
-
list_repositories_issues: List issues from a repository.- Required inputs:
owner(string): The owner of the repository.repo(string): The repository name.page(optional number, default: 1): Page number for pagination.per_page(optional number, default: 30, max: 100): Number of results per page.direction(optional string, default:desc): Direction of sort (ascordesc).sort(optional string, default:created): Sort field (can be one of:created,commentsorupdated).since(optional string): Results last updated after the given time (ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.).labels(optional string): Comma separated label names. Example: bug,ui,@high.milestone(optional string): Milestone number.assignee(optional string): Name of assignee user (*for all).creator(optional string): The user that created the issue. (*for all).mentioned(optional string): A user that's mentioned in the issue.
- Required inputs:
-
get_issue: Get an issue from a repository.- Required inputs:
owner(string): The owner of the repository.repo(string): The repository name.issue_number(number): The issue number.
- Required inputs:
-
list_repositories_pull_requests: List pull requests from a repository.- Required inputs:
owner(string): The owner of the repository.repo(string): The repository name.page(optional number, default: 1): Page number for pagination.per_page(optional number, default: 30, max: 100): Number of results per page.direction(optional string, default:desc): Direction of sort (ascordesc).sort(optional string, default:created): Sort field (can be one of:created,popularity,long-runningorupdated).head(optional string): Filter pulls by head user or head organization and branch name in the format of user:ref-name or organization:ref-name (For example: github:new-script-format or octocat:test-branch).base(optional string): Filter pulls by base branch name. (For example: gh-pages).
- Required inputs:
-
get_pull_request: Get a pull request from a repository.- Required inputs:
owner(string): The owner of the repository.repo(string): The repository name.pull_request_number(number): The pull request number.
- Required inputs:
使用示例
一些你可以用来与Github交互的示例提示:
- "modelcontextprotocol" → 执行
search_repositories工具来查找提及了 modelcontextprotocol 的仓库。 - "What is the 739 issue on modelcontextprotocol servers repo" → 执行
get_issue工具从 modelcontextprotocol 服务器仓库中查找739号问题。 - "What is the 717 PR on modelcontextprotocol servers repo" → 执行
get_pull_request工具从 modelcontextprotocol 服务器仓库中查找717号拉取请求。
开发
- 安装依赖项:
pnpm install
- 在
.env文件中配置 Github 访问令牌:
GITHUB_PERSONAL_ACCESS_TOKEN=<your_personal_github_access_token>
- 本地运行并启用监视:
pnpm dev
- 构建服务器:
pnpm build
- 使用检查器进行本地调试:
pnpm inspector
服务配置
[{'mcpServers': {'github': {'args': ['-y', 'github-mcp-server'], 'command': 'npx', 'env': {'GITHUB_PERSONAL_ACCESS_TOKEN': 'your_personal_github_access_token'}}}}]
来源
- 来源:github
- 链接:https://github.com/ParasSolanki/github-mcp-server