586ac182df
Documentation Check / docs-check (push) Has been cancelled
Build and Test Go Project / build (macos-latest) (push) Has been cancelled
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Docker / build (push) Has been cancelled
Build and Test Go Project / build (ubuntu-latest) (push) Has been cancelled
Build and Test Go Project / build (windows-latest) (push) Has been cancelled
golangci-lint / lint (push) Has been cancelled
MCP Server Diff / mcp-diff (push) Has been cancelled
MCP Server Diff / mcp-diff-http (push) Has been cancelled
1670 lines
94 KiB
Markdown
1670 lines
94 KiB
Markdown
<!-- WEHUB_ZH_README -->
|
||
> [!NOTE]
|
||
> 本文档由 WeHub 基于上游 README 翻译整理,属于社区翻译,非官方中文文档。
|
||
> [English](./README.en.md) · [原始项目](https://github.com/github/github-mcp-server) · [上游 README](https://github.com/github/github-mcp-server/blob/HEAD/README.md)
|
||
> 原作者、版权与许可证归属以原始项目及本仓库 LICENSE 文件为准。
|
||
|
||
[](https://goreportcard.com/report/github.com/github/github-mcp-server)
|
||
|
||
# GitHub MCP Server
|
||
|
||
GitHub MCP Server 可将 AI 工具直接连接到 GitHub 平台。这使 AI 智能体(agent)、助手和聊天机器人能够读取仓库与代码文件、管理 issue 与 PR、分析代码并自动化工作流,全部通过自然语言交互完成。
|
||
|
||
### 使用场景
|
||
|
||
- 仓库管理:浏览和查询代码、搜索文件、分析提交,并了解你有权访问的任意仓库的项目结构。
|
||
- Issue 与 PR 自动化:创建、更新和管理 issue 与 pull request。让 AI 协助分类 bug、审查代码变更并维护项目看板。
|
||
- CI/CD 与工作流智能:监控 GitHub Actions 工作流运行、分析构建失败、管理发布,并深入了解你的开发流水线。
|
||
- 代码分析:检查安全发现、审查 Dependabot 告警、理解代码模式,并全面了解你的代码库。
|
||
- 团队协作:访问讨论、管理通知、分析团队活动,并为团队简化流程。
|
||
|
||
面向希望将 AI 工具连接到 GitHub 上下文与能力的开发者,从简单的自然语言查询到复杂的多步骤智能体工作流均可支持。
|
||
|
||
---
|
||
|
||
## 远程 GitHub MCP Server
|
||
|
||
[](https://insiders.vscode.dev/redirect/mcp/install?name=github&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2F%22%7D) [](https://insiders.vscode.dev/redirect/mcp/install?name=github&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2F%22%7D&quality=insiders) [](https://aka.ms/vs/mcp-install?%7B%22name%22%3A%22github%22%2C%22gallery%22%3Atrue%2C%22url%22%3A%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2F%22%7D)
|
||
|
||
远程 GitHub MCP Server 由 GitHub 托管,是上手运行最简便的方式。如果你的 MCP 宿主不支持远程 MCP 服务器,也不用担心!你可以改用[本地版 GitHub MCP Server](https://github.com/github/github-mcp-server?tab=readme-ov-file#local-github-mcp-server)。
|
||
|
||
### 前置条件
|
||
|
||
1. 支持远程服务器的兼容 MCP 宿主(VS Code 1.101+、Claude Desktop、Cursor、Windsurf 等)
|
||
2. 已启用所有适用的[策略](https://github.com/github/github-mcp-server/blob/main/docs/policies-and-governance.md)
|
||
|
||
### 在 VS Code 中安装
|
||
|
||
如需快速安装,请使用上方的一键安装按钮。完成该流程后,切换 Agent 模式(位于 Copilot Chat 文本输入框旁),服务器即可启动。请确保你使用的是 [VS Code 1.101](https://code.visualstudio.com/updates/v1_101) 或[更高版本](https://code.visualstudio.com/updates),以支持远程 MCP 与 OAuth。
|
||
|
||
或者,若要手动配置 VS Code,请从下方示例中选择合适的 JSON 代码块,并将其添加到你的宿主配置中:
|
||
|
||
<table>
|
||
<tr><th>使用 OAuth</th><th>使用 GitHub PAT</th></tr>
|
||
<tr><th align=left colspan=2>VS Code(1.101 或更高版本)</th></tr>
|
||
<tr valign=top>
|
||
<td>
|
||
|
||
```json
|
||
{
|
||
"servers": {
|
||
"github": {
|
||
"type": "http",
|
||
"url": "https://api.githubcopilot.com/mcp/"
|
||
}
|
||
}
|
||
}
|
||
```
|
||
|
||
</td>
|
||
<td>
|
||
|
||
```json
|
||
{
|
||
"servers": {
|
||
"github": {
|
||
"type": "http",
|
||
"url": "https://api.githubcopilot.com/mcp/",
|
||
"headers": {
|
||
"Authorization": "Bearer ${input:github_mcp_pat}"
|
||
}
|
||
}
|
||
},
|
||
"inputs": [
|
||
{
|
||
"type": "promptString",
|
||
"id": "github_mcp_pat",
|
||
"description": "GitHub Personal Access Token",
|
||
"password": true
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
|
||
### 在其他 MCP 宿主中安装
|
||
|
||
- **[Copilot CLI](/docs/installation-guides/install-copilot-cli.md)** - GitHub Copilot CLI 安装指南
|
||
- **[GitHub Copilot in other IDEs](/docs/installation-guides/install-other-copilot-ides.md)** - 在 JetBrains、Visual Studio、Eclipse 和 Xcode 中安装 GitHub Copilot
|
||
- **[Claude Applications](/docs/installation-guides/install-claude.md)** - Claude Desktop 与 Claude Code CLI 安装指南
|
||
- **[Codex](/docs/installation-guides/install-codex.md)** - OpenAI Codex 安装指南
|
||
- **[Cursor](/docs/installation-guides/install-cursor.md)** - Cursor IDE 安装指南
|
||
- **[OpenCode](/docs/installation-guides/install-opencode.md)** - OpenCode 终端智能体安装指南
|
||
- **[Windsurf](/docs/installation-guides/install-windsurf.md)** - Windsurf IDE 安装指南
|
||
- **[Zed](/docs/installation-guides/install-zed.md)** - Zed 编辑器安装指南
|
||
- **[Rovo Dev CLI](/docs/installation-guides/install-rovo-dev-cli.md)** - Rovo Dev CLI 安装指南
|
||
|
||
> **注意:** 每个 MCP 宿主应用都需要配置 GitHub App 或 OAuth App,以支持通过 OAuth 进行远程访问。任何支持远程 MCP 服务器的宿主应用都应支持使用 PAT 认证的远程 GitHub 服务器。配置细节与支持程度因宿主而异。请务必查阅宿主应用的文档以获取更多信息。
|
||
|
||
### 配置
|
||
|
||
#### 工具集配置
|
||
|
||
有关远程服务器配置、工具集、请求头及高级用法的完整说明,请参阅[远程服务器文档](docs/remote-server.md)。该文件提供了在 VS Code 及其他 MCP 宿主中连接、自定义和安装远程 GitHub MCP Server 的全面说明与示例。
|
||
|
||
未指定工具集时,将使用[默认工具集](#default-toolset)。
|
||
|
||
#### Insiders 模式
|
||
|
||
> **抢先体验新功能!** 远程服务器提供 insiders 版本,可提前访问新功能与实验性工具。
|
||
|
||
<table>
|
||
<tr><th>使用 URL 路径</th><th>使用 Header</th></tr>
|
||
<tr valign=top>
|
||
<td>
|
||
|
||
```json
|
||
{
|
||
"servers": {
|
||
"github": {
|
||
"type": "http",
|
||
"url": "https://api.githubcopilot.com/mcp/insiders"
|
||
}
|
||
}
|
||
}
|
||
```
|
||
|
||
</td>
|
||
<td>
|
||
|
||
```json
|
||
{
|
||
"servers": {
|
||
"github": {
|
||
"type": "http",
|
||
"url": "https://api.githubcopilot.com/mcp/",
|
||
"headers": {
|
||
"X-MCP-Insiders": "true"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
```
|
||
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
|
||
更多细节与示例请参阅[远程服务器文档](docs/remote-server.md#insiders-mode),可用功能完整列表请参阅 [Insiders Features](docs/insiders-features.md)。
|
||
|
||
#### GitHub Enterprise
|
||
|
||
##### 带数据驻留的 GitHub Enterprise Cloud(ghe.com)
|
||
|
||
带数据驻留的 GitHub Enterprise Cloud 也可使用远程服务器。
|
||
|
||
使用 GitHub PAT token 的 `https://octocorp.ghe.com` 示例:
|
||
|
||
```
|
||
{
|
||
...
|
||
"github-octocorp": {
|
||
"type": "http",
|
||
"url": "https://copilot-api.octocorp.ghe.com/mcp",
|
||
"headers": {
|
||
"Authorization": "Bearer ${input:github_mcp_pat}"
|
||
}
|
||
},
|
||
...
|
||
}
|
||
```
|
||
|
||
> **注意:** 在 VS Code 与 GitHub Copilot 中通过 OAuth 使用 GitHub Enterprise 时,你还需要配置 VS Code 设置以指向你的 GitHub Enterprise 实例——请参阅[从 VS Code 进行身份验证](https://docs.github.com/en/enterprise-cloud@latest/copilot/how-tos/configure-personal-settings/authenticate-to-ghecom)
|
||
|
||
##### GitHub Enterprise Server
|
||
|
||
GitHub Enterprise Server 不支持远程服务器托管。请参阅本地服务器配置中的 [GitHub Enterprise Server and Enterprise Cloud with data residency (ghe.com)](#github-enterprise-server-and-enterprise-cloud-with-data-residency-ghecom)。
|
||
|
||
---
|
||
|
||
## 本地 GitHub MCP Server
|
||
|
||
[](https://insiders.vscode.dev/redirect/mcp/install?name=github&config=%7B%22command%22%3A%22docker%22%2C%22args%22%3A%5B%22run%22%2C%22-i%22%2C%22--rm%22%2C%22-p%22%2C%22127.0.0.1%3A8085%3A8085%22%2C%22-e%22%2C%22GITHUB_OAUTH_CALLBACK_PORT%22%2C%22ghcr.io%2Fgithub%2Fgithub-mcp-server%22%5D%2C%22env%22%3A%7B%22GITHUB_OAUTH_CALLBACK_PORT%22%3A%228085%22%7D%7D) [](https://insiders.vscode.dev/redirect/mcp/install?name=github&config=%7B%22command%22%3A%22docker%22%2C%22args%22%3A%5B%22run%22%2C%22-i%22%2C%22--rm%22%2C%22-p%22%2C%22127.0.0.1%3A8085%3A8085%22%2C%22-e%22%2C%22GITHUB_OAUTH_CALLBACK_PORT%22%2C%22ghcr.io%2Fgithub%2Fgithub-mcp-server%22%5D%2C%22env%22%3A%7B%22GITHUB_OAUTH_CALLBACK_PORT%22%3A%228085%22%7D%7D&quality=insiders) [](https://aka.ms/vs/mcp-install?%7B%22name%22%3A%22github%22%2C%22command%22%3A%22docker%22%2C%22args%22%3A%5B%22run%22%2C%22-i%22%2C%22--rm%22%2C%22-p%22%2C%22127.0.0.1%3A8085%3A8085%22%2C%22-e%22%2C%22GITHUB_OAUTH_CALLBACK_PORT%3D8085%22%2C%22ghcr.io%2Fgithub%2Fgithub-mcp-server%22%5D%7D)
|
||
|
||
### 前置条件
|
||
|
||
1. 若要在容器中运行服务器,你需要已安装 [Docker](https://www.docker.com/)。
|
||
2. 安装 Docker 后,还需确保 Docker 正在运行。Docker 镜像位于 `ghcr.io/github/github-mcp-server`。该镜像为公开镜像;若拉取时出现错误,可能是 token 已过期,需要 `docker logout ghcr.io`。
|
||
3. **身份验证。** 在 github.com 上,你无需预先创建任何内容——上方的一键按钮会在首次使用时通过 OAuth 登录(基于浏览器的流程;token 仅保存在内存中)。Docker 按钮会发布固定的回调端口(`127.0.0.1:8085`),以便容器内的登录回调可被访问。请参阅 **[本地服务器 OAuth 登录](docs/oauth-login.md)**,了解其工作原理、无界面/设备码(device-code)回退方案,以及如何自带 OAuth 或 GitHub App(GitHub Enterprise Server 和 `ghe.com` 需要此项)。
|
||
|
||
更喜欢使用 token?你仍可通过设置 `GITHUB_PERSONAL_ACCESS_TOKEN` 来使用 [GitHub Personal Access Token](https://github.com/settings/personal-access-tokens/new) 进行身份验证(其优先级高于 OAuth)。MCP 服务器可使用众多 GitHub API,因此请启用你愿意授予 AI 工具的权限(要了解更多关于访问 token 的信息,请参阅 [文档](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)).
|
||
|
||
<details><summary><b>安全处理 PAT</b></summary>
|
||
|
||
### 环境变量(推荐)
|
||
|
||
为在多个 MCP 主机之间安全、可复用地保存 GitHub PAT:
|
||
|
||
1. **将 PAT 存储在环境变量中**
|
||
|
||
```bash
|
||
export GITHUB_PAT=your_token_here
|
||
```
|
||
|
||
或创建 `.env` 文件:
|
||
|
||
```env
|
||
GITHUB_PAT=your_token_here
|
||
```
|
||
|
||
2. **保护你的 `.env` 文件**
|
||
|
||
```bash
|
||
# Add to .gitignore to prevent accidental commits
|
||
echo ".env" >> .gitignore
|
||
```
|
||
|
||
3. **在配置中引用 token**
|
||
|
||
```bash
|
||
# CLI usage
|
||
claude mcp add github -e GITHUB_PERSONAL_ACCESS_TOKEN=$GITHUB_PAT -- docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN ghcr.io/github/github-mcp-server
|
||
|
||
# In config files (where supported)
|
||
"env": {
|
||
"GITHUB_PERSONAL_ACCESS_TOKEN": "$GITHUB_PAT"
|
||
}
|
||
```
|
||
|
||
> **注意**:各主机应用和 IDE 对环境变量的支持程度不同。部分应用(如 Windsurf)要求在配置文件中硬编码 token。
|
||
|
||
### Token 安全最佳实践
|
||
|
||
- **最小权限范围**:仅授予必要权限
|
||
- `repo` - 仓库操作
|
||
- `read:packages` - Docker 镜像访问
|
||
- `read:org` - 组织团队访问
|
||
- **分离 token**:为不同项目/环境使用不同的 PAT
|
||
- **定期轮换**:定期更新 token
|
||
- **切勿提交**:不要将 token 纳入版本控制
|
||
- **文件权限**:限制对包含 token 的配置文件的访问
|
||
|
||
```bash
|
||
chmod 600 ~/.your-app/config.json
|
||
```
|
||
|
||
</details>
|
||
|
||
### GitHub Enterprise Server 与带数据驻留的 Enterprise Cloud(ghe.com)
|
||
|
||
标志 `--gh-host` 和环境变量 `GITHUB_HOST` 可用于设置
|
||
GitHub Enterprise Server 或带数据驻留的 GitHub Enterprise Cloud 的主机名。
|
||
|
||
- 对于 GitHub Enterprise Server,请在主机名前添加 `https://` URI 方案,否则默认使用 `http://`,而 GitHub Enterprise Server 不支持该方案。
|
||
- 对于带数据驻留的 GitHub Enterprise Cloud,请使用 `https://YOURSUBDOMAIN.ghe.com` 作为主机名。
|
||
|
||
``` json
|
||
"github": {
|
||
"command": "docker",
|
||
"args": [
|
||
"run",
|
||
"-i",
|
||
"--rm",
|
||
"-e",
|
||
"GITHUB_PERSONAL_ACCESS_TOKEN",
|
||
"-e",
|
||
"GITHUB_HOST",
|
||
"ghcr.io/github/github-mcp-server"
|
||
],
|
||
"env": {
|
||
"GITHUB_PERSONAL_ACCESS_TOKEN": "${input:github_token}",
|
||
"GITHUB_HOST": "https://<your GHES or ghe.com domain name>"
|
||
}
|
||
}
|
||
```
|
||
|
||
## 安装
|
||
|
||
### 在 VS Code 的 GitHub Copilot 中安装
|
||
|
||
如需快速安装,请使用上方的一键安装按钮。完成该流程后,切换 Agent 模式(位于 Copilot Chat 文本输入框旁),服务器即可启动。
|
||
|
||
有关在 VS Code 的 agent 模式中使用 MCP 服务器工具的更多信息,请参阅 [agent 模式文档](https://code.visualstudio.com/docs/copilot/chat/mcp-servers).
|
||
|
||
在 GitHub Copilot 的其他 IDE 中安装(JetBrains、Visual Studio、Eclipse 等)
|
||
|
||
将以下 JSON 块之一添加到你 IDE 的 MCP 设置中。
|
||
|
||
**使用 OAuth 登录(无需创建或存储 token)。** 在 github.com 上,官方镜像已包含应用凭据,因此你无需自行提供:首次使用时会运行基于浏览器的登录,并将生成的 token **仅保存在内存中**。在 Docker 中,需要将固定的回调端口发布到 loopback,以便容器内的登录回调可被访问:
|
||
|
||
```json
|
||
{
|
||
"mcp": {
|
||
"servers": {
|
||
"github": {
|
||
"command": "docker",
|
||
"args": [
|
||
"run",
|
||
"-i",
|
||
"--rm",
|
||
"-p",
|
||
"127.0.0.1:8085:8085",
|
||
"-e",
|
||
"GITHUB_OAUTH_CALLBACK_PORT",
|
||
"ghcr.io/github/github-mcp-server"
|
||
],
|
||
"env": {
|
||
"GITHUB_OAUTH_CALLBACK_PORT": "8085"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
```
|
||
|
||
请参阅 **[本地服务器 OAuth 登录](docs/oauth-login.md)**,了解原生二进制流程(无需固定端口)、无界面/设备码回退方案、GitHub Enterprise Server / `ghe.com`,以及如何自带 OAuth 或 GitHub App。
|
||
|
||
**或使用个人访问令牌(Personal Access Token)进行身份验证。** 改为设置 `GITHUB_PERSONAL_ACCESS_TOKEN`(其优先级高于 OAuth):
|
||
|
||
```json
|
||
{
|
||
"mcp": {
|
||
"inputs": [
|
||
{
|
||
"type": "promptString",
|
||
"id": "github_token",
|
||
"description": "GitHub Personal Access Token",
|
||
"password": true
|
||
}
|
||
],
|
||
"servers": {
|
||
"github": {
|
||
"command": "docker",
|
||
"args": [
|
||
"run",
|
||
"-i",
|
||
"--rm",
|
||
"-e",
|
||
"GITHUB_PERSONAL_ACCESS_TOKEN",
|
||
"ghcr.io/github/github-mcp-server"
|
||
],
|
||
"env": {
|
||
"GITHUB_PERSONAL_ACCESS_TOKEN": "${input:github_token}"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
```
|
||
|
||
你也可以选择将类似示例(即不含 mcp 键)添加到工作区中名为 `.vscode/mcp.json` 的文件。这样即可与接受相同格式的其他主机应用共享配置。
|
||
|
||
<details>
|
||
<summary><b>不含 MCP 键的示例 JSON 块</b></summary>
|
||
<br>
|
||
|
||
```json
|
||
{
|
||
"inputs": [
|
||
{
|
||
"type": "promptString",
|
||
"id": "github_token",
|
||
"description": "GitHub Personal Access Token",
|
||
"password": true
|
||
}
|
||
],
|
||
"servers": {
|
||
"github": {
|
||
"command": "docker",
|
||
"args": [
|
||
"run",
|
||
"-i",
|
||
"--rm",
|
||
"-e",
|
||
"GITHUB_PERSONAL_ACCESS_TOKEN",
|
||
"ghcr.io/github/github-mcp-server"
|
||
],
|
||
"env": {
|
||
"GITHUB_PERSONAL_ACCESS_TOKEN": "${input:github_token}"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
```
|
||
|
||
</details>
|
||
|
||
### 在其他 MCP 主机中安装
|
||
|
||
对于其他 MCP 主机应用,请参阅我们的安装指南:
|
||
|
||
- **[Copilot CLI](docs/installation-guides/install-copilot-cli.md)** - GitHub Copilot CLI 安装指南
|
||
- **[GitHub Copilot in other IDEs](/docs/installation-guides/install-other-copilot-ides.md)** - 在 JetBrains、Visual Studio、Eclipse 和 Xcode 中使用 GitHub Copilot 的安装说明
|
||
- **[Claude Code & Claude Desktop](docs/installation-guides/install-claude.md)** - Claude Code 与 Claude Desktop 安装指南
|
||
- **[Cursor](docs/installation-guides/install-cursor.md)** - Cursor IDE 安装指南
|
||
- **[Google Gemini CLI](docs/installation-guides/install-gemini-cli.md)** - Google Gemini CLI 安装指南
|
||
- **[OpenCode](docs/installation-guides/install-opencode.md)** - OpenCode 终端代理安装指南
|
||
- **[Windsurf](docs/installation-guides/install-windsurf.md)** - Windsurf IDE 安装指南
|
||
- **[Zed](docs/installation-guides/install-zed.md)** - Zed 编辑器安装指南
|
||
|
||
如需全面了解所有安装选项,请参阅我们的 **[安装指南索引](docs/installation-guides)**。
|
||
|
||
> **注意:** 任何支持本地 MCP 服务器的宿主应用(host application)都应能访问本地 GitHub MCP 服务器。不过,集成的具体配置流程、语法和稳定性会因宿主应用而异。虽然许多应用可能遵循与上文示例类似的格式,但这并不保证一致。请参阅宿主应用的文档,了解正确的 MCP 配置语法和设置流程。
|
||
|
||
### 从源码构建
|
||
|
||
如果你没有 Docker,可以使用 `go build` 在 `cmd/github-mcp-server` 目录中构建二进制文件,并使用 `github-mcp-server stdio` 命令,同时将 `GITHUB_PERSONAL_ACCESS_TOKEN` 环境变量设置为你的 token。若要指定构建输出位置,请使用 `-o` 标志。你应将服务器配置为使用构建生成的可执行文件作为其 `command`。例如:
|
||
|
||
```JSON
|
||
{
|
||
"mcp": {
|
||
"servers": {
|
||
"github": {
|
||
"command": "/path/to/github-mcp-server",
|
||
"args": ["stdio"],
|
||
"env": {
|
||
"GITHUB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
```
|
||
|
||
### CLI 实用工具
|
||
|
||
`github-mcp-server` 二进制文件包含一些有助于调试和探索服务器的 CLI 子命令。
|
||
|
||
- `github-mcp-server tool-search "<query>"` 可按名称、描述和输入参数名称搜索工具。使用 `--max-results` 可返回更多匹配结果。
|
||
示例(彩色输出需要 TTY;在 Docker 中运行时请使用 `docker run -t`(或 `-it`)):
|
||
```bash
|
||
docker run -it --rm ghcr.io/github/github-mcp-server tool-search "issue" --max-results 5
|
||
github-mcp-server tool-search "issue" --max-results 5
|
||
```
|
||
|
||
## 工具配置
|
||
|
||
GitHub MCP Server 支持通过 `--toolsets` 标志启用或禁用特定功能组。这使你能够控制哪些 GitHub API 能力可供 AI 工具使用。仅启用所需 toolset 有助于 LLM 进行工具选择并减少上下文大小。
|
||
|
||
_工具集(toolsets)不仅限于工具(Tools)。在适用情况下,相关的 MCP 资源(Resources)和提示(Prompts)也会一并包含。_
|
||
|
||
未指定 toolset 时,将使用[默认 toolset](#default-toolset)。
|
||
|
||
> **需要示例?** 请参阅[服务器配置指南](./docs/server-configuration.md),其中包含常见方案,例如最小化配置、只读模式,以及将 tools 与 toolsets 组合使用。
|
||
|
||
#### 指定 Toolsets
|
||
|
||
若要指定希望向 LLM 开放的 toolsets,可通过以下两种方式传入允许列表(allow-list):
|
||
|
||
1. **使用命令行参数**:
|
||
|
||
```bash
|
||
github-mcp-server --toolsets repos,issues,pull_requests,actions,code_security
|
||
```
|
||
|
||
2. **使用环境变量**:
|
||
|
||
```bash
|
||
GITHUB_TOOLSETS="repos,issues,pull_requests,actions,code_security" ./github-mcp-server
|
||
```
|
||
|
||
如果同时提供了环境变量和命令行参数,环境变量 `GITHUB_TOOLSETS` 优先于命令行参数。
|
||
|
||
#### 指定单个 Tools
|
||
|
||
你也可以使用 `--tools` 标志配置特定 tools。tools 可单独使用,也可与 toolsets 组合以实现细粒度控制。
|
||
|
||
1. **使用命令行参数**:
|
||
|
||
```bash
|
||
github-mcp-server --tools get_file_contents,issue_read,create_pull_request
|
||
```
|
||
|
||
2. **使用环境变量**:
|
||
|
||
```bash
|
||
GITHUB_TOOLS="get_file_contents,issue_read,create_pull_request" ./github-mcp-server
|
||
```
|
||
|
||
3. **与 Toolsets 组合**(累加):
|
||
|
||
```bash
|
||
github-mcp-server --toolsets repos,issues --tools get_gist
|
||
```
|
||
|
||
这将注册 `repos` 和 `issues` toolsets 中的所有 tools,以及 `get_gist`。
|
||
|
||
**重要说明:**
|
||
|
||
- tools 和 toolsets 可同时使用
|
||
- 只读模式优先:如果设置了 `--read-only`,写入类 tools 将被跳过,即使通过 `--tools` 显式请求也是如此
|
||
- tool 名称必须完全匹配(例如 `get_file_contents`,而不是 `getFileContents`)。无效的 tool 名称会导致服务器在启动时失败并显示错误信息
|
||
- 当 tools 重命名时,旧名称会作为别名保留以保持向后兼容。详见 [Tool 重命名](docs/tool-renaming.md)。
|
||
|
||
### 在 Docker 中使用 Toolsets
|
||
|
||
使用 Docker 时,可将 toolsets 作为环境变量传入:
|
||
|
||
```bash
|
||
docker run -i --rm \
|
||
-e GITHUB_PERSONAL_ACCESS_TOKEN=<your-token> \
|
||
-e GITHUB_TOOLSETS="repos,issues,pull_requests,actions,code_security" \
|
||
ghcr.io/github/github-mcp-server
|
||
```
|
||
|
||
### 在 Docker 中使用 Tools
|
||
|
||
使用 Docker 时,可将特定 tools 作为环境变量传入。你也可以将 tools 与 toolsets 组合使用:
|
||
|
||
```bash
|
||
# Tools only
|
||
docker run -i --rm \
|
||
-e GITHUB_PERSONAL_ACCESS_TOKEN=<your-token> \
|
||
-e GITHUB_TOOLS="get_file_contents,issue_read,create_pull_request" \
|
||
ghcr.io/github/github-mcp-server
|
||
|
||
# Tools combined with toolsets (additive)
|
||
docker run -i --rm \
|
||
-e GITHUB_PERSONAL_ACCESS_TOKEN=<your-token> \
|
||
-e GITHUB_TOOLSETS="repos,issues" \
|
||
-e GITHUB_TOOLS="get_gist" \
|
||
ghcr.io/github/github-mcp-server
|
||
```
|
||
|
||
### 特殊 toolsets
|
||
|
||
#### "all" toolset
|
||
|
||
可提供特殊 toolset `all`,以启用所有可用 toolsets,不受其他配置影响:
|
||
|
||
```bash
|
||
./github-mcp-server --toolsets all
|
||
```
|
||
|
||
或使用环境变量:
|
||
|
||
```bash
|
||
GITHUB_TOOLSETS="all" ./github-mcp-server
|
||
```
|
||
|
||
#### "default" toolset
|
||
|
||
默认 toolset `default` 是在未指定任何 toolsets 时传给服务器的配置。
|
||
|
||
默认配置为:
|
||
|
||
- context
|
||
- repos
|
||
- issues
|
||
- pull_requests
|
||
- users
|
||
|
||
在保留默认配置的同时添加更多 toolsets:
|
||
|
||
```bash
|
||
GITHUB_TOOLSETS="default,stargazers" ./github-mcp-server
|
||
```
|
||
|
||
### Insiders 模式
|
||
|
||
本地 GitHub MCP Server 提供 insiders 版本,可抢先体验新功能和实验性 tools。
|
||
|
||
1. **使用命令行参数**:
|
||
|
||
```bash
|
||
./github-mcp-server --insiders
|
||
```
|
||
|
||
2. **使用环境变量**:
|
||
|
||
```bash
|
||
GITHUB_INSIDERS=true ./github-mcp-server
|
||
```
|
||
|
||
使用 Docker 时:
|
||
|
||
```bash
|
||
docker run -i --rm \
|
||
-e GITHUB_PERSONAL_ACCESS_TOKEN=<your-token> \
|
||
-e GITHUB_INSIDERS=true \
|
||
ghcr.io/github/github-mcp-server
|
||
```
|
||
|
||
### 可用 Toolsets
|
||
|
||
以下工具集可用:
|
||
|
||
<!-- START AUTOMATED TOOLSETS -->
|
||
| | Toolset | Description |
|
||
| --- | ----------------------- | ------------------------------------------------------------- |
|
||
| <picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/person-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/person-light.png"><img src="pkg/octicons/icons/person-light.png" width="20" height="20" alt="person"></picture> | `context` | **强烈建议启用**:提供当前用户及所处 GitHub 上下文相关信息的 tools |
|
||
| <picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/workflow-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/workflow-light.png"><img src="pkg/octicons/icons/workflow-light.png" width="20" height="20" alt="workflow"></picture> | `actions` | GitHub Actions 工作流及 CI/CD 操作 |
|
||
| <picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/code-square-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/code-square-light.png"><img src="pkg/octicons/icons/code-square-light.png" width="20" height="20" alt="code-square"></picture> | `code_quality` | GitHub Code Quality 相关 tools |
|
||
| <picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/codescan-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/codescan-light.png"><img src="pkg/octicons/icons/codescan-light.png" width="20" height="20" alt="codescan"></picture> | `code_security` | 代码安全相关 tools,例如 GitHub Code Scanning |
|
||
| <picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/copilot-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/copilot-light.png"><img src="pkg/octicons/icons/copilot-light.png" width="20" height="20" alt="copilot"></picture> | `copilot` | Copilot 相关 tools |
|
||
| <picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/dependabot-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/dependabot-light.png"><img src="pkg/octicons/icons/dependabot-light.png" width="20" height="20" alt="dependabot"></picture> | `dependabot` | Dependabot tools |
|
||
| <picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/comment-discussion-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/comment-discussion-light.png"><img src="pkg/octicons/icons/comment-discussion-light.png" width="20" height="20" alt="comment-discussion"></picture> | `discussions` | GitHub Discussions 相关 tools |
|
||
| <picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/logo-gist-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/logo-gist-light.png"><img src="pkg/octicons/icons/logo-gist-light.png" width="20" height="20" alt="logo-gist"></picture> | `gists` | GitHub Gist 相关 tools |
|
||
| <picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/git-branch-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/git-branch-light.png"><img src="pkg/octicons/icons/git-branch-light.png" width="20" height="20" alt="git-branch"></picture> | `git` | 用于底层 Git 操作的 GitHub Git API 相关 tools |
|
||
| <picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/issue-opened-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/issue-opened-light.png"><img src="pkg/octicons/icons/issue-opened-light.png" width="20" height="20" alt="issue-opened"></picture> | `issues` | GitHub Issues 相关 tools |
|
||
| <picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/tag-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/tag-light.png"><img src="pkg/octicons/icons/tag-light.png" width="20" height="20" alt="tag"></picture> | `labels` | GitHub Labels 相关 tools |
|
||
| <picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/bell-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/bell-light.png"><img src="pkg/octicons/icons/bell-light.png" width="20" height="20" alt="bell"></picture> | `notifications` | GitHub Notifications 相关 tools |
|
||
| <picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/organization-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/organization-light.png"><img src="pkg/octicons/icons/organization-light.png" width="20" height="20" alt="organization"></picture> | `orgs` | GitHub Organization 相关 tools |
|
||
| <picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/project-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/project-light.png"><img src="pkg/octicons/icons/project-light.png" width="20" height="20" alt="project"></picture> | `projects` | GitHub Projects 相关 tools |
|
||
| <picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/git-pull-request-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/git-pull-request-light.png"><img src="pkg/octicons/icons/git-pull-request-light.png" width="20" height="20" alt="git-pull-request"></picture> | `pull_requests` | GitHub Pull Request 相关 tools |
|
||
| <picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/repo-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/repo-light.png"><img src="pkg/octicons/icons/repo-light.png" width="20" height="20" alt="repo"></picture> | `repos` | GitHub Repository 相关 tools |
|
||
| <picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/shield-lock-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/shield-lock-light.png"><img src="pkg/octicons/icons/shield-lock-light.png" width="20" height="20" alt="shield-lock"></picture> | `secret_protection` | 密钥保护相关 tools,例如 GitHub Secret Scanning |
|
||
| <picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/shield-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/shield-light.png"><img src="pkg/octicons/icons/shield-light.png" width="20" height="20" alt="shield"></picture> | `security_advisories` | 安全公告相关 tools |
|
||
| <picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/star-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/star-light.png"><img src="pkg/octicons/icons/star-light.png" width="20" height="20" alt="star"></picture> | `stargazers` | GitHub Stargazers 相关 tools |
|
||
| <picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/people-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/people-light.png"><img src="pkg/octicons/icons/people-light.png" width="20" height="20" alt="people"></picture> | `users` | GitHub User 相关 tools |
|
||
<!-- END AUTOMATED TOOLSETS -->
|
||
|
||
### 远程 GitHub MCP Server 中的其他工具集
|
||
|
||
| Toolset | Description |
|
||
| ----------------------- | ------------------------------------------------------------- |
|
||
| `copilot` | Copilot 相关工具(例如 Copilot Coding Agent) |
|
||
| `copilot_spaces` | Copilot Spaces 相关工具 |
|
||
| `github_support_docs_search` | 搜索文档以回答 GitHub 产品与支持问题 |
|
||
|
||
## 工具
|
||
|
||
<!-- START AUTOMATED TOOLS -->
|
||
<details>
|
||
|
||
<summary><picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/workflow-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/workflow-light.png"><img src="pkg/octicons/icons/workflow-light.png" width="20" height="20" alt="workflow"></picture> Actions</summary>
|
||
|
||
- **actions_get** - 获取 GitHub Actions 资源(工作流、工作流运行、作业和构件)的详情
|
||
- **必需的 OAuth 作用域**:`repo`
|
||
- `method`:要执行的方法(string,必填)
|
||
- `owner`:仓库所有者(string,必填)
|
||
- `repo`:仓库名称(string,必填)
|
||
- `resource_id`:资源的唯一标识符。该值会因所提供的 "method" 而异,因此请确保提供正确的 ID:
|
||
- 对于 `get_workflow` 方法,请提供工作流 ID 或工作流文件名(例如 `ci.yaml`)。
|
||
- 对于 `get_workflow_run`、`get_workflow_run_usage` 和 `get_workflow_run_logs_url` 方法,请提供工作流运行 ID。
|
||
- 对于 `download_workflow_run_artifact` 方法,请提供构件 ID。
|
||
- 对于 `get_workflow_job` 方法,请提供作业 ID。
|
||
(string,必填)
|
||
|
||
- **actions_list** - 列出仓库中的 GitHub Actions 工作流
|
||
- **必需的 OAuth 作用域**:`repo`
|
||
- `method`:要执行的操作(string,必填)
|
||
- `owner`:仓库所有者(string,必填)
|
||
- `page`:分页页码(默认:1)(number,可选)
|
||
- `per_page`:每页结果数(默认:30,最大:100)(number,可选)
|
||
- `repo`:仓库名称(string,必填)
|
||
- `resource_id`:资源的唯一标识符。该值会因所提供的 "method" 而异,因此请确保提供正确的 ID:
|
||
- 对于 `list_workflows` 方法,请勿提供任何资源 ID。
|
||
- 对于 `list_workflow_runs` 方法,请提供工作流 ID 或工作流文件名(例如 `ci.yaml`),或省略以列出仓库中的所有工作流运行。
|
||
- 对于 `list_workflow_jobs` 和 `list_workflow_run_artifacts` 方法,请提供工作流运行 ID。
|
||
(string,可选)
|
||
- `workflow_jobs_filter`:工作流作业的筛选条件。**仅**在 method 为 `list_workflow_jobs` 时使用(object,可选)
|
||
- `workflow_runs_filter`:工作流运行的筛选条件。**仅**在 method 为 `list_workflow_runs` 时使用(object,可选)
|
||
|
||
- **actions_run_trigger** - 触发 GitHub Actions 工作流操作
|
||
- **必需的 OAuth 作用域**:`repo`
|
||
- `inputs`:工作流接受的输入参数。仅用于 `run_workflow` 方法。(object,可选)
|
||
- `method`:要执行的方法(string,必填)
|
||
- `owner`:仓库所有者(string,必填)
|
||
- `ref`:工作流的 Git 引用。引用可以是分支或标签名称。`run_workflow` 方法必填。(string,可选)
|
||
- `repo`:仓库名称(string,必填)
|
||
- `run_id`:工作流运行的 ID。除 `run_workflow` 外的所有方法均必填。(number,可选)
|
||
- `workflow_id`:工作流 ID(数字)或工作流文件名(例如 `main.yml`、`ci.yaml`)。`run_workflow` 方法必填。(string,可选)
|
||
|
||
- **get_job_logs** - 获取 GitHub Actions 工作流作业日志
|
||
- **必需的 OAuth 作用域**:`repo`
|
||
- `failed_only`:为 true 时,获取由 run_id 指定的工作流运行中所有失败作业的日志。必须提供 run_id。(boolean,可选)
|
||
- `job_id`:工作流作业的唯一标识符。获取单个作业日志时必填。(number,可选)
|
||
- `owner`:仓库所有者(string,必填)
|
||
- `repo`:仓库名称(string,必填)
|
||
- `return_content`:返回实际日志内容而非 URL(boolean,可选)
|
||
- `run_id`:工作流运行的唯一标识符。当 failed_only 为 true 以获取运行中所有失败作业日志时必填。(number,可选)
|
||
- `tail_lines`:从日志末尾返回的行数(number,可选)
|
||
|
||
</details>
|
||
|
||
<details>
|
||
|
||
<summary><picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/code-square-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/code-square-light.png"><img src="pkg/octicons/icons/code-square-light.png" width="20" height="20" alt="code-square"></picture> Code Quality</summary>
|
||
|
||
- **get_code_quality_finding** - 获取代码质量发现项
|
||
- **必需的 OAuth 作用域**:`repo`
|
||
- `findingNumber`:发现项编号。(number,必填)
|
||
- `owner`:仓库所有者。(string,必填)
|
||
- `repo`:仓库名称。(string,必填)
|
||
|
||
</details>
|
||
|
||
<details>
|
||
|
||
<summary><picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/codescan-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/codescan-light.png"><img src="pkg/octicons/icons/codescan-light.png" width="20" height="20" alt="codescan"></picture> Code Security</summary>
|
||
|
||
- **get_code_scanning_alert** - 获取代码扫描告警
|
||
- **必需的 OAuth 作用域**:`security_events`
|
||
- **可接受的 OAuth 作用域**:`repo`、`security_events`
|
||
- `alertNumber`:告警编号。(number,必填)
|
||
- `owner`:仓库所有者。(string,必填)
|
||
- `repo`:仓库名称。(string,必填)
|
||
|
||
- **list_code_scanning_alerts** - 列出代码扫描告警
|
||
- **必需的 OAuth 作用域**:`security_events`
|
||
- **可接受的 OAuth 作用域**:`repo`、`security_events`
|
||
- `owner`:仓库所有者。(string,必填)
|
||
- `page`:分页页码(最小 1)(number,可选)
|
||
- `perPage`:每页结果数(最小 1,最大 100)(number,可选)
|
||
- `ref`:要列出结果的 Git 引用。(string,可选)
|
||
- `repo`:仓库名称。(string,必填)
|
||
- `severity`:按严重程度筛选代码扫描告警(string,可选)
|
||
- `state`:按状态筛选代码扫描告警。默认为 open(string,可选)
|
||
- `tool_name`:用于代码扫描的工具名称。(string,可选)
|
||
|
||
</details>
|
||
|
||
<details>
|
||
|
||
<summary><picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/person-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/person-light.png"><img src="pkg/octicons/icons/person-light.png" width="20" height="20" alt="person"></picture> Context</summary>
|
||
|
||
- **get_me** - 获取我的用户资料
|
||
- 无需参数
|
||
|
||
- **get_team_members** - 获取团队成员
|
||
- **必需的 OAuth 作用域**:`read:org`
|
||
- **可接受的 OAuth 作用域**:`admin:org`、`read:org`、`write:org`
|
||
- `org`:包含该团队的组织登录名(所有者)。(string,必填)
|
||
- `team_slug`:团队 slug(string,必填)
|
||
|
||
- **get_teams** - 获取团队
|
||
- **必需的 OAuth 作用域**:`read:org`
|
||
- **可接受的 OAuth 作用域**:`admin:org`、`read:org`、`write:org`
|
||
- `user`:要获取其团队的用户名。如未提供,则使用已认证用户。(string,可选)
|
||
|
||
</details>
|
||
|
||
<details>
|
||
|
||
<summary><picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/copilot-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/copilot-light.png"><img src="pkg/octicons/icons/copilot-light.png" width="20" height="20" alt="copilot"></picture> Copilot</summary>
|
||
|
||
- **assign_copilot_to_issue** - 将 Copilot 分配给议题
|
||
- **必需的 OAuth 作用域**:`repo`
|
||
- `base_ref`:智能体将从此处开始工作的 Git 引用(例如分支)。如未指定,默认为仓库的默认分支(string,可选)
|
||
- `custom_instructions`:可选的自定义指令,用于在议题正文之外引导智能体。可用于提供议题描述中未包含的额外上下文、约束或指导(string,可选)
|
||
- `issue_number`:议题编号(number,必填)
|
||
- `owner`:仓库所有者(string,必填)
|
||
- `repo`:仓库名称(string,必填)
|
||
|
||
- **request_copilot_review** - 请求 Copilot 审查
|
||
- **Required OAuth Scopes**:`repo`
|
||
- `owner`:仓库所有者(string,必填)
|
||
- `pullNumber`:拉取请求编号(number,必填)
|
||
- `repo`:仓库名称(string,必填)
|
||
|
||
</details>
|
||
|
||
<details>
|
||
|
||
<summary><picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/dependabot-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/dependabot-light.png"><img src="pkg/octicons/icons/dependabot-light.png" width="20" height="20" alt="dependabot"></picture> Dependabot</summary>
|
||
|
||
- **get_dependabot_alert** - 获取 Dependabot 警报
|
||
- **Required OAuth Scopes**:`security_events`
|
||
- **Accepted OAuth Scopes**:`repo`、`security_events`
|
||
- `alertNumber`:警报编号。(number,必填)
|
||
- `owner`:仓库所有者。(string,必填)
|
||
- `repo`:仓库名称。(string,必填)
|
||
|
||
- **list_dependabot_alerts** - 列出 Dependabot 警报
|
||
- **Required OAuth Scopes**:`security_events`
|
||
- **Accepted OAuth Scopes**:`repo`、`security_events`
|
||
- `after`:分页游标。使用上一次响应中的游标。(string,可选)
|
||
- `owner`:仓库所有者。(string,必填)
|
||
- `perPage`:分页每页结果数(最小 1,最大 100)(number,可选)
|
||
- `repo`:仓库名称。(string,必填)
|
||
- `severity`:按严重程度筛选 Dependabot 警报(string,可选)
|
||
- `state`:按状态筛选 Dependabot 警报。默认为 open(string,可选)
|
||
|
||
</details>
|
||
|
||
<details>
|
||
|
||
<summary><picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/comment-discussion-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/comment-discussion-light.png"><img src="pkg/octicons/icons/comment-discussion-light.png" width="20" height="20" alt="comment-discussion"></picture> Discussions</summary>
|
||
|
||
- **discussion_comment_write** - 管理讨论评论
|
||
- **Required OAuth Scopes**:`repo`
|
||
- `body`:评论内容('add'、'reply' 和 'update' 方法必填)(string,可选)
|
||
- `commentNodeID`:讨论评论的 Node ID('reply'、'update'、'delete'、'mark_answer' 和 'unmark_answer' 方法必填)。对于 'reply',这是要回复的顶层评论;GitHub Discussions 仅支持一层嵌套。(string,可选)
|
||
- `discussionNumber`:讨论编号('add' 和 'reply' 方法必填)(number,可选)
|
||
- `method`:对讨论评论执行的写入操作。
|
||
选项包括:
|
||
- 'add' - 向讨论添加新的顶层评论。
|
||
- 'reply' - 回复顶层讨论评论(GitHub Discussions 仅支持一层嵌套)。
|
||
- 'update' - 更新现有讨论评论。
|
||
- 'delete' - 删除讨论评论。
|
||
- 'mark_answer' - 将讨论评论标记为答案(仅限 Q&A)。
|
||
- 'unmark_answer' - 取消将讨论评论标记为答案(仅限 Q&A)。
|
||
(string,必填)
|
||
- `owner`:仓库所有者('add' 和 'reply' 方法必填)(string,可选)
|
||
- `repo`:仓库名称('add' 和 'reply' 方法必填)(string,可选)
|
||
|
||
- **get_discussion** - 获取讨论
|
||
- **Required OAuth Scopes**:`repo`
|
||
- `discussionNumber`:讨论编号(number,必填)
|
||
- `owner`:仓库所有者(string,必填)
|
||
- `repo`:仓库名称(string,必填)
|
||
|
||
- **get_discussion_comments** - 获取讨论评论
|
||
- **Required OAuth Scopes**:`repo`
|
||
- `after`:分页游标。使用上一次响应中的游标。(string,可选)
|
||
- `discussionNumber`:讨论编号(number,必填)
|
||
- `includeReplies`:为 true 时,每个顶层评论将包含嵌套在内的回复(每个评论最多 100 条回复,这是 GitHub API 的上限)。默认为 false。(boolean,可选)
|
||
- `owner`:仓库所有者(string,必填)
|
||
- `perPage`:分页每页结果数(最小 1,最大 100)(number,可选)
|
||
- `repo`:仓库名称(string,必填)
|
||
|
||
- **list_discussion_categories** - 列出讨论分类
|
||
- **Required OAuth Scopes**:`repo`
|
||
- `owner`:仓库所有者(string,必填)
|
||
- `repo`:仓库名称。如未提供,将在组织级别查询讨论分类。(string,可选)
|
||
|
||
- **list_discussions** - 列出讨论
|
||
- **Required OAuth Scopes**:`repo`
|
||
- `after`:分页游标。使用上一次响应中的游标。(string,可选)
|
||
- `category`:按讨论分类 ID 可选筛选。如提供,则仅列出该分类下的讨论。(string,可选)
|
||
- `direction`:排序方向。(string,可选)
|
||
- `orderBy`:按字段对讨论排序。如提供,还需同时提供 'direction'。(string,可选)
|
||
- `owner`:仓库所有者(string,必填)
|
||
- `perPage`:分页每页结果数(最小 1,最大 100)(number,可选)
|
||
- `repo`:仓库名称。如未提供,将在组织级别查询讨论。(string,可选)
|
||
|
||
</details>
|
||
|
||
<details>
|
||
|
||
<summary><picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/logo-gist-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/logo-gist-light.png"><img src="pkg/octicons/icons/logo-gist-light.png" width="20" height="20" alt="logo-gist"></picture> Gists</summary>
|
||
|
||
- **create_gist** - 创建 Gist
|
||
- **Required OAuth Scopes**:`gist`
|
||
- `content`:用于简单单文件 Gist 创建的内容(string,必填)
|
||
- `description`:Gist 描述(string,可选)
|
||
- `filename`:用于简单单文件 Gist 创建的文件名(string,必填)
|
||
- `public`:Gist 是否为公开(boolean,可选)
|
||
|
||
- **get_gist** - 获取 Gist 内容
|
||
- `gist_id`:Gist 的 ID(string,必填)
|
||
|
||
- **list_gists** - 列出 Gist
|
||
- `page`:分页页码(最小 1)(number,可选)
|
||
- `perPage`:分页每页结果数(最小 1,最大 100)(number,可选)
|
||
- `since`:仅列出在此时间之后更新的 Gist(ISO 8601 时间戳)(string,可选)
|
||
- `username`:GitHub 用户名(省略则列出已认证用户的 Gist)(string,可选)
|
||
|
||
- **update_gist** - 更新 Gist
|
||
- **Required OAuth Scopes**:`gist`
|
||
- `content`:文件内容(string,必填)
|
||
- `description`:Gist 的更新描述(string,可选)
|
||
- `filename`:要更新或创建的文件名(string,必填)
|
||
- `gist_id`:要更新的 Gist ID(string,必填)
|
||
|
||
</details>
|
||
|
||
<details>
|
||
|
||
<summary><picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/git-branch-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/git-branch-light.png"><img src="pkg/octicons/icons/git-branch-light.png" width="20" height="20" alt="git-branch"></picture> Git</summary>
|
||
|
||
- **get_repository_tree** - 获取仓库树
|
||
- **Required OAuth Scopes**:`repo`
|
||
- `owner`:仓库所有者(用户名或组织)(string,必填)
|
||
- `path_filter`:用于筛选树结果的可选路径前缀(例如,'src/' 仅显示 src 目录中的文件)(string,可选)
|
||
- `recursive`:将此参数设为 true 时,返回树所引用的对象或子树。默认为 false(boolean,可选)
|
||
- `repo`:仓库名称(string,必填)
|
||
- `tree_sha`:树的 SHA1 值或 ref(分支或标签)名称。默认为仓库的默认分支(string,可选)
|
||
|
||
</details>
|
||
|
||
<details>
|
||
|
||
<summary><picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/issue-opened-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/issue-opened-light.png"><img src="pkg/octicons/icons/issue-opened-light.png" width="20" height="20" alt="issue-opened"></picture> Issues</summary>
|
||
|
||
- **add_issue_comment** - 为 Issue 或拉取请求添加评论
|
||
- **Required OAuth Scopes**:`repo`
|
||
- `body`:评论内容。除非提供了 reaction,否则必填。(string,可选)
|
||
- `comment_id`:要添加反应的 Issue 或拉取请求评论的数字 ID。用于对评论添加反应;省略则对 Issue 或拉取请求本身添加反应。不能与 body 同时使用。(number,可选)
|
||
- `issue_number`:要评论或添加反应的 Issue 或拉取请求编号。(number,必填)
|
||
- `owner`:仓库所有者(string,必填)
|
||
- `reaction`:要添加的表情符号反应。除非提供了 body,否则必填。(string,可选)
|
||
- `repo`:仓库名称(string,必填)
|
||
|
||
- **get_label** - 从仓库获取指定标签
|
||
- **Required OAuth Scopes**: `repo`
|
||
- `name`: 标签名称。(string, required)
|
||
- `owner`: 仓库所有者(用户名或组织名)(string, required)
|
||
- `repo`: 仓库名称 (string, required)
|
||
|
||
- **issue_read** - 获取 issue 详情
|
||
- **Required OAuth Scopes**: `repo`
|
||
- `issue_number`: issue 编号 (number, required)
|
||
- `method`: 对单个 issue 执行的读取操作。
|
||
选项包括:
|
||
1. get - 获取 issue 详情。还会尽力返回层级标志(`has_parent`、`has_children`);`parent` 和 `sub_issues_summary` 为可选的关系摘要。
|
||
2. get_comments - 获取 issue 评论。
|
||
3. get_sub_issues - 获取该 issue 的子 issue(children)。
|
||
4. get_parent - 若该 issue 是另一个 issue 的子 issue,则获取其父 issue。
|
||
5. get_labels - 获取分配给该 issue 的标签。
|
||
(string, required)
|
||
- `owner`: 仓库所有者 (string, required)
|
||
- `page`: 分页页码(最小为 1)(number, optional)
|
||
- `perPage`: 每页结果数(最小为 1,最大为 100)(number, optional)
|
||
- `repo`: 仓库名称 (string, required)
|
||
|
||
- **issue_write** - 创建或更新 issue/pull request
|
||
- **Required OAuth Scopes**: `repo`
|
||
- `assignees`: 要分配给该 issue 的用户名 (string[], optional)
|
||
- `body`: issue 正文内容 (string, optional)
|
||
- `duplicate_of`: 该 issue 所重复的 issue 编号。仅在 state_reason 为 'duplicate' 时使用。(number, optional)
|
||
- `issue_fields`: 要设置或清除的 issue 字段值。每项需要 'field_name',且 'value'、'field_option_name' 或 'delete: true' 三者必居其一。(object[], optional)
|
||
- `issue_number`: 要更新的 issue 编号 (number, optional)
|
||
- `labels`: 要应用到该 issue 的标签 (string[], optional)
|
||
- `method`: 对单个 issue 执行的写入操作。
|
||
选项包括:
|
||
- 'create' - 创建新 issue。
|
||
- 'update' - 更新现有 issue。
|
||
(string, required)
|
||
- `milestone`: 里程碑编号 (number, optional)
|
||
- `owner`: 仓库所有者 (string, required)
|
||
- `repo`: 仓库名称 (string, required)
|
||
- `state`: 新状态 (string, optional)
|
||
- `state_reason`: 状态变更原因。除非状态发生变更,否则会被忽略。(string, optional)
|
||
- `title`: issue 标题 (string, optional)
|
||
- `type`: 该 issue 的类型。仅在该仓库启用了 issue 类型时使用。使用 list_issue_types 工具获取该仓库或其所属组织的有效类型值。若仓库不支持 issue 类型,请省略此参数。(string, optional)
|
||
|
||
- **list_issue_fields** - 列出 issue 字段
|
||
- **Required OAuth Scopes (any of)**: `repo`, `read:org`
|
||
- **Accepted OAuth Scopes**: `admin:org`, `read:org`, `repo`, `write:org`
|
||
- `owner`: 仓库或组织的账户所有者。名称不区分大小写。(string, required)
|
||
- `repo`: 仓库名称。提供时,返回该特定仓库的字段(继承自其组织)。省略时,直接返回组织级字段。(string, optional)
|
||
|
||
- **list_issue_types** - 列出可用的 issue 类型
|
||
- **Required OAuth Scopes (any of)**: `repo`, `read:org`
|
||
- **Accepted OAuth Scopes**: `admin:org`, `read:org`, `repo`, `write:org`
|
||
- `owner`: 仓库或组织的账户所有者。(string, required)
|
||
- `repo`: 仓库名称。提供时,返回该特定仓库的 issue 类型。省略时,直接返回组织级 issue 类型。(string, optional)
|
||
|
||
- **list_issues** - 列出 issues
|
||
- **Required OAuth Scopes**: `repo`
|
||
- `after`: 分页游标。使用上一次响应中的 cursor。(string, optional)
|
||
- `direction`: 排序方向。若提供此参数,还需提供 'orderBy'。(string, optional)
|
||
- `field_filters`: 按自定义 issue 字段值筛选。每项包含 field_name 和 value;服务器会查找该字段并将 value 强制转换为其类型(单选选项名、文本、数字或 YYYY-MM-DD 日期)。(object[], optional)
|
||
- `labels`: 按标签筛选 (string[], optional)
|
||
- `orderBy`: 按字段对 issues 排序。若提供此参数,还需提供 'direction'。(string, optional)
|
||
- `owner`: 仓库所有者 (string, required)
|
||
- `perPage`: 每页结果数(最小为 1,最大为 100)(number, optional)
|
||
- `repo`: 仓库名称 (string, required)
|
||
- `since`: 按日期筛选(ISO 8601 时间戳)(string, optional)
|
||
- `state`: 按状态筛选;未提供时默认同时返回 open 和 closed issues (string, optional)
|
||
|
||
- **search_issues** - 搜索 issues
|
||
- **Required OAuth Scopes**: `repo`
|
||
- `order`: 排序顺序 (string, optional)
|
||
- `owner`: 可选的仓库所有者。若与 repo 一并提供,则仅列出该仓库的 issues。(string, optional)
|
||
- `page`: 分页页码(最小为 1)(number, optional)
|
||
- `perPage`: 每页结果数(最小为 1,最大为 100)(number, optional)
|
||
- `query`: 使用 GitHub issues 搜索语法的搜索查询 (string, required)
|
||
- `repo`: 可选的仓库名称。若与 owner 一并提供,则仅列出该仓库的 issues。(string, optional)
|
||
- `sort`: 按各类别匹配数量排序的字段,默认为最佳匹配 (string, optional)
|
||
|
||
- **sub_issue_write** - 变更子 issue
|
||
- **Required OAuth Scopes**: `repo`
|
||
- `after_id`: 子 issue 应排在之后的子 issue ID(应指定 after_id 或 before_id 之一)(number, optional)
|
||
- `before_id`: 子 issue 应排在之前的子 issue ID(应指定 after_id 或 before_id 之一)(number, optional)
|
||
- `issue_number`: 父 issue 编号 (number, required)
|
||
- `method`: 对单个子 issue 执行的操作
|
||
选项包括:
|
||
- 'add' - 在 GitHub 仓库中将子 issue 添加到父 issue。
|
||
- 'remove' - 在 GitHub 仓库中从父 issue 移除子 issue。
|
||
- 'reprioritize' - 在 GitHub 仓库中更改父 issue 内子 issue 的顺序。使用 'after_id' 或 'before_id' 指定新位置。
|
||
写入 issue 层级关系。若要将子 issue 移动到新的父 issue,请使用 `add` 配合 `replace_parent=true`;没有可写的 parent 字段。
|
||
(string, required)
|
||
- `owner`: 仓库所有者 (string, required)
|
||
- `replace_parent`: 为 true 时,替换子 issue 当前的父 issue。仅与 'add' 方法一起使用。(boolean, optional)
|
||
- `repo`: 仓库名称 (string, required)
|
||
- `sub_issue_id`: 要添加的子 issue ID。ID 与 issue 编号不同 (number, required)
|
||
|
||
</details>
|
||
|
||
<details>
|
||
|
||
<summary><picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/tag-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/tag-light.png"><img src="pkg/octicons/icons/tag-light.png" width="20" height="20" alt="tag"></picture> Labels</summary>
|
||
|
||
- **get_label** - 从仓库获取指定标签
|
||
- **Required OAuth Scopes**: `repo`
|
||
- `name`: 标签名称。(string, required)
|
||
- `owner`: 仓库所有者(用户名或组织名)(string, required)
|
||
- `repo`: 仓库名称 (string, required)
|
||
|
||
- **label_write** - 对仓库标签执行写入操作
|
||
- **Required OAuth Scopes**: `repo`
|
||
- `color`: 标签颜色,为不带 '#' 前缀的 6 位十六进制代码(例如 'f29513')。'create' 时必填,'update' 时可选。(string, optional)
|
||
- `description`: 标签描述文本。'create' 和 'update' 时可选。(string, optional)
|
||
- `method`: 要执行的操作:'create'、'update' 或 'delete' (string, required)
|
||
- `name`: 标签名称 - 所有操作均必填 (string, required)
|
||
- `new_name`: 标签的新名称(仅在与 'update' 方法一起使用时用于重命名)(string, optional)
|
||
- `owner`: 仓库所有者(用户名或组织名)(string, required)
|
||
- `repo`: 仓库名称 (string, required)
|
||
|
||
- **list_label** - 列出仓库中的标签
|
||
- **Required OAuth Scopes**: `repo`
|
||
- `owner`: 仓库所有者(用户名或组织名)- 所有操作均必填 (string, required)
|
||
- `repo`: 仓库名称 - 所有操作均必填 (string, required)
|
||
|
||
</details>
|
||
|
||
<details>
|
||
|
||
<summary><picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/bell-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/bell-light.png"><img src="pkg/octicons/icons/bell-light.png" width="20" height="20" alt="bell"></picture> 通知(Notifications)</summary>
|
||
|
||
- **dismiss_notification** - 关闭通知
|
||
- **Required OAuth Scopes**:`notifications`
|
||
- `state`:通知的新状态(read/done)(string,必填)
|
||
- `threadID`:通知线程的 ID(string,必填)
|
||
|
||
- **get_notification_details** - 获取通知详情
|
||
- **Required OAuth Scopes**:`notifications`
|
||
- `notificationID`:通知的 ID(string,必填)
|
||
|
||
- **list_notifications** - 列出通知
|
||
- **Required OAuth Scopes**:`notifications`
|
||
- `before`:仅显示在指定时间之前更新的通知(ISO 8601 格式)(string,可选)
|
||
- `filter`:过滤通知的范围,除非另有指定否则使用默认值。已读(Read)通知是指用户已确认的通知。参与(Participating)通知是指用户直接相关的通知,例如用户评论或创建的 issue 或 pull request。(string,可选)
|
||
- `owner`:可选的仓库所有者。若与 repo 一起提供,则仅列出该仓库的通知。(string,可选)
|
||
- `page`:分页页码(最小为 1)(number,可选)
|
||
- `perPage`:每页结果数(最小 1,最大 100)(number,可选)
|
||
- `repo`:可选的仓库名称。若与 owner 一起提供,则仅列出该仓库的通知。(string,可选)
|
||
- `since`:仅显示在指定时间之后更新的通知(ISO 8601 格式)(string,可选)
|
||
|
||
- **manage_notification_subscription** - 管理通知订阅
|
||
- **Required OAuth Scopes**:`notifications`
|
||
- `action`:要执行的操作:ignore(忽略)、watch(关注)或 delete(删除)该通知订阅。(string,必填)
|
||
- `notificationID`:通知线程的 ID。(string,必填)
|
||
|
||
- **manage_repository_notification_subscription** - 管理仓库通知订阅
|
||
- **Required OAuth Scopes**:`notifications`
|
||
- `action`:要执行的操作:ignore(忽略)、watch(关注)或 delete(删除)该仓库通知订阅。(string,必填)
|
||
- `owner`:仓库所属账户的所有者。(string,必填)
|
||
- `repo`:仓库名称。(string,必填)
|
||
|
||
- **mark_all_notifications_read** - 将所有通知标记为已读
|
||
- **Required OAuth Scopes**:`notifications`
|
||
- `lastReadAt`:描述上次检查通知的时间点(可选)。默认值:Now(string,可选)
|
||
- `owner`:可选的仓库所有者。若与 repo 一起提供,则仅将该仓库的通知标记为已读。(string,可选)
|
||
- `repo`:可选的仓库名称。若与 owner 一起提供,则仅将该仓库的通知标记为已读。(string,可选)
|
||
|
||
</details>
|
||
|
||
<details>
|
||
|
||
<summary><picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/organization-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/organization-light.png"><img src="pkg/octicons/icons/organization-light.png" width="20" height="20" alt="organization"></picture> 组织(Organizations)</summary>
|
||
|
||
- **search_orgs** - 搜索组织
|
||
- **Required OAuth Scopes**:`read:org`
|
||
- **Accepted OAuth Scopes**:`admin:org`、`read:org`、`write:org`
|
||
- `order`:排序顺序(string,可选)
|
||
- `page`:分页页码(最小为 1)(number,可选)
|
||
- `perPage`:每页结果数(最小 1,最大 100)(number,可选)
|
||
- `query`:组织搜索查询。示例:'microsoft'、'location:california'、'created:>=2025-01-01'。搜索会自动限定为 type:org。(string,必填)
|
||
- `sort`:按类别排序的字段(string,可选)
|
||
|
||
</details>
|
||
|
||
<details>
|
||
|
||
<summary><picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/project-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/project-light.png"><img src="pkg/octicons/icons/project-light.png" width="20" height="20" alt="project"></picture> 项目(Projects)</summary>
|
||
|
||
- **projects_get** - 获取 GitHub Projects 资源详情
|
||
- **Required OAuth Scopes**:`read:project`
|
||
- **Accepted OAuth Scopes**:`project`、`read:project`
|
||
- `field_id`:字段的 ID。'get_project_field' 方法必填。(number,可选)
|
||
- `field_names`:获取项目条目时要包含在响应中的字段名称列表(例如 ["Status", "Priority"])。由服务端解析为字段 ID——当你只知道人类可读名称时,请传此参数而非 'fields'。与 'fields' 互斥——二者只提供其一。仅用于 'get_project_item' 方法。(string[],可选)
|
||
- `fields`:获取项目条目时要包含在响应中的字段 ID 列表(例如 ["102589", "985201", "169875"])。若既未提供 'fields' 也未提供 'field_names',则仅包含标题字段。与 'field_names' 互斥——二者只提供其一。仅用于 'get_project_item' 方法。(string[],可选)
|
||
- `item_id`:条目的 ID。'get_project_item' 方法必填。(number,可选)
|
||
- `method`:要执行的方法(string,必填)
|
||
- `owner`:所有者(用户或组织登录名)。名称不区分大小写。(string,可选)
|
||
- `owner_type`:所有者类型(user 或 org)。若未提供,将自动检测。(string,可选)
|
||
- `project_number`:项目编号。(number,可选)
|
||
- `status_update_id`:项目状态更新的 node ID。'get_project_status_update' 方法必填。(string,可选)
|
||
|
||
- **projects_list** - 列出 GitHub Projects 资源
|
||
- **Required OAuth Scopes**:`read:project`
|
||
- **Accepted OAuth Scopes**:`project`、`read:project`
|
||
- `after`:来自上一页 pageInfo.nextCursor 的正向分页游标。(string,可选)
|
||
- `before`:来自上一页 pageInfo.prevCursor 的反向分页游标(较少使用)。(string,可选)
|
||
- `field_names`:列出项目条目时要包含的字段名称(例如 ["Status", "Priority"])。由服务端解析为字段 ID——当你只知道人类可读名称时,请传此参数而非 'fields'。无法解析的名称会返回结构化错误。与 'fields' 互斥——二者只提供其一。仅用于 'list_project_items' 方法。(string[],可选)
|
||
- `fields`:列出项目条目时要包含的字段 ID(例如 ["102589", "985201"])。重要:务必提供以获取字段值。若不提供此项(且不提供 'field_names'),则仅返回标题。与 'field_names' 互斥——二者只提供其一。仅用于 'list_project_items' 方法。(string[],可选)
|
||
- `method`:要执行的操作(string,必填)
|
||
- `owner`:所有者(用户或组织登录名)。名称不区分大小写。(string,必填)
|
||
- `owner_type`:所有者类型(user 或 org)。若未提供,将自动尝试两者。(string,可选)
|
||
- `per_page`:每页结果数(最大 50)(number,可选)
|
||
- `project_number`:项目编号。'list_project_fields'、'list_project_items' 和 'list_project_status_updates' 方法必填。(number,可选)
|
||
- `query`:过滤/查询字符串。对于 list_projects:按标题文本和状态过滤(例如 "roadmap is:open")。对于 list_project_items:使用 GitHub 项目过滤语法进行高级过滤。(string,可选)
|
||
|
||
- **projects_write** - 管理 GitHub Projects
|
||
- **Required OAuth Scopes**:`project`
|
||
- `body`:状态更新的正文(markdown)。用于 'create_project_status_update' 方法。(string,可选)
|
||
- `field_name`:迭代字段的名称(例如 'Sprint')。'create_iteration_field' 方法必填。(string,可选)
|
||
- `issue_number`:issue 编号。当 item_type 为 'issue' 时,'add_project_item' 必填。'update_project_item' 也接受此参数,用于通过 issue 编号解析条目(需与 item_owner 和 item_repo 组合使用)。(number,可选)
|
||
- `item_id`:项目条目 ID。'delete_project_item' 必填。对于 'update_project_item',请提供 item_id,或提供(item_owner + item_repo + issue_number)以通过 issue 解析条目。(number,可选)
|
||
- `item_owner`:包含该 issue 或 pull request 的仓库所有者(用户或组织)。'add_project_item' 方法必填。'update_project_item' 在通过 issue 编号解析条目时也接受此参数。(string,可选)
|
||
- `item_repo`:包含该 issue 或 pull request 的仓库名称。'add_project_item' 方法必填。'update_project_item' 在通过 issue 编号解析条目时也接受此参数。(string,可选)
|
||
- `item_type`:条目类型,为 issue 或 pull_request。'add_project_item' 方法必填。(string,可选)
|
||
- `iteration_duration`:该字段每次迭代的时长(天)(例如 7 表示每周,14 表示每两周)。'create_iteration_field' 方法必填。(number,可选)
|
||
- `iterations`:用于 'create_iteration_field' 方法的自定义迭代。仅在需要时长不等的迭代、迭代之间有间隔,或需要特定标题时设置。否则请省略:GitHub 会自动创建三个时长为 'iteration_duration' 天、从 'start_date' 开始的迭代,这对大多数场景都合适。(object[],可选)
|
||
- `method`:要执行的方法(string,必填)
|
||
- `owner`:项目所有者(用户或组织登录名)。名称不区分大小写。(string,必填)
|
||
- `owner_type`:所有者类型(user 或 org)。'create_project' 方法必填。其他方法若未提供,将自动检测。(string,可选)
|
||
- `project_number`:项目编号。除 'create_project' 外的所有方法均必填。(number,可选)
|
||
- `pull_request_number`:pull request 编号(当 item_type 为 'pull_request' 时用于 'add_project_item' 方法)。请提供 issue_number 或 pull_request_number 之一。(number,可选)
|
||
- `start_date`:开始日期,格式为 YYYY-MM-DD。用于 'create_project_status_update' 和 'create_iteration_field' 方法。(string,可选)
|
||
- `status`:项目状态。用于 'create_project_status_update' 方法。(string,可选)
|
||
- `target_date`:状态更新的目标日期,格式为 YYYY-MM-DD。用于 'create_project_status_update' 方法。(string,可选)
|
||
- `title`:项目标题。'create_project' 方法必填。(string,可选)
|
||
- `updated_field`:描述要更新的字段及其新值的对象。'update_project_item' 必填。接受两种形态:(1)按 ID——{"id": 123456, "value": "..."};(2)按名称——{"name": "Status", "value": "In Progress"}。对于单选字段,选项名称解析需要使用按名称的形态;在按 ID 的形态下,请传入选项 ID。将 value 设为 null 可清空该字段。(object,可选)
|
||
|
||
</details>
|
||
|
||
<details>
|
||
|
||
<summary><picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/git-pull-request-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/git-pull-request-light.png"><img src="pkg/octicons/icons/git-pull-request-light.png" width="20" height="20" alt="git-pull-request"></picture> Pull Requests(拉取请求)</summary>
|
||
|
||
- **add_comment_to_pending_review** - 向请求者最新的待处理拉取请求审查(pull request review)添加审查评论
|
||
- **Required OAuth Scopes(必需的 OAuth 作用域)**: `repo`
|
||
- `body`: 审查评论的文本(string,必填)
|
||
- `line`: 审查评论所针对的拉取请求 diff 中 blob 的行号。对于多行评论,为范围的最后一条行号(number,可选)
|
||
- `owner`: 仓库所有者(string,必填)
|
||
- `path`: 需要添加评论的文件的相对路径(string,必填)
|
||
- `pullNumber`: 拉取请求编号(number,必填)
|
||
- `repo`: 仓库名称(string,必填)
|
||
- `side`: 要评论的 diff 侧。LEFT 表示先前状态,RIGHT 表示新状态(string,可选)
|
||
- `startLine`: 对于多行评论,评论所适用范围的第一条行号(number,可选)
|
||
- `startSide`: 对于多行评论,评论所适用 diff 的起始侧。LEFT 表示先前状态,RIGHT 表示新状态(string,可选)
|
||
- `subjectType`: 评论所针对的层级(string,必填)
|
||
|
||
- **add_reply_to_pull_request_comment** - 为拉取请求评论添加回复
|
||
- **Required OAuth Scopes**: `repo`
|
||
- `body`: 回复文本。除非提供了 reaction,否则为必填项。(string,可选)
|
||
- `commentId`: 要回复或做出反应的拉取请求审查评论的数字 ID。请使用 #discussion_r... 锚点中的编号,而非 GraphQL 线程节点 ID(PRRT_...)。(number,必填)
|
||
- `owner`: 仓库所有者(string,必填)
|
||
- `pullNumber`: 拉取请求编号。提供 body 时为必填项。(number,可选)
|
||
- `reaction`: 要添加的表情符号反应(emoji reaction)。除非提供了 body,否则为必填项。(string,可选)
|
||
- `repo`: 仓库名称(string,必填)
|
||
|
||
- **create_pull_request** - 打开新的拉取请求
|
||
- **Required OAuth Scopes**: `repo`
|
||
- `base`: 要合并到的分支(string,必填)
|
||
- `body`: PR 描述(string,可选)
|
||
- `draft`: 创建为草稿 PR(boolean,可选)
|
||
- `head`: 包含更改的分支(string,必填)
|
||
- `maintainer_can_modify`: 允许维护者编辑(boolean,可选)
|
||
- `owner`: 仓库所有者(string,必填)
|
||
- `repo`: 仓库名称(string,必填)
|
||
- `reviewers`: 要请求审查的 GitHub 用户名或 ORG/team-slug 团队审查者(string[],可选)
|
||
- `title`: PR 标题(string,必填)
|
||
|
||
- **list_pull_requests** - 列出拉取请求
|
||
- **Required OAuth Scopes**: `repo`
|
||
- `base`: 按基础分支筛选(string,可选)
|
||
- `direction`: 排序方向(string,可选)
|
||
- `head`: 按 head 用户/组织及分支筛选(string,可选)
|
||
- `owner`: 仓库所有者(string,必填)
|
||
- `page`: 分页页码(最小为 1)(number,可选)
|
||
- `perPage`: 分页每页结果数(最小为 1,最大为 100)(number,可选)
|
||
- `repo`: 仓库名称(string,必填)
|
||
- `sort`: 排序字段(string,可选)
|
||
- `state`: 按状态筛选(string,可选)
|
||
|
||
- **merge_pull_request** - 合并拉取请求
|
||
- **Required OAuth Scopes**: `repo`
|
||
- `commit_message`: 合并提交的额外详情(string,可选)
|
||
- `commit_title`: 合并提交的标题(string,可选)
|
||
- `merge_method`: 合并方法(string,可选)
|
||
- `owner`: 仓库所有者(string,必填)
|
||
- `pullNumber`: 拉取请求编号(number,必填)
|
||
- `repo`: 仓库名称(string,必填)
|
||
|
||
- **pull_request_read** - 获取单个拉取请求的详情
|
||
- **Required OAuth Scopes**: `repo`
|
||
- `after`: 分页游标,仅由 get_review_comments 方法使用。传入上一页 PageInfo 的 endCursor 以获取下一页。(string,可选)
|
||
- `method`: 指定需要从 GitHub 获取哪些拉取请求数据的操作。
|
||
可选选项:
|
||
1. get - 获取特定拉取请求的详情。
|
||
2. get_diff - 获取拉取请求的 diff。
|
||
3. get_status - 获取拉取请求中 head 提交的组合提交状态。
|
||
4. get_files - 获取拉取请求中变更的文件列表。可配合分页参数控制返回结果数量。
|
||
5. get_commits - 获取拉取请求上的提交列表。可配合分页参数控制返回结果数量。
|
||
6. get_review_comments - 获取拉取请求上的审查线程。每个线程包含在拉取请求审查期间于同一代码位置做出的逻辑分组审查评论。返回带有元数据(isResolved、isOutdated、isCollapsed)的线程及其关联评论。使用基于游标的分页(perPage、after)控制结果。
|
||
7. get_reviews - 获取拉取请求上的审查。当被要求提供审查评论时,请使用 get_review_comments 方法。可配合分页参数控制返回结果数量。
|
||
8. get_comments - 获取拉取请求上的评论。若用户未明确要求审查评论,请使用此方法。可配合分页参数控制返回结果数量。
|
||
9. get_check_runs - 获取拉取请求 head 提交的检查运行(check runs)。检查运行是在 PR 上运行的各个 CI/CD 作业和检查。
|
||
(string,必填)
|
||
- `owner`: 仓库所有者(string,必填)
|
||
- `page`: 分页页码(最小为 1)(number,可选)
|
||
- `perPage`: 分页每页结果数(最小为 1,最大为 100)(number,可选)
|
||
- `pullNumber`: 拉取请求编号(number,必填)
|
||
- `repo`: 仓库名称(string,必填)
|
||
|
||
- **pull_request_review_write** - 对拉取请求审查执行写入操作(创建、提交、删除)
|
||
- **Required OAuth Scopes**: `repo`
|
||
- `body`: 审查评论文本(string,可选)
|
||
- `commitID`: 要审查的提交的 SHA(string,可选)
|
||
- `event`: 要执行的审查操作。(string,可选)
|
||
- `method`: 要对拉取请求审查执行的写入操作。(string,必填)
|
||
- `owner`: 仓库所有者(string,必填)
|
||
- `pullNumber`: 拉取请求编号(number,必填)
|
||
- `repo`: 仓库名称(string,必填)
|
||
- `threadId`: 审查线程的节点 ID(例如 PRRT_kwDOxxx)。resolve_thread 和 unresolve_thread 方法需要此参数。可通过 pull_request_read 的 get_review_comments 方法获取线程 ID。(string,可选)
|
||
|
||
- **search_pull_requests** - 搜索拉取请求
|
||
- **Required OAuth Scopes**: `repo`
|
||
- `order`: 排序顺序(string,可选)
|
||
- `owner`: 可选的仓库所有者。若与 repo 一并提供,则仅列出该仓库的拉取请求。(string,可选)
|
||
- `page`: 分页页码(最小为 1)(number,可选)
|
||
- `perPage`: 分页每页结果数(最小为 1,最大为 100)(number,可选)
|
||
- `query`: 使用 GitHub 拉取请求搜索语法的搜索查询(string,必填)
|
||
- `repo`: 可选的仓库名称。若与 owner 一并提供,则仅列出该仓库的拉取请求。(string,可选)
|
||
- `sort`: 按各类别匹配数量排序的字段,默认为最佳匹配(string,可选)
|
||
|
||
- **update_pull_request** - 编辑拉取请求
|
||
- **Required OAuth Scopes**: `repo`
|
||
- `base`: 新的基础分支名称(string,可选)
|
||
- `body`: 新描述(string,可选)
|
||
- `draft`: 将拉取请求标记为草稿(true)或准备审查(false)(boolean,可选)
|
||
- `maintainer_can_modify`: 允许维护者编辑(boolean,可选)
|
||
- `owner`: 仓库所有者(string,必填)
|
||
- `pullNumber`: 要更新的拉取请求编号(number,必填)
|
||
- `repo`: 仓库名称(string,必填)
|
||
- `reviewers`: 要请求审查的 GitHub 用户名或 ORG/team-slug 团队审查者(string[],可选)
|
||
- `state`: 新状态(string,可选)
|
||
- `title`: 新标题(string,可选)
|
||
|
||
- **update_pull_request_branch** - 更新 Pull Request 分支
|
||
- **所需 OAuth 权限范围**:`repo`
|
||
- `expectedHeadSha`:拉取请求 HEAD 引用的预期 SHA(string,可选)
|
||
- `owner`:仓库所有者(string,必填)
|
||
- `pullNumber`:拉取请求编号(number,必填)
|
||
- `repo`:仓库名称(string,必填)
|
||
|
||
</details>
|
||
|
||
<details>
|
||
|
||
<summary><picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/repo-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/repo-light.png"><img src="pkg/octicons/icons/repo-light.png" width="20" height="20" alt="repo"></picture> Repositories</summary>
|
||
|
||
- **create_branch** - 创建分支
|
||
- **所需 OAuth 权限范围**:`repo`
|
||
- `branch`:新分支名称(string,必填)
|
||
- `from_branch`:源分支(默认为仓库默认分支)(string,可选)
|
||
- `owner`:仓库所有者(string,必填)
|
||
- `repo`:仓库名称(string,必填)
|
||
|
||
- **create_or_update_file** - 创建或更新文件
|
||
- **所需 OAuth 权限范围**:`repo`
|
||
- `branch`:创建/更新文件所在的分支(string,必填)
|
||
- `content`:文件内容(string,必填)
|
||
- `message`:提交消息(string,必填)
|
||
- `owner`:仓库所有者(用户名或组织)(string,必填)
|
||
- `path`:创建/更新文件的路径(string,必填)
|
||
- `repo`:仓库名称(string,必填)
|
||
- `sha`:被替换文件的 blob SHA。若文件已存在则为必填。(string,可选)
|
||
|
||
- **create_repository** - 创建仓库
|
||
- **所需 OAuth 权限范围**:`repo`
|
||
- `autoInit`:是否使用 README 初始化(boolean,可选)
|
||
- `description`:仓库描述(string,可选)
|
||
- `name`:仓库名称(string,必填)
|
||
- `organization`:创建仓库的组织(省略则在个人账号下创建)(string,可选)
|
||
- `private`:仓库是否应为私有。省略时默认为 true(私有)。(boolean,可选)
|
||
|
||
- **delete_file** - 删除文件
|
||
- **所需 OAuth 权限范围**:`repo`
|
||
- `branch`:删除文件所在的分支(string,必填)
|
||
- `message`:提交消息(string,必填)
|
||
- `owner`:仓库所有者(用户名或组织)(string,必填)
|
||
- `path`:要删除的文件路径(string,必填)
|
||
- `repo`:仓库名称(string,必填)
|
||
|
||
- **fork_repository** - Fork 仓库
|
||
- **所需 OAuth 权限范围**:`repo`
|
||
- `organization`:Fork 到的组织(string,可选)
|
||
- `owner`:仓库所有者(string,必填)
|
||
- `repo`:仓库名称(string,必填)
|
||
|
||
- **get_commit** - 获取提交详情
|
||
- **所需 OAuth 权限范围**:`repo`
|
||
- `detail`:变更文件的详细程度。"none" 会完全省略统计信息和文件。"stats"(默认)包含每个文件的元数据:文件名、状态以及代码行数统计(新增、删除、变更),不包含 patch 内容。"full_patch" 还会包含每个文件的统一 diff 内容,体积可能非常大。(string,可选)
|
||
- `owner`:仓库所有者(string,必填)
|
||
- `page`:分页页码(最小 1)(number,可选)
|
||
- `perPage`:每页结果数(最小 1,最大 100)(number,可选)
|
||
- `repo`:仓库名称(string,必填)
|
||
- `sha`:提交 SHA、分支名或标签名(string,必填)
|
||
|
||
- **get_file_contents** - 获取文件或目录内容
|
||
- **所需 OAuth 权限范围**:`repo`
|
||
- `owner`:仓库所有者(用户名或组织)(string,必填)
|
||
- `path`:文件/目录路径(string,可选)
|
||
- `ref`:接受可选的 git 引用,例如 `refs/tags/{tag}`、`refs/heads/{branch}` 或 `refs/pull/{pr_number}/head`(string,可选)
|
||
- `repo`:仓库名称(string,必填)
|
||
- `sha`:接受可选的提交 SHA。若指定,将替代 ref 使用(string,可选)
|
||
|
||
- **get_latest_release** - 获取最新 Release
|
||
- **所需 OAuth 权限范围**:`repo`
|
||
- `owner`:仓库所有者(string,必填)
|
||
- `repo`:仓库名称(string,必填)
|
||
|
||
- **get_release_by_tag** - 按标签名获取 Release
|
||
- **所需 OAuth 权限范围**:`repo`
|
||
- `owner`:仓库所有者(string,必填)
|
||
- `repo`:仓库名称(string,必填)
|
||
- `tag`:标签名(例如 'v1.0.0')(string,必填)
|
||
|
||
- **get_tag** - 获取标签详情
|
||
- **所需 OAuth 权限范围**:`repo`
|
||
- `owner`:仓库所有者(string,必填)
|
||
- `repo`:仓库名称(string,必填)
|
||
- `tag`:标签名(string,必填)
|
||
|
||
- **list_branches** - 列出分支
|
||
- **所需 OAuth 权限范围**:`repo`
|
||
- `owner`:仓库所有者(string,必填)
|
||
- `page`:分页页码(最小 1)(number,可选)
|
||
- `perPage`:每页结果数(最小 1,最大 100)(number,可选)
|
||
- `repo`:仓库名称(string,必填)
|
||
|
||
- **list_commits** - 列出提交
|
||
- **所需 OAuth 权限范围**:`repo`
|
||
- `author`:按作者用户名或电子邮件地址筛选提交(string,可选)
|
||
- `owner`:仓库所有者(string,必填)
|
||
- `page`:分页页码(最小 1)(number,可选)
|
||
- `path`:仅返回包含此文件路径的提交(string,可选)
|
||
- `perPage`:每页结果数(最小 1,最大 100)(number,可选)
|
||
- `repo`:仓库名称(string,必填)
|
||
- `sha`:要列出提交的提交 SHA、分支或标签名。若未提供,则使用仓库的默认分支。若提供提交 SHA,将列出截至该 SHA 的提交。(string,可选)
|
||
- `since`:仅返回此日期之后的提交(ISO 8601 格式:YYYY-MM-DDTHH:MM:SSZ 或 YYYY-MM-DD)(string,可选)
|
||
- `until`:仅返回此日期之前的提交(ISO 8601 格式:YYYY-MM-DDTHH:MM:SSZ 或 YYYY-MM-DD)(string,可选)
|
||
|
||
- **list_releases** - 列出 Release
|
||
- **所需 OAuth 权限范围**:`repo`
|
||
- `owner`:仓库所有者(string,必填)
|
||
- `page`:分页页码(最小 1)(number,可选)
|
||
- `perPage`:每页结果数(最小 1,最大 100)(number,可选)
|
||
- `repo`:仓库名称(string,必填)
|
||
|
||
- **list_repository_collaborators** - 列出仓库协作者
|
||
- **所需 OAuth 权限范围**:`repo`
|
||
- `affiliation`:按关联关系筛选。可选值:'outside'(外部协作者)、'direct'(所有具有权限的用户,不论是否为组织成员)、'all'(所有协作者)。默认值:'all'(string,可选)
|
||
- `owner`:仓库所有者(string,必填)
|
||
- `page`:分页页码(默认 1,最小 1)(number,可选)
|
||
- `perPage`:每页结果数(默认 30,最小 1,最大 100)(number,可选)
|
||
- `repo`:仓库名称(string,必填)
|
||
|
||
- **list_tags** - 列出标签
|
||
- **所需 OAuth 权限范围**:`repo`
|
||
- `owner`:仓库所有者(string,必填)
|
||
- `page`:分页页码(最小 1)(number,可选)
|
||
- `perPage`:每页结果数(最小 1,最大 100)(number,可选)
|
||
- `repo`:仓库名称(string,必填)
|
||
|
||
- **push_files** - 推送文件到仓库
|
||
- **所需 OAuth 权限范围**:`repo`
|
||
- `branch`:推送目标分支(string,必填)
|
||
- `files`:要推送的文件对象数组,每个对象包含 path(string)和 content(string)(object[],必填)
|
||
- `message`:提交消息(string,必填)
|
||
- `owner`:仓库所有者(string,必填)
|
||
- `repo`:仓库名称(string,必填)
|
||
|
||
- **search_code** - 搜索代码
|
||
- **所需 OAuth 权限范围**:`repo`
|
||
- `order`:结果排序顺序(string,可选)
|
||
- `page`:分页页码(最小 1)(number,可选)
|
||
- `perPage`:每页结果数(最小 1,最大 100)(number,可选)
|
||
- `query`:搜索查询(GitHub 代码搜索 REST)。词条之间隐式 AND;支持 `OR`、`NOT` 和 `"quoted phrase"` 进行精确匹配。限定符:`repo:owner/repo`、`org:`、`user:`、`language:`、`path:dir`(前缀匹配)、`filename:exact.ext`、`extension:`、`in:file`、`in:path`、`size:`、`is:archived`、`is:fork`。最多 256 个字符。示例:`WithContext language:go org:github`;`"package main" repo:o/r`;`func extension:go path:cmd repo:o/r`;`NOT TODO language:go repo:o/r`。(string,必填)
|
||
- `sort`:排序字段(仅 'indexed')(string,可选)
|
||
|
||
- **search_commits** - 搜索提交
|
||
- **必需的 OAuth 权限范围**:`repo`
|
||
- `order`:排序顺序(string,可选)
|
||
- `page`:分页页码(最小值为 1)(number,可选)
|
||
- `perPage`:每页结果数(最小值为 1,最大值为 100)(number,可选)
|
||
- `query`:提交搜索查询(GitHub commit search REST)。仅在默认分支上搜索提交消息。请使用 `repo:owner/repo`、`org:` 或 `user:` 限定搜索范围(未带范围限定符的查询会在整个 GitHub 上匹配,通常并非你所需要的)。其他限定符:`author:`、`committer:`、`author-name:`、`committer-name:`、`author-email:`、`committer-email:`、`author-date:`、`committer-date:`(支持 `>`、`<`、`>=`、`<=` 和 `YYYY-MM-DD..YYYY-MM-DD` 范围)、`merge:true|false`、`hash:`、`tree:`、`parent:`、`is:public`。示例:`repo:owner/repo fix panic`;`org:github author:defunkt committer-date:>=2024-01-01`;`"refactor cache" repo:o/r`;`hash:abc1234 repo:o/r`。(string,必填)
|
||
- `sort`:按作者或提交者日期排序(默认为最佳匹配)(string,可选)
|
||
|
||
- **search_repositories** - 搜索仓库
|
||
- **必需的 OAuth 权限范围**:`repo`
|
||
- `minimal_output`:返回精简的仓库信息(默认:true)。为 false 时返回完整的 GitHub API 仓库对象。(boolean,可选)
|
||
- `order`:排序顺序(string,可选)
|
||
- `page`:分页页码(最小值为 1)(number,可选)
|
||
- `perPage`:每页结果数(最小值为 1,最大值为 100)(number,可选)
|
||
- `query`:仓库搜索查询。示例:'machine learning in:name stars:>1000 language:python'、'topic:react'、'user:facebook'。支持高级搜索语法以实现精确筛选。(string,必填)
|
||
- `sort`:按字段对仓库排序,默认为最佳匹配(string,可选)
|
||
|
||
</details>
|
||
|
||
<details>
|
||
|
||
<summary><picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/shield-lock-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/shield-lock-light.png"><img src="pkg/octicons/icons/shield-lock-light.png" width="20" height="20" alt="shield-lock"></picture> 密钥保护(Secret Protection)</summary>
|
||
|
||
- **get_secret_scanning_alert** - 获取密钥扫描告警
|
||
- **必需的 OAuth 权限范围**:`security_events`
|
||
- **可接受的 OAuth 权限范围**:`repo`、`security_events`
|
||
- `alertNumber`:告警编号。(number,必填)
|
||
- `owner`:仓库所有者。(string,必填)
|
||
- `repo`:仓库名称。(string,必填)
|
||
|
||
- **list_secret_scanning_alerts** - 列出密钥扫描告警
|
||
- **必需的 OAuth 权限范围**:`security_events`
|
||
- **可接受的 OAuth 权限范围**:`repo`、`security_events`
|
||
- `owner`:仓库所有者。(string,必填)
|
||
- `page`:分页页码(最小值为 1)(number,可选)
|
||
- `perPage`:每页结果数(最小值为 1,最大值为 100)(number,可选)
|
||
- `repo`:仓库名称。(string,必填)
|
||
- `resolution`:按处理方式筛选(string,可选)
|
||
- `secret_type`:以逗号分隔的密钥类型列表。默认返回所有默认密钥模式。要返回通用模式,请在参数中传入令牌名称。(string,可选)
|
||
- `state`:按状态筛选(string,可选)
|
||
|
||
</details>
|
||
|
||
<details>
|
||
|
||
<summary><picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/shield-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/shield-light.png"><img src="pkg/octicons/icons/shield-light.png" width="20" height="20" alt="shield"></picture> 安全公告(Security Advisories)</summary>
|
||
|
||
- **get_global_security_advisory** - 获取全局安全公告
|
||
- **必需的 OAuth 权限范围**:`security_events`
|
||
- **可接受的 OAuth 权限范围**:`repo`、`security_events`
|
||
- `ghsaId`:GitHub 安全公告 ID(格式:GHSA-xxxx-xxxx-xxxx)。(string,必填)
|
||
|
||
- **list_global_security_advisories** - 列出全局安全公告
|
||
- **必需的 OAuth 权限范围**:`security_events`
|
||
- **可接受的 OAuth 权限范围**:`repo`、`security_events`
|
||
- `affects`:按受影响的包或版本筛选公告(例如 "package1,package2@1.0.0")。(string,可选)
|
||
- `cveId`:按 CVE ID 筛选。(string,可选)
|
||
- `cwes`:按通用弱点枚举(Common Weakness Enumeration,CWE)ID 筛选(例如 ["79", "284", "22"])。(string[],可选)
|
||
- `ecosystem`:按包生态系统筛选。(string,可选)
|
||
- `ghsaId`:按 GitHub 安全公告 ID 筛选(格式:GHSA-xxxx-xxxx-xxxx)。(string,可选)
|
||
- `isWithdrawn`:是否仅返回已撤回的公告。(boolean,可选)
|
||
- `modified`:按发布或更新日期或日期范围筛选(ISO 8601 日期或范围)。(string,可选)
|
||
- `published`:按发布日期或日期范围筛选(ISO 8601 日期或范围)。(string,可选)
|
||
- `severity`:按严重程度筛选。(string,可选)
|
||
- `type`:公告类型。(string,可选)
|
||
- `updated`:按更新日期或日期范围筛选(ISO 8601 日期或范围)。(string,可选)
|
||
|
||
- **list_org_repository_security_advisories** - 列出组织仓库安全公告
|
||
- **必需的 OAuth 权限范围**:`security_events`
|
||
- **可接受的 OAuth 权限范围**:`repo`、`security_events`
|
||
- `direction`:排序方向。(string,可选)
|
||
- `org`:组织登录名。(string,必填)
|
||
- `sort`:排序字段。(string,可选)
|
||
- `state`:按公告状态筛选。(string,可选)
|
||
|
||
- **list_repository_security_advisories** - 列出仓库安全公告
|
||
- **必需的 OAuth 权限范围**:`security_events`
|
||
- **可接受的 OAuth 权限范围**:`repo`、`security_events`
|
||
- `direction`:排序方向。(string,可选)
|
||
- `owner`:仓库所有者。(string,必填)
|
||
- `repo`:仓库名称。(string,必填)
|
||
- `sort`:排序字段。(string,可选)
|
||
- `state`:按公告状态筛选。(string,可选)
|
||
|
||
</details>
|
||
|
||
<details>
|
||
|
||
<summary><picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/star-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/star-light.png"><img src="pkg/octicons/icons/star-light.png" width="20" height="20" alt="star"></picture> Star 用户(Stargazers)</summary>
|
||
|
||
- **list_starred_repositories** - 列出已加星的仓库
|
||
- **必需的 OAuth 权限范围**:`repo`
|
||
- `direction`:结果排序方向。(string,可选)
|
||
- `page`:分页页码(最小值为 1)(number,可选)
|
||
- `perPage`:每页结果数(最小值为 1,最大值为 100)(number,可选)
|
||
- `sort`:结果的排序方式。可以是 'created'(仓库被加星的时间)或 'updated'(仓库最后一次推送的时间)。(string,可选)
|
||
- `username`:要列出其已加星仓库的用户名。默认为已认证用户。(string,可选)
|
||
|
||
- **star_repository** - 为仓库加星
|
||
- **必需的 OAuth 权限范围**:`repo`
|
||
- `owner`:仓库所有者(string,必填)
|
||
- `repo`:仓库名称(string,必填)
|
||
|
||
- **unstar_repository** - 取消为仓库加星
|
||
- **必需的 OAuth 权限范围**:`repo`
|
||
- `owner`:仓库所有者(string,必填)
|
||
- `repo`:仓库名称(string,必填)
|
||
|
||
</details>
|
||
|
||
<details>
|
||
|
||
<summary><picture><source media="(prefers-color-scheme: dark)" srcset="pkg/octicons/icons/people-dark.png"><source media="(prefers-color-scheme: light)" srcset="pkg/octicons/icons/people-light.png"><img src="pkg/octicons/icons/people-light.png" width="20" height="20" alt="people"></picture> 用户(Users)</summary>
|
||
|
||
- **search_users** - 搜索用户
|
||
- **必需的 OAuth 权限范围**:`repo`
|
||
- `order`:排序顺序(string,可选)
|
||
- `page`:分页页码(最小值为 1)(number,可选)
|
||
- `perPage`:每页结果数(最小值为 1,最大值为 100)(number,可选)
|
||
- `query`:用户搜索查询。示例:'john smith'、'location:seattle'、'followers:>100'。搜索会自动限定为 type:user。(string,必填)
|
||
- `sort`:按关注者数量、仓库数量或用户加入 GitHub 的时间排序。(string,可选)
|
||
|
||
</details>
|
||
<!-- END AUTOMATED TOOLS -->
|
||
|
||
### 远程 GitHub MCP Server 中的其他工具
|
||
|
||
<details>
|
||
|
||
<summary>Copilot</summary>
|
||
|
||
- **create_pull_request_with_copilot** - 使用 GitHub Copilot 编码代理执行任务
|
||
- `owner`: 仓库所有者。你可以推测所有者,但在继续之前须与用户确认。(string,必填)
|
||
- `repo`: 仓库名称。你可以推测仓库名称,但在继续之前须与用户确认。(string,必填)
|
||
- `problem_statement`: 待执行任务的详细描述(例如「实现某项功能 X」「修复 bug Y」等)(string,必填)
|
||
- `title`: 将创建的拉取请求标题(string,必填)
|
||
- `base_ref`: 代理开始工作时使用的 Git 引用(例如分支)。若未指定,则默认为仓库的默认分支(string,可选)
|
||
|
||
</details>
|
||
|
||
<details>
|
||
|
||
<summary>Copilot Spaces</summary>
|
||
|
||
- **Authentication note**
|
||
- 细粒度 PAT(Personal Access Token)不会受经典 PAT 作用域过滤的隐藏,因此即使令牌无法使用这些工具,它们仍可能显示。
|
||
- 对于组织拥有的 Space,细粒度 PAT 必须安装在所属组织上,并包含 `organization_copilot_spaces: read`。
|
||
- 若组织拥有的 Space 包含以仓库为后端的资源,令牌还必须能访问所有被引用的仓库,否则该 Space 可能被视作不存在。
|
||
|
||
- **get_copilot_space** - 获取 Copilot Space
|
||
- `owner`: Space 的所有者。(string,必填)
|
||
- `name`: Space 的名称。(string,必填)
|
||
|
||
- **list_copilot_spaces** - 列出 Copilot Spaces
|
||
|
||
</details>
|
||
|
||
<details>
|
||
|
||
<summary>GitHub Support Docs Search</summary>
|
||
|
||
- **github_support_docs_search** - 检索与回答 GitHub 产品和支持问题相关的文档。支持主题包括:GitHub Actions Workflows、Authentication、GitHub Support Inquiries、Pull Request Practices、Repository Maintenance、GitHub Pages、GitHub Packages、GitHub Discussions、Copilot Spaces
|
||
- `query`: 用户关于待解答问题的输入。这是最新、未经编辑的原始用户消息。你必须始终原样保留用户消息,不得修改。(string,必填)
|
||
|
||
</details>
|
||
|
||
## 只读模式(Read-Only Mode)
|
||
|
||
要以只读模式运行服务器,可使用 `--read-only` 标志。此模式仅提供只读工具,防止对仓库、议题(issue)、拉取请求(pull request)等进行任何修改。
|
||
|
||
```bash
|
||
./github-mcp-server --read-only
|
||
```
|
||
|
||
使用 Docker 时,可将只读模式作为环境变量传入:
|
||
|
||
```bash
|
||
docker run -i --rm \
|
||
-e GITHUB_PERSONAL_ACCESS_TOKEN=<your-token> \
|
||
-e GITHUB_READ_ONLY=1 \
|
||
ghcr.io/github/github-mcp-server
|
||
```
|
||
|
||
## 锁定模式(Lockdown Mode)
|
||
|
||
锁定模式限制服务器从公开仓库中展示的内容。启用后,服务器会检查每项内容的作者是否对该仓库拥有推送(push)权限。私有仓库不受影响,协作者仍可完全访问自己的内容。
|
||
|
||
```bash
|
||
./github-mcp-server --lockdown-mode
|
||
```
|
||
|
||
使用 Docker 运行时,请设置相应的环境变量:
|
||
|
||
```bash
|
||
docker run -i --rm \
|
||
-e GITHUB_PERSONAL_ACCESS_TOKEN=<your-token> \
|
||
-e GITHUB_LOCKDOWN_MODE=1 \
|
||
ghcr.io/github/github-mcp-server
|
||
```
|
||
|
||
锁定模式的行为取决于所调用的工具。
|
||
|
||
当作者缺少推送权限时,以下工具将返回错误:
|
||
|
||
- `issue_read:get`
|
||
- `pull_request_read:get`
|
||
|
||
以下工具会过滤掉缺少推送权限用户的内容:
|
||
|
||
- `issue_read:get_comments`
|
||
- `issue_read:get_sub_issues`
|
||
- `pull_request_read:get_comments`
|
||
- `pull_request_read:get_review_comments`
|
||
- `pull_request_read:get_reviews`
|
||
|
||
## 国际化 / 覆盖描述(i18n / Overriding Descriptions)
|
||
|
||
可通过在与二进制文件相同目录下创建 `github-mcp-server-config.json` 文件来覆盖工具描述。
|
||
|
||
该文件应包含一个 JSON 对象,以工具名称为键、新描述为值。例如:
|
||
|
||
```json
|
||
{
|
||
"TOOL_ADD_ISSUE_COMMENT_DESCRIPTION": "an alternative description",
|
||
"TOOL_CREATE_BRANCH_DESCRIPTION": "Create a new branch in a GitHub repository"
|
||
}
|
||
```
|
||
|
||
可通过使用 `--export-translations` 标志运行二进制文件来导出当前翻译。
|
||
|
||
此标志会保留你已做的任何翻译/覆盖,同时添加自上次导出以来二进制文件中新增的翻译。
|
||
|
||
```sh
|
||
./github-mcp-server --export-translations
|
||
cat github-mcp-server-config.json
|
||
```
|
||
|
||
也可使用环境变量覆盖描述。环境变量名称与 JSON 文件中的键相同,前缀为 `GITHUB_MCP_`,且全部大写。
|
||
|
||
例如,要覆盖 `TOOL_ADD_ISSUE_COMMENT_DESCRIPTION` 工具,可设置以下环境变量:
|
||
|
||
```sh
|
||
export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description"
|
||
```
|
||
|
||
### 覆盖服务器名称与标题
|
||
|
||
同一覆盖机制可用于自定义 MCP 服务器初始化响应中的 `name` 和 `title` 字段。在运行多个 GitHub MCP Server 实例时(例如一个用于 github.com,一个用于 GitHub Enterprise Server)这很有用,以便代理能够区分它们。
|
||
|
||
| Key | Environment Variable | Default |
|
||
|-----|---------------------|---------|
|
||
| `SERVER_NAME` | `GITHUB_MCP_SERVER_NAME` | `github-mcp-server` |
|
||
| `SERVER_TITLE` | `GITHUB_MCP_SERVER_TITLE` | `GitHub MCP Server` |
|
||
|
||
例如,为 GitHub Enterprise Server 配置服务器实例:
|
||
|
||
```json
|
||
{
|
||
"SERVER_NAME": "ghes-mcp-server",
|
||
"SERVER_TITLE": "GHES MCP Server"
|
||
}
|
||
```
|
||
|
||
或使用环境变量:
|
||
|
||
```sh
|
||
export GITHUB_MCP_SERVER_NAME="ghes-mcp-server"
|
||
export GITHUB_MCP_SERVER_TITLE="GHES MCP Server"
|
||
```
|
||
|
||
## 库用法(Library Usage)
|
||
|
||
目前应将本模块导出的 Go API 视为不稳定,且可能包含破坏性变更。未来我们可能会提供稳定性保证;若你有相关用例需求,请提交 issue。
|
||
|
||
## 贡献(Contributing)
|
||
|
||
欢迎贡献。在打开拉取请求之前,请阅读[贡献指南](CONTRIBUTING.md),了解设置、测试、代码检查(linting)和文档生成说明。
|
||
|
||
## 支持(Support)
|
||
|
||
有关 GitHub MCP Server 的使用帮助,请参阅[支持指南](SUPPORT.md)。若你发现 bug 或想请求新功能,请在新建 issue 前先搜索现有 issue。
|
||
|
||
## 安全(Security)
|
||
|
||
请勿通过公开 issue 报告安全漏洞。请按照[安全政策](SECURITY.md)中的说明负责任地报告漏洞。
|
||
|
||
## 许可证(License)
|
||
|
||
本项目依据 MIT 开源许可证条款授权。完整条款请参阅 [MIT](./LICENSE)。
|