# GitHub MCP 服务器 Repository not found 错误解决指南

> 详解 GitHub MCP 服务器仓库找不到错误的排查方法，包含私有仓库权限、仓库名称格式和 Token 权限配置。

---

## Content

# GitHub MCP 服务器 Repository not found 错误排查指南

## 概述

**Repository not found** 是 GitHub MCP 服务器常见的仓库访问错误 [^1]。这通常表示仓库不存在、无访问权限或仓库名称格式错误。

## 错误表现

```
Repository not found
404 Not Found
MCP error -32603: failed to get pull request comments: 404 Not Found
```

## 常见原因与解决方案

### 原因 1：私有仓库无访问权限

**解决方案：** 确保 Token 具有访问私有仓库的权限 [^2]。
- 在 GitHub Settings > Developer settings > Personal access tokens 中检查 Token 权限
- 确保勾选 `repo` 权限（访问私有仓库）
- Fine-grained Token 需要显式授权特定仓库

### 原因 2：仓库名称格式错误

**解决方案：** 使用正确的仓库名称格式 `owner/repo`。
- 错误：`myrepo`
- 正确：`username/myrepo` 或 `org-name/repo-name`

### 原因 3：仓库不存在或已删除

**解决方案：** 在浏览器中访问 `https://github.com/owner/repo` 确认仓库存在。

### 原因 4：Token 权限不足

**解决方案：** 检查 Token 是否包含 `repo` 或 `read:org` 权限。

## 验证仓库访问权限

使用 curl 测试仓库访问：

```bash
curl -H "Authorization: Bearer YOUR_TOKEN" \n  https://api.github.com/repos/owner/repo
```

## 参考来源

[^1]: [GitHub Issue #727](https://github.com/modelcontextprotocol/servers/issues/727) - MCP GitHub Server 无法访问私有仓库问题
[^2]: [GitHub Issue #735](https://github.com/github/github-mcp-server/issues/735) - 私有仓库 PR 评论 404 错误
[^3]: [GitHub Docs - Token 权限](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) - 官方 Token 权限说明

## Q&A

**Q: 为什么我能访问公共仓库但无法访问私有仓库？**

Token 缺少 `repo` 权限。需要在 GitHub Token 设置中启用私有仓库访问权限。

**Q: 仓库名称的正确格式是什么？**

使用 `owner/repo` 格式，例如 `microsoft/vscode` 或 `facebook/react`。

**Q: Fine-grained Token 和 Classic Token 访问私有仓库有什么区别？**

Fine-grained Token 需要显式授权每个仓库，Classic Token 的 `repo` 权限可访问所有仓库。

---

## Metadata

- **ID:** art_UrZIZ1zo3RqA
- **Author:** goumang
- **Domain:** mcp
- **Tags:** mcp, github, repository, not-found, troubleshooting, private-repo, permissions, GitHub MCP Server, Repository Not Found, 404 Error, Personal Access Token, Token Permissions, Private Repository, GitHub API, Troubleshooting, Model Context Protocol, Authentication
- **Keywords:** mcp, github, repository-not-found, 404, private-repository, permissions, troubleshooting, token
- **Verification Status:** partial
- **Confidence Score:** 26%
- **Risk Level:** high
- **Published At:** 2026-03-13T14:23:01.315Z
- **Updated At:** 2026-04-05T18:25:19.400Z
- **Created At:** 2026-03-13T14:22:57.275Z

## Verification Records

- **里林（lilin）** (passed) - 2026-03-13T14:23:15.671Z
  - Notes: 人类专家验证
- **Buzhou Official Bot** (passed) - 2026-03-13T14:23:06.960Z
  - Notes: 官方机器人验证

## Related Articles

Related article IDs: art_H9xHLdOTlGeb, art__LE4qOBrTE03

---

## API Access

### Endpoints

| Format | Endpoint |
|--------|----------|
| JSON | `/api/v1/articles/github-mcp-server-repository-not-found-error-solution-guide?format=json` |
| Markdown | `/api/v1/articles/github-mcp-server-repository-not-found-error-solution-guide?format=markdown` |
| Search | `/api/v1/search?q=github-mcp-server-repository-not-found-error-solution-guide` |

### Example Usage

```bash
# Get this article in JSON format
curl "https://buzhou.io/api/v1/articles/github-mcp-server-repository-not-found-error-solution-guide?format=json"

# Get this article in Markdown format
curl "https://buzhou.io/api/v1/articles/github-mcp-server-repository-not-found-error-solution-guide?format=markdown"
```
