repocontext
Next-gen AST codebase map, token compression (70%~85% savings), and context packaging engine for AI coding agents & IDEs.
README
⚡ RepoContext
<div align="center">
The Next-Generation AST Codebase Map, Token Compression, and Context Packaging Engine for AI Coding Agents and IDEs.
</div>
🌟 Why RepoContext?
When feeding codebases into modern AI coding assistants (Claude Code, Cursor, Windsurf, OpenAI Codex, Antigravity, Cline), developers face three critical bottlenecks:
- 💥 Token Explosion & High API Costs: Raw code dumps quickly exceed context limits or cost tens of dollars per query.
- 📉 Low Signal-to-Noise Ratio: 80% of lines are routine implementation details. LLMs only need the semantic API surface (signatures, types, interfaces, docstrings).
- 🔓 Security Leaks: Accidental exposure of
.envcredentials, API keys, and database URIs in prompts.
RepoContext solves all three with intelligent AST outline pruning, task-focused semantic file ranking, automated credential redaction, and native Model Context Protocol (MCP) integration.
🚀 Key Features
- ⚡ AST Codebase Map & Skeletonizer: Compresses source files by 70%~85% while retaining 100% of interfaces, types, functions, and JSDoc/docstrings.
- 🎯 Task-Oriented Relevance Pruning: Pass your prompt query (e.g.
repocontext pack -q "Fix JWT auth token expiry") to automatically rank and pack only the most critical files. - 🛡️ Automated Secret Scanner & Redaction: Built-in entropy and regex scanner detects and masks OpenAI keys, GitHub tokens, AWS keys, JWTs, and database URIs.
- 🔌 Native Model Context Protocol (MCP) Server: Directly integrates with Claude Desktop, Cursor, Windsurf, and Antigravity via standard MCP tools.
- 📑 Multi-Format Export: Generates clean Markdown with directory trees, Claude-optimized XML (
<documents>), or structured JSON. - 📊 Multi-Model Token & Cost Analytics: Real-time token counter with cost estimates for GPT-4o, GPT-5, Claude 3.5 Sonnet, and Gemini 1.5 Pro.
📦 Quick Start
1. Run without installation via npx
# Pack entire repository into an optimized Markdown prompt
npx repocontext pack
# Pack only files relevant to a specific task prompt
npx repocontext pack -q "Implement Stripe payment webhook handler" -o prompt.md
# Generate lightweight AST skeleton map (75%+ token reduction)
npx repocontext map -o codebase-map.md
2. Global Installation
npm install -g repocontext
🛠️ CLI Usage & Options
repocontext pack [dir] [options]
Options:
-m, --mode <mode> Packing mode: full | ast | relevant | hybrid (default: "full")
-q, --query <query> Filter and rank files relevant to a coding task prompt
-f, --format <format> Output format: markdown | xml | json (default: "markdown")
-o, --output <file> Output file path (default: "repocontext-output.md")
-t, --max-tokens <number> Maximum token budget ceiling (default: 80000)
--no-security Disable secret scanning and auto-redaction
-h, --help Display help for command
🔌 Model Context Protocol (MCP) Integration
RepoContext comes with built-in MCP server support. Add it to your claude_desktop_config.json or Cursor/Windsurf MCP settings:
{
"mcpServers": {
"repocontext": {
"command": "npx",
"args": ["-y", "repocontext", "mcp"]
}
}
}
Exposed MCP Tools:
get_codebase_map: Returns AST symbol outline map of the repository.extract_relevant_context: Prunes codebase and returns only files needed for a prompt.read_file_outline: Reads compressed AST skeleton for a single file.
📊 Benchmark & Comparison
| Feature | Raw Concatenation | Repomix | RepoContext |
|---|---|---|---|
| AST Skeleton Pruning | ❌ No | ❌ No | ✅ Yes (80% Token Savings) |
| Task Relevance Ranker | ❌ No | ❌ No | ✅ Yes (Query-guided Pruning) |
| Secret Auto-Redaction | ❌ No | ⚠️ Basic | ✅ Yes (10+ Security Rules) |
| Native MCP Server | ❌ No | ❌ No | ✅ Yes (Claude / Cursor / Windsurf) |
| Multi-Model Cost Est. | ❌ No | ❌ No | ✅ Yes (GPT-4o/5, Claude, Gemini) |
🤝 Contributing
Contributions, issues and feature requests are welcome! Feel free to check issues page.
📄 License
This project is MIT licensed.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.