GitHub MCP Server
Enables AI assistants to analyze GitHub repository structures and read file contents with features like directory traversal, file type analysis, syntax highlighting, and code pattern detection. Supports both public and private repositories through GitHub API integration.
README
🐙 GitHub MCP Server
A powerful Model Context Protocol (MCP) server that enables AI assistants to analyze and read GitHub repositories with ease. Perfect for code analysis, repository exploration, and understanding project structures.
✨ Features
🔍 Repository Structure Analysis
- Complete directory traversal with configurable depth
- File type distribution analysis and statistics
- Project architecture insights with framework detection
- Important file detection (README, package.json, Dockerfile, etc.)
- Visual tree structure representation
- Size analysis and file counting
📖 File Content Reading
- Multi-format support (UTF-8, Base64, Raw)
- Syntax highlighting for 30+ programming languages
- Code analysis with function/class counting
- Pattern detection (TODO comments, async/await, etc.)
- Smart content truncation for large files
- Binary file handling with appropriate encoding
🚀 Advanced Capabilities
- Rate limit optimization with GitHub token support
- Branch-specific analysis (main, develop, feature branches)
- Error handling with detailed troubleshooting
- Session management for efficient API usage
- Streamable HTTP transport for modern AI clients
🛠️ Installation
Quick Start
npm install -g @xingyuchen/github-mcp-server
From Source
git clone https://github.com/guangxiangdebizi/github-mcp-server.git
cd github-mcp-server
npm install
npm run build
⚙️ Configuration
Environment Setup
-
Copy environment template:
cp .env.example .env -
Configure your settings:
# GitHub Personal Access Token (recommended for higher rate limits) GITHUB_TOKEN=your_github_token_here # Server Configuration PORT=3000 # Optional: Default repository DEFAULT_REPO=owner/repository
GitHub Token Setup
For optimal performance and access to private repositories:
- Go to GitHub Settings > Developer settings > Personal access tokens
- Generate a new token with
reposcope - Add it to your
.envfile
🚀 Usage
Starting the Server
# Production mode
npm start
# Development mode
npm run dev
# HTTP mode (recommended)
npm run start:http
The server will start at http://localhost:3000 with the MCP endpoint at /mcp.
Client Configuration
Add to your AI client's MCP configuration:
{
"mcpServers": {
"github-analyzer": {
"type": "streamableHttp",
"url": "http://localhost:3000/mcp",
"timeout": 600
}
}
}
🔧 Available Tools
1. analyze_repository_structure
Analyze the complete structure and architecture of a GitHub repository.
Parameters:
owner(required): Repository owner/organizationrepo(required): Repository namepath(optional): Specific directory to analyzebranch(optional): Branch name (default: main)max_depth(optional): Maximum traversal depth (1-5, default: 3)
Example:
{
"owner": "microsoft",
"repo": "vscode",
"branch": "main",
"max_depth": 3
}
2. read_repository_file
Read and analyze the contents of a specific file from a GitHub repository.
Parameters:
owner(required): Repository owner/organizationrepo(required): Repository namepath(required): File path within the repositorybranch(optional): Branch name (default: main)encoding(optional): File encoding (utf8/base64/raw, default: utf8)max_size(optional): Maximum file size in bytes (default: 1MB, max: 5MB)
Example:
{
"owner": "microsoft",
"repo": "vscode",
"path": "src/vs/code/electron-main/main.ts",
"branch": "main"
}
📊 Example Output
Repository Structure Analysis
# 📊 Repository Structure Analysis
## 📋 Repository Information
- **Repository:** microsoft/vscode
- **Description:** Visual Studio Code
- **Language:** TypeScript
- **Stars:** 150,000 ⭐
- **Forks:** 25,000 🍴
## 📁 Directory Structure
📁 src/
📁 vs/
📄 main.ts (15.2 KB)
📁 workbench/
📄 workbench.main.ts (8.5 KB)
## 📈 Statistics
- **Total Files:** 12,450
- **Total Directories:** 1,200
- **Total Size:** 145.2 MB
## 🏗️ Project Architecture Insights
🟨 **TypeScript Project** - Modern web development stack detected
📦 **Node.js Ecosystem** - Uses npm package management
🐳 **Containerized** - Docker deployment ready
File Content Analysis
# 📄 File Content Analysis
## 📋 File Information
- **Repository:** microsoft/vscode
- **File Path:** `src/main.ts`
- **Branch:** main
## 📊 Content Analysis
**File Type:** TypeScript
**Size:** 15.2 KB
**Lines:** 450
**Functions:** 12
**Classes:** 3
**Imports:** 25
## 📝 File Content
```typescript
import { app, BrowserWindow } from 'electron';
// ... (file content with syntax highlighting)
🔍 Health Check
Monitor server status:
curl http://localhost:3000/health
Response:
{
"status": "healthy",
"transport": "streamable-http",
"activeSessions": 2,
"serverInfo": {
"name": "GitHub-MCP",
"version": "1.0.0"
}
}
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
📝 License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
👨💻 Author
Xingyu Chen
- 🌐 LinkedIn: Xingyu Chen
- 📧 Email: guangxiangdebizi@gmail.com
- 🐙 GitHub: @guangxiangdebizi
- 📦 NPM: @xingyuchen
🙏 Acknowledgments
- Built with the Model Context Protocol SDK
- Powered by GitHub REST API
- Inspired by the need for better AI-repository integration
<div align="center"> <strong>⭐ Star this repository if you find it helpful! ⭐</strong> </div>
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。