摘要
通过 GitHub 官方 MCP 服务器,在 Claude、ChatGPT 或 Copilot 中使用 GitHub:读取代码和提交、搜索仓库、分拣 issue、创建和审查 pull request。
引导式设置
2 分钟将 GitHub 连接到 Microsoft Copilot
开始 AnythingMCP Cloud 免费试用,在引导式设置中连接 GitHub,再把你的 MCP URL 添加到 Microsoft Copilot。无需代码,也无需自行运行服务器。
无需信用卡 · 7 天试用 · 提供自托管方案
试试这样问
GitHub 的示例提示
点击任意提示即可复制,然后粘贴到 Claude、ChatGPT、Cursor、Gemini、Copilot 或 OpenClaw 中,在该连接器上运行。
Claude 是 AI,可能会出错。请核对回答。
💡 无需安装? 直接使用 cloud.anythingmcp.com。 登录、点击 Connectors → GitHub、粘贴凭证、生成 MCP API key — 完成。无 Docker、无
git clone、无本地服务器。
GitHub + Microsoft Copilot
通过 GitHub 官方 MCP 服务器,在 Claude、ChatGPT 或 Copilot 中使用 GitHub:读取代码和提交、搜索仓库、分拣 issue、创建和审查 pull request。
前提条件
完整的设置说明已内置在连接器中 (在 store 中选择连接器时可见)。所需环境变量:
GITHUB_PAT
步骤 1 — 获取凭证
AnythingMCP 使用 personal access token 连接 GitHub 官方的远程 MCP 服务器 (https://api.githubcopilot.com/mcp/)。工具由 GitHub 的服务器提供:安装时 AnythingMCP 会读取当前的工具列表,每个工具都带有前缀 github_。GitHub 新增工具后,打开连接器并点击 Discover tools 即可获取。
- 在 GitHub 打开 Settings → Developer settings → Personal access tokens → Fine-grained tokens → Generate new token(直达链接)。选择 resource owner(你的账号或某个组织)、有效期,并在 Only select repositories 中只选 AI 需要访问的仓库。
- 在 Repository permissions 中把 Contents、Issues 和 Pull requests 设为 Read-only;如果 AI 需要创建分支、提交代码或创建 issue 和 pull request,则设为 Read and write。Metadata(只读)会自动加入。要使用
github_get_teams和github_get_team_members,还需添加组织权限 Members: Read-only。 - 如果 owner 是组织,可能需要组织所有者先批准该令牌(组织的 Settings → Personal access tokens → Pending requests)。启用了 SAML 单点登录的组织还需要为 SSO 授权该令牌。
- 把令牌粘贴到
GITHUB_PAT并安装。经典令牌(ghp_…,scoperepo,团队相关再加read:org)也可以用,但它能访问你有权限的所有仓库,所以 fine-grained 令牌更安全。
组织策略:在 Copilot Business 或 Copilot Enterprise 下,组织必须启用 MCP servers in Copilot 策略。组织可以限制 personal access token,使用 Enterprise Managed Users 的企业可能完全禁用了它。对于启用数据驻留的 GitHub Enterprise Cloud,请把连接器的基础 URL 改为 https://copilot-api.<your-subdomain>.ghe.com/mcp。GitHub Enterprise Server 没有托管的 MCP 服务器。
工具集和只读模式:GitHub 默认提供 context、repos、issues、pull_requests 和 users 工具集。要更改,请在连接器编辑器中添加请求头 X-MCP-Toolsets(例如 repos,issues,pull_requests,actions,或 all);添加 X-MCP-Readonly: true 则只公开读取类工具。然后点击 Discover tools。
安装时默认关闭:github_merge_pull_request、github_push_files、github_create_or_update_file 和 github_delete_file。之后通过工具集请求头新增的工具(例如删除仓库)同样默认关闭。你可以在连接器中逐个开启。所有操作都以令牌所有者的身份执行;公开仓库中 issue 和 pull request 的文字属于不可信输入(X-MCP-Lockdown: true 会隐藏没有 push 权限的作者的内容)。
第一次调用:先用 github_get_me 确认令牌属于谁,再使用 github_search_repositories、github_get_file_contents、github_list_issues 和 github_pull_request_read。401 表示令牌错误、过期或已被撤销;403 表示缺少权限、组织审批或 SSO 授权尚未完成,或受策略限制;私有仓库返回 404 通常说明令牌未包含该仓库。
步骤 2 — 安装 adapter
curl -fsSL https://raw.githubusercontent.com/HelpCode-ai/anythingmcp/main/docker-compose.quickstart.yml -o docker-compose.yml
printf 'JWT_SECRET=%s\nENCRYPTION_KEY=%s\n' "$(openssl rand -hex 32)" "$(openssl rand -hex 32)" > .env
docker compose up -d
步骤 3 — 在 Microsoft Copilot 中添加连接器
你的服务器 URL: 在 AnythingMCP 中打开 MCP Servers → 此连接器所在的服务器,复制它的 URL(
https://cloud.anythingmcp.com/mcp/…)。本指南中出现YOUR_SERVER_ID的地方都用它替换。
Microsoft Copilot 通过在 Copilot Studio 中构建的智能体使用 MCP 服务器:把 AnythingMCP 作为工具添加到智能体,然后把智能体发布到 Microsoft 365 Copilot 和 Teams。Copilot Studio 从 Microsoft 的云端通过 Streamable HTTP 连接,AnythingMCP 支持这种方式。
- 在 Copilot Studio 中打开你的智能体(或新建一个),进入 Tools,选择 Add a tool → New tool → Model Context Protocol。
- 填写 Server name(例如
AnythingMCP)、说明连接器用途的 Server description,以及 Server URLhttps://cloud.anythingmcp.com/mcp/YOUR_SERVER_ID。Copilot Studio 根据描述决定何时调用该服务器。 - 身份验证选择 API key,把 Type 设为 Header,请求头名称填
X-API-Key,然后选择 Create。 - 在 Add tool 中选择 Create a new connection,粘贴 AnythingMCP 的 MCP API 密钥(MCP Servers → 你的服务器 → API keys),然后选择 Add to agent。
- 在智能体的 Test 窗格中试一试:提出需要用到
GitHub的工具的请求。 - 选择 Publish,然后进入 Channels → Microsoft 365 and Microsoft Teams,保持勾选 Make agent available in Microsoft Copilot,再选择 Add channel。See agent in Teams 会为你安装该智能体;在 Microsoft 365 Copilot 中输入 @ 并选择该智能体。
希望每个用户各自登录?请选择 OAuth 2.0 → Dynamic discovery 代替 API 密钥:每个用户会在智能体首次调用时登录 AnythingMCP。
自托管?请用你实例的公网 HTTPS 地址替换 https://cloud.anythingmcp.com。Copilot Studio 从 Microsoft 的云端连接,因此 localhost 无法使用。
可用工具
| Tool | What it does |
|---|---|
github_add_comment_to_pending_review | Add review comment to the requester's latest pending pull request review |
github_add_issue_comment | Add a comment and/or reaction to a specific issue or issue comment in a GitHub repository |
github_add_reply_to_pull_request_comment | Add a reply and/or reaction to an existing pull request comment |
github_create_branch | Create a new branch in a GitHub repository, starting from from_branch or, when it is omitted, from the repository's default branch |
github_create_or_update_file | Create or update a single file in a GitHub repository |
github_create_pull_request | Create a new pull request in a GitHub repository from the head branch into the base branch, optionally as a draft and with reviewers… |
github_create_repository | Create a new GitHub repository in your account or specified organization |
github_delete_file | Delete a file from a GitHub repository by committing its removal to the given branch with a commit message |
github_fork_repository | Fork a GitHub repository to your account or specified organization |
github_get_commit | Get details for a commit from a GitHub repository: message, author and, depending on detail, the stats or the full patch of the changed… |
github_get_file_contents | Get the contents of a file or directory from a GitHub repository |
github_get_label | Get a specific label from a repository by its name, with its color and description |
github_get_latest_release | Get the latest release in a GitHub repository, with its tag, name, release notes and assets |
github_get_me | Get details of the authenticated GitHub user |
github_get_release_by_tag | Get a specific release by its tag name in a GitHub repository |
github_get_tag | Get details about a specific git tag in a GitHub repository, including the object the tag points to |
github_get_team_members | Get member usernames of a specific team in an organization |
github_get_teams | Get details of the teams the user is a member of |
github_issue_read | Get information about a specific issue in a GitHub repository |
github_issue_write | Create a new or update an existing issue in a GitHub repository |
github_list_branches | List branches in a GitHub repository with the commit each one points to; paginated with page and perPage |
github_list_commits | Get list of commits of a branch in a GitHub repository |
github_list_issue_fields | List issue fields for a repository or organization |
github_list_issue_types | List supported issue types for a repository or its owner organization |
github_list_issues | List issues in a GitHub repository |
github_list_pull_requests | List pull requests in a GitHub repository |
github_list_releases | List releases in a GitHub repository with their tags, names and release notes; paginated with page and perPage |
github_list_repository_collaborators | List collaborators of a GitHub repository |
github_list_tags | List git tags in a GitHub repository with the commit each tag points to; paginated with page and perPage |
github_merge_pull_request | Merge a pull request in a GitHub repository with the merge, squash or rebase method, optionally only while its head is still expectedHeadSha |
(showing 30 of 46 tools — install the connector to see them all)
FAQ
这适用于哪个 Copilot? 适用于工作中的 Microsoft 365 Copilot,通过 Copilot Studio 的智能体实现。面向个人账户的 Microsoft Copilot 应用无法添加自己的 MCP 服务器。
我需要什么? 一个可以使用 Copilot Studio 的工作账户(许可证或试用版),用于构建智能体。在 Microsoft 365 Copilot 或 Teams 中使用它的人需要拥有该智能体的访问权限:把它共享给他们,或请管理员为整个组织发布。如果你的组织对 Power Platform 连接器设置了数据策略,这些策略同样适用于 MCP 服务器。
智能体不调用工具。 检查请求头名称是否正好是 X-API-Key,密钥是否属于与 URL 相同的 MCP 服务器,并把 Server description 写得具体:Copilot Studio 根据它决定何时调用服务器。每次修改后重新发布智能体;在已打开的对话中输入 "start over" 即可使用新版本。
下一步
这份指南对你有帮助吗?