GitHub存储库资源管理器MCP
一个模型上下文协议(MCP)服务器,使Claude Code能够探索和理解任何GitHub存储库。非常适合从现有代码库中学习、理解实现模式或研究其他项目如何解决类似问题。
为什么使用这个?
你有没有想过VS Code是如何实现其编辑器的,React是如何处理状态管理的,或者任何开源项目是如何构建代码的?此MCP服务器允许Claude Code深入任何公共存储库,以帮助您理解和学习现实世界的实现。
特性
- 🚀 即时存储库访问:克隆并探索任何公共GitHub存储库
- 📁 导航代码库:像在本地环境中一样浏览目录结构
- 📄 读取源代码:检查任何文件的实施细节
- 🔍 智能代码搜索:在整个项目中查找特定的模式、功能或实现
- 💡 范例学习:研究成功的项目如何实现您想要构建的功能
- 🔒 安全勘探:只读访问确保您只是在学习,而不是在修改
用例
🎯 从热门项目中学习
// Explore how VS Code implements its text editor
await clone_repo({ url: "https://github.com/microsoft/vscode" })
await grep({ pattern: "TextEditor", path: "src" })
// Understand React's hooks implementation
await clone_repo({ url: "https://github.com/facebook/react" })
await cat({ path: "packages/react/src/ReactHooks.js" })
// Study Next.js routing architecture
await clone_repo({ url: "https://github.com/vercel/next.js" })
await ls({ path: "packages/next/src/client/components" })🔍 研究实现模式
- 认证:查看Supabase如何处理身份验证流
- 状态管理:研究Redux或Zustand内部
- API设计:学习Stripe的SDK模式
- 测试策略:探索Jest或Vitest代码库
- 构建工具:了解Vite或Webpack的工作原理
安装
# Clone this repository
git clone https://github.com/yourusername/github-repo-explorer-mcp.git
cd github-repo-explorer-mcp
# Install dependencies
npm install
# Build TypeScript files
npm run build使用Claude代码进行设置
1.运行服务器
# Use the provided shell script (recommended)
./run-github-mcp.sh
# Or run directly with npm
npm run dev2.添加到克劳德桌面
# Add using Claude CLI
claude mcp add github-repo /path/to/github-repo-explorer-mcp/run-github-mcp.sh
# For example, if you cloned to your Projects folder:
claude mcp add github-repo /Users/yourusername/Projects/github-repo-explorer-mcp/run-github-mcp.sh
# The server will now be available in Claude Code sessionsapi参考
工具
clone_repo
将GitHub存储库克隆到本地文件系统。
{
url: string; // GitHub repository URL
name?: string; // Optional custom directory name
}ls
列出存储库中的文件和目录。
{
path?: string; // Optional path relative to repo root (defaults to root)
}cat
从存储库读取文件内容。
{
path: string; // Path to file relative to repo root
}grep
在存储库文件中搜索模式。
{
pattern: string; // Search pattern (supports regex)
path?: string; // Optional path to search in
ignoreCase?: boolean; // Case-insensitive search
}资源
repository_info-显示当前存储库URL和本地路径
探索课程示例
理解VS代码的编辑器实现
// Clone VS Code repository
await clone_repo({ url: "https://github.com/microsoft/vscode" })
// Find where the editor is implemented
await grep({ pattern: "class.*Editor", path: "src/vs/editor" })
// Explore the monaco editor structure
await ls({ path: "src/vs/editor/browser" })
// Read specific implementation
await cat({ path: "src/vs/editor/browser/editorBrowser.ts" })从Supabase学习认证模式
// Clone Supabase auth helpers
await clone_repo({ url: "https://github.com/supabase/auth-helpers" })
// Find OAuth implementations
await grep({ pattern: "OAuth|oauth", ignoreCase: true })
// Study the auth client structure
await ls({ path: "packages/shared/src" })探索现代构建工具
// See how Vite handles HMR (Hot Module Replacement)
await clone_repo({ url: "https://github.com/vitejs/vite" })
await grep({ pattern: "hot.*update|hmr", path: "packages/vite/src", ignoreCase: true })
// Understand Turbopack's architecture
await clone_repo({ url: "https://github.com/vercel/turbo" })
await ls({ path: "crates/turbopack-core/src" })项目结构
github-mcp-server/
├── src/
│ └── index.ts # Main server implementation
├── build/ # Compiled JavaScript output
├── CLAUDE.md # Instructions for Claude Code
├── package.json # Project dependencies
├── tsconfig.json # TypeScript configuration
└── run-github-mcp.sh # Shell script for running the server发展
先决条件
- Node.js 16+
- npm或纱线
- TypeScript
从源头构建
# Install dependencies
npm install
# Run in development mode
npm run dev
# Build for production
npm run build
# Run tests (if available)
npm test安全考虑
- 🔒 仅适用于公共GitHub存储库
- 📁 文件访问仅限于克隆的存储库目录
- 🛡️ 正确转义Shell命令以防止注入
- 🚫 没有存储或传输身份验证令牌
- 📍 克隆的存储库存储在本地
./repo默认情况下
贡献
欢迎投稿!请随时提交拉取请求。
许可证
MIT许可证-有关详细信息,请参阅许可证文件
