Token导航 LogoToken导航TokenDH.com
GitHub MCP With Claude logo
开发工具stdio官方级别未说明来源级核验

GitHub MCP With Claude

MCP Server

GitHub MCP服务器是一个用于与GitHub仓库交互的工具,提供代码搜索、文件管理、分支操作等功能。

工具数

0

提示词数

0

GitHub Stars

1

资源数

0
GitHub代码管理JavaScriptClaude开发工具Claude DesktopClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

EngineerAbdullahIqbal

提供方

EngineerAbdullahIqbal

最后核验

2026/5/17 20:21

运行时

Node.js

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

npx --version

详细介绍

🔧 解决方案:使用GitHub MCP服务器(不是GitHub Copilot)

你需要使用 官方GitHub MCP服务器 来自ModelContextProtocol,而不是GitHub Copilot API端点。

✅ 正确的设置步骤

第一步:安装GitHub MCP服务器

# Install the official GitHub MCP server
npm install -g @modelcontextprotocol/server-github

# Or using npx (no installation needed)
# You'll use npx in the config

步骤2:创建GitHub个人访问令牌

  1. 转到GitHub:https://github.com/settings/tokens
  2. 点击 “生成新令牌”“生成新令牌(经典)”
  3. 给它起个名字: Claude MCP Access
  4. 选择范围:

- ✅ repo (完全控制私有存储库) - ✅ read:org (阅读组织和团队成员) - ✅ read:user (读取用户配置文件数据) - ✅ user:email (访问用户电子邮件地址)

  1. 点击 “生成令牌”
  2. 复制令牌 (你不会再看到它了!)

步骤3:配置Claude桌面

编辑您的Claude配置文件:

# Open the config file
nano ~/.claude.json

# Or use your preferred editor
code ~/.claude.json

添加此配置:

{
  "mcpServers": {
    "github": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-github"
      ],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_your_actual_token_here"
      }
    }
  }
}

替换 ghp_your_actual_token_here 使用您的真实GitHub代币!

步骤4:重新启动克劳德桌面

# Completely quit Claude Desktop (not just close window)
# Then restart it

# On Linux, you can force quit:
pkill -9 claude

# Then relaunch Claude Desktop

步骤5:验证连接

在Claude Desktop中,键入 /mcp 你应该看到:

Github MCP Server

Status: ● enabled

______________________________________________________________________

🔐 备选方案:项目特定配置

如果你只想让GitHub MCP服务器用于你的Hackathon2项目:

cd /path/to/hackathon2-todo-app

# Create project-specific config
nano .claude.json

添加相同的配置:

{
  "mcpServers": {
    "github": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-github"
      ],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_your_token_here"
      }
    }
  }
}

这使得GitHub访问令牌仅限于此项目。

______________________________________________________________________

🛠️ 故障排除

问题:“找不到命令:npx”

# Install Node.js and npm first
# On Ubuntu/Debian:
sudo apt update
sudo apt install nodejs npm

# Verify installation
node --version
npm --version
npx --version

问题:“权限被拒绝”

# Fix npm permissions
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc

问题:令牌不起作用

确保您的令牌具有正确的作用域:

  • repo (最重要)
  • read:org
  • read:user
  • user:email

问题:仍然显示“禁用”

  1. 检查你的 .claude.json 语法(有效的JSON)
  2. 完全退出并重新启动Claude Desktop
  3. 检查克劳德日志:
   # Linux logs location
   ~/.config/Claude/logs/

   # Check recent errors
   tail -f ~/.config/Claude/logs/main.log

______________________________________________________________________

📋 使用GitHub MCP服务器可以获得什么

启用后,您可以要求Claude:

  1. 搜索存储库:“查找我仓库中的所有Python文件”
  2. 读取文件:“显示main.py的内容”
  3. 创建问题:“为这个bug创建一个问题”
  4. 列出分支:“此回购中存在哪些分支?”
  5. 获取提交历史记录:“显示最近的提交”
  6. 搜索代码:“查找我们在哪里使用FastAPI”

______________________________________________________________________

🎯 为您的Hackathon2项目

设置GitHub MCP后,您可以使用它来:

# Example prompts for Claude:

"List all files in my hackathon2-todo-app repository"

"Show me the current directory structure of my project"

"Create a new branch called 'feature/basic-crud'"

"Commit the constitution file with message 'feat: add project constitution'"

"Create an issue titled 'Implement recurring tasks feature' with the specification from specs/recurring-tasks.md"

"Search for all TODO comments in my codebase"

______________________________________________________________________

⚠️ 安全说明

永不承诺 .claude.json 将您的代币发送到GitHub!

添加到 .gitignore:

echo ".claude.json" >> .gitignore
git add .gitignore
git commit -m "chore: ignore Claude config with sensitive tokens"

______________________________________________________________________

✅ 快速摘要

走错了路 (你尝试了什么):

{
  "url": "https://api.githubcopilot.com/mcp/"  ❌
}

正确的方式:

{
  "mcpServers": {
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_your_token"
      }
    }
  }
}

遵循以下步骤,您的GitHub MCP服务器将完美运行! 🚀

目录标签

目录标签

GitHub代码管理JavaScriptClaude开发工具GitHub集成本地部署自动化

支持客户端

Claude DesktopClaude

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Node.js

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP