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.
- 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
- 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
- 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
npm install -g @xingyuchen/github-mcp-server
git clone https://github.com/guangxiangdebizi/github-mcp-server.git
cd github-mcp-server
npm install
npm run build
-
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
For optimal performance and access to private repositories:
- Go to GitHub Settings > Developer settings > Personal access tokens
- Generate a new token with
repo
scope - Add it to your
.env
file
# 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
.
Add to your AI client's MCP configuration:
{
"mcpServers": {
"github-analyzer": {
"type": "streamableHttp",
"url": "http://localhost:3000/mcp",
"timeout": 600
}
}
}
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
}
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"
}
# π 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 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)
Monitor server status:
curl http://localhost:3000/health
Response:
{
"status": "healthy",
"transport": "streamable-http",
"activeSessions": 2,
"serverInfo": {
"name": "GitHub-MCP",
"version": "1.0.0"
}
}
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
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Xingyu Chen
- π LinkedIn: Xingyu Chen
- π§ Email: guangxiangdebizi@gmail.com
- π GitHub: @guangxiangdebizi
- π¦ NPM: @xingyuchen
- Built with the Model Context Protocol SDK
- Powered by GitHub REST API
- Inspired by the need for better AI-repository integration