oms0401/repopack-MCP-git-flatner
If you are the rightful owner of repopack-MCP-git-flatner and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
RepoStack is a Model Context Protocol (MCP) server designed to transform GitHub repositories into a single, formatted file for analysis by Claude.
🚀 Repopack - GitHub Repository Flattener for Claude
Pack entire GitHub repositories into Claude-ready context in seconds.
RepoStack is a powerful Model Context Protocol (MCP) server that transforms any GitHub repository into a single, beautifully formatted file that Claude can analyze instantly. No more manual copying, no more missing files—just pure codebase intelligence.
🎯 What It Does
RepoStack empowers Claude to:
- 📦 Instant Access - Fetch any GitHub repository with a single command
- 🔍 Smart Extraction - Automatically identifies and extracts relevant code files
- 📄 Perfect Formatting - Concatenates everything into a clean, navigable document
- 🤖 Full Context - Gives Claude the complete picture of any codebase
Perfect for code reviews, security audits, documentation generation, learning new frameworks, architecture analysis, and technical interviews.
✨ Features
- ✅ Public & Private Repos - Works with any GitHub repository
- ✅ Intelligent Filtering - Excludes dependencies, build files, and noise
- ✅ 40+ Languages - Python, JavaScript, TypeScript, Go, Rust, and more
- ✅ Configurable Limits - Control how many files to include
- ✅ Auto Branch Detection - Finds main/master automatically
- ✅ Beautiful Output - Clean separators and file headers
- ✅ Lightning Fast - Async operations for maximum speed
🎬 Demo
You: "RepoStack, analyze https://github.com/facebook/react"
Claude: *fetches entire React codebase*
"React is a declarative JavaScript library for building user interfaces..."
*provides deep insights from the actual source code*
📋 Prerequisites
- Python 3.8+ installed on your system
- Claude Desktop application
- GitHub Account (for private repos)
🚀 Quick Start
Step 1: Installation
# Clone RepoStack
git clone <your-repo-url>
cd repostack
# Install dependencies
pip install fastmcp httpx
💡 Pro Tip: Use a virtual environment:
python -m venv venv
venv\Scripts\activate # Windows
source venv/bin/activate # macOS/Linux
pip install fastmcp httpx
Step 2: Configure Claude Desktop
Windows 🪟
- Press
Win + Rand type:%APPDATA%\Claude - Create or edit
claude_desktop_config.json - Add this configuration:
{
"mcpServers": {
"repostack": {
"command": "python",
"args": ["D:\\path\\to\\repostack\\github_flattener.py"]
}
}
}
macOS 🍎
code ~/Library/Application\ Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"repostack": {
"command": "python3",
"args": ["/path/to/repostack/github_flattener.py"]
}
}
}
Linux 🐧
nano ~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"repostack": {
"command": "python3",
"args": ["/path/to/repostack/github_flattener.py"]
}
}
}
Step 3: Restart Claude
Important: Completely quit Claude Desktop (not just minimize) and restart it.
💬 Usage
Simply chat with Claude naturally:
🎯 Basic Commands
"Flatten https://github.com/openai/whisper"
"Use RepoStack on github.com/vercel/next.js"
"Analyze the codebase at https://github.com/microsoft/typescript"
🎨 Creative Prompts
Code Review:
"RepoStack https://github.com/user/project and review the code quality"
Security Audit:
"Find security vulnerabilities in https://github.com/user/webapp"
Architecture Analysis:
"Explain the architecture of https://github.com/nestjs/nest"
Learning:
"How does https://github.com/django/django handle authentication?"
Documentation:
"Create comprehensive docs for https://github.com/user/api"
Migration Planning:
"How would I migrate https://github.com/user/js-app to TypeScript?"
⚙️ Configuration
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
repo_url | string | ✅ Yes | - | GitHub URL or owner/repo format |
github_token | string | ❌ No | None | Personal access token for private repos |
max_files | number | ❌ No | 100 | Maximum files to include (prevents overwhelming context) |
Examples
Limit files:
"Flatten https://github.com/large/repo with max 50 files"
Private repository:
"Flatten https://github.com/user/private with token ghp_your_token_here"
🔐 Private Repositories
For private repositories, you'll need a GitHub Personal Access Token:
- Visit https://github.com/settings/tokens
- Click "Generate new token (classic)"
- Name it:
RepoStack MCP - Select scope:
repo(Full control of private repositories) - Click "Generate token"
- Copy and save your token securely
Usage:
"Flatten https://github.com/mycompany/private-api with token ghp_abc123xyz"
📁 Supported File Types
RepoStack intelligently includes:
Languages
py js ts jsx tsx java cpp c h cs go rs rb php swift kt scala r m sh
Web
html css scss sass less vue svelte
Config
json yaml yml toml xml md txt
Special
Makefile Dockerfile .gitignore .env.example
🚫 Auto-Excluded
RepoStack automatically skips:
- 📁 Dependencies:
node_modules/,vendor/,dist/,build/ - 🔒 Cache:
__pycache__/,.next/,.nuxt/,coverage/ - 🔐 Env:
venv/,env/,.venv/ - 📦 Lock files:
package-lock.json,yarn.lock,pnpm-lock.yaml - 🗜️ Minified:
.min.js,.min.css,bundle.js
🐛 Troubleshooting
"ModuleNotFoundError: No module named 'fastmcp'"
pip install fastmcp httpx
"Server disconnected immediately"
Check your Python path:
where python # Windows
which python3 # macOS/Linux
Update your config with the full path:
{
"mcpServers": {
"repostack": {
"command": "C:\\Python313\\python.exe",
"args": ["D:\\path\\to\\github_flattener.py"]
}
}
}
"GitHub API rate limit exceeded"
You've hit GitHub's rate limit (60 requests/hour without auth).
Solution: Add a GitHub token to increase limit to 5,000/hour.
"Can't see RepoStack in Claude"
- ✅ Verify config file has no JSON syntax errors
- ✅ Completely quit and restart Claude Desktop
- ✅ Check logs: Claude → Help → View Logs
- ✅ Test the server independently (see Testing section)
"Repository not found (404)"
- Verify the repository URL is correct
- For private repos, ensure you're using a valid token
- Check that the repository hasn't been deleted or renamed
🧪 Testing
Method 1: MCP Inspector (Recommended)
npx @modelcontextprotocol/inspector
Connect with:
- Command:
python(or full path) - Args:
D:\path\to\github_flattener.py
Method 2: Direct Test Script
Create test.py:
import asyncio
import httpx
import os
# Copy the helper functions from your main file
CODE_EXTENSIONS = {
'.py', '.js', '.ts', '.jsx', '.tsx', '.java', '.cpp', '.c', '.h', '.hpp',
'.cs', '.go', '.rs', '.rb', '.php', '.swift', '.kt', '.scala', '.r',
'.m', '.mm', '.sh', '.bash', '.zsh', '.sql', '.html', '.css', '.scss',
'.sass', '.less', '.vue', '.svelte', '.json', '.yaml', '.yml', '.toml',
'.xml', '.md', '.txt', '.gitignore', '.env.example', 'Makefile', 'Dockerfile'
}
EXCLUDE_PATTERNS = {
'package-lock.json', 'yarn.lock', 'pnpm-lock.yaml',
'.min.js', '.min.css', 'bundle.js'
}
async def fetch_repo_tree(owner: str, repo: str, token: str = None):
url = f"https://api.github.com/repos/{owner}/{repo}/git/trees/main?recursive=1"
headers = {"Accept": "application/vnd.github.v3+json"}
if token:
headers["Authorization"] = f"token {token}"
async with httpx.AsyncClient() as client:
response = await client.get(url, headers=headers, timeout=30.0)
if response.status_code == 404:
url = f"https://api.github.com/repos/{owner}/{repo}/git/trees/master?recursive=1"
response = await client.get(url, headers=headers, timeout=30.0)
response.raise_for_status()
data = response.json()
return data.get("tree", [])
async def fetch_file_content(owner: str, repo: str, path: str, token: str = None):
url = f"https://raw.githubusercontent.com/{owner}/{repo}/main/{path}"
headers = {}
if token:
headers["Authorization"] = f"token {token}"
async with httpx.AsyncClient() as client:
response = await client.get(url, headers=headers, timeout=30.0)
if response.status_code == 404:
url = f"https://raw.githubusercontent.com/{owner}/{repo}/master/{path}"
response = await client.get(url, headers=headers, timeout=30.0)
if response.status_code == 200:
try:
return response.text
except:
return f"[Binary file: {path}]"
return ""
def should_include_file(path: str):
for pattern in EXCLUDE_PATTERNS:
if pattern in path:
return False
ignore_dirs = ['node_modules/', '.git/', 'dist/', 'build/', '__pycache__/',
'venv/', 'env/', '.next/', '.nuxt/', 'coverage/']
if any(ignore_dir in path for ignore_dir in ignore_dirs):
return False
_, ext = os.path.splitext(path)
filename = os.path.basename(path)
return ext.lower() in CODE_EXTENSIONS or filename in CODE_EXTENSIONS
async def test_flatten(repo_url: str, max_files: int = 20):
"""Test the flattening logic directly"""
repo_url = repo_url.strip().rstrip('/')
if "github.com/" in repo_url:
parts = repo_url.split("github.com/")[1].split("/")
owner, repo = parts[0], parts[1]
else:
parts = repo_url.split("/")
owner, repo = parts[0], parts[1]
print(f"Fetching repo: {owner}/{repo}")
tree = await fetch_repo_tree(owner, repo)
print(f"Total items in tree: {len(tree)}")
files_to_fetch = [
item for item in tree
if item["type"] == "blob" and should_include_file(item["path"])
][:max_files]
print(f"Files to fetch: {len(files_to_fetch)}")
output_lines = [
f"# Flattened Repository: {owner}/{repo}",
f"# Total files included: {len(files_to_fetch)}",
"=" * 80,
""
]
for item in files_to_fetch:
path = item["path"]
print(f"Fetching: {path}")
content = await fetch_file_content(owner, repo, path)
if content:
output_lines.extend([
"",
f"{'=' * 80}",
f"# FILE: {path}",
f"{'=' * 80}",
content,
""
])
result = "\n".join(output_lines)
return result
async def main():
result = await test_flatten(
repo_url="https://github.com/fastmcp/fastmcp",
max_files=10
)
print("\n" + "="*80)
print("RESULT (first 2000 chars):")
print("="*80)
print(result[:2000])
print(f"\n... (Total length: {len(result)} characters)")
if __name__ == "__main__":
asyncio.run(main())
Run:
python test.py
📊 Performance
RepoStack is optimized for speed:
- Small repos (<50 files): ~2-5 seconds
- Medium repos (50-200 files): ~5-15 seconds
- Large repos (200+ files): ~15-30 seconds
Times vary based on network speed and file sizes
🔒 Security & Privacy
- ✅ All data stays between you, GitHub, and Claude
- ✅ No data is stored or logged by RepoStack
- ✅ Tokens are used only for API authentication
- ✅ Open source - audit the code yourself
🛠️ Development
Project Structure
repostack/
├── github_flattener.py # Main MCP server
├── requirements.txt # Dependencies
├── README.md # This file
├── LICENSE # MIT License
└── tests/ # Test files
└── test_mcp.py
Contributing
We love contributions!
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
📝 Requirements
Create requirements.txt:
fastmcp>=0.1.0
httpx>=0.27.0
Install:
pip install -r requirements.txt
🎓 Use Cases
For Developers
- 🔍 Quick codebase exploration
- 🐛 Bug hunting across large projects
- 📚 Learning from popular open-source projects
- 🔄 Refactoring assistance
For Teams
- 👀 Code review automation
- 📖 Documentation generation
- 🏗️ Architecture analysis
- 🔐 Security audits
For Learners
- 📖 Study real-world codebases
- 🎯 Understand design patterns
- 🚀 Learn best practices
- 💡 Get explanations of complex code
🌟 Pro Tips
- Start Small: Test with smaller repos first (< 50 files)
- Use Tokens: Always use a GitHub token to avoid rate limits
- Limit Files: Use
max_filesfor very large repositories - Be Specific: Ask Claude specific questions about the code
- Combine Tools: Use with Claude's other tools for maximum power
📜 License
MIT License - use it, modify it, ship it! See LICENSE file for details.
🙏 Credits
Built with love using:
- FastMCP - Simplified MCP development
- httpx - Modern async HTTP
- Model Context Protocol - By Anthropic
📞 Support
Need help? Here's how to get it:
- 📖 Check the Troubleshooting section
- 🔍 Review MCP Documentation
- 💬 Open an
- 📧 Contact: your-email@example.com
🚀 What's Next?
Upcoming features:
- Support for GitLab and Bitbucket
- Custom file filtering rules
- Diff analysis between branches
- Direct Git clone support
- Repository comparison tool
- Code statistics and insights
⭐ If RepoStack helped you, give it a star on GitHub!
Made with ❤️ by Om Manoj Sharma for the developer community