repocontext
This server provides AI coding assistants with token-efficient, task-aware access to a repository's code structure and contents.
get_codebase_map: Generates a compressed AST symbol outline (classes, functions, interfaces) of the entire repository, reducing token usage by ~80%.
extract_relevant_context: Accepts a user query (e.g., "Fix JWT auth error") and returns only the most relevant code files, pruned by semantic ranking, within a configurable token budget.
read_file_outline: Returns a compressed skeleton of a single file’s public API (signatures and docstrings) without implementation details, saving tokens.
Note: The server integrates with MCP-compatible clients (Claude, Cursor, Windsurf) and supports automated secret redaction, though the schema shows only the three tools above.
⚡ RepoContext
The Next-Generation AST Codebase Map, Token Compression, and Context Packaging Engine for AI Coding Agents and IDEs.
🌟 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.
Related MCP server: AtlasMemory
🚀 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.md2. Global Installation
npm install -g repocontext🛠️ CLI Usage & Options
# 1. Pack with direct clipboard copy (ready to paste into ChatGPT/Claude)
repocontext pack -c
# 2. Pack relevant files only based on task query
repocontext pack -q "Fix JWT auth expiration" -o prompt.md
# 3. Generate AST symbol map
repocontext map -c
# 4. Analyze token distribution without writing a file
repocontext analyze .Options for pack:
Option | Description | Default |
| Packing mode: |
|
| Filter and rank files relevant to coding prompt | None |
| Output format: |
|
| Output file path |
|
| Maximum token budget |
|
| Copy output directly to system clipboard |
|
| Disable automated secret redaction |
|
🔌 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 (4-Tier Context Pyramid):
get_codebase_map: Extracts token-efficient AST symbol outline map across the repository (~80% token savings).extract_relevant_context: Prunes codebase using semantic ranking to return files pertinent to a task prompt.read_file_outline: Reads compressed AST skeleton for an individual file (signatures & docstrings).read_file_content: Precise source code reading with optional line-range slicing (startLine/endLine) and automated credential masking.
📊 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.
Available Tools
4 toolsextract_relevant_contextA
Performs semantic relevance ranking to extract and package code files pertinent to a specific user coding task or bug report within a token budget.
Behavior: Read-only operation. Zero file modifications, zero persistent side-effects, and zero network calls. Applies automatic secret redaction. Returns formatted Markdown.
When to use: Use this when given a specific feature request, issue, or debugging objective to gather only the essential source code.
When NOT to use: Do NOT use this for full-repository structural overviews (use get_codebase_map instead), or to inspect single file outlines (use read_file_outline instead).
Inputs: query (required), rootDir, maxTokens.
get_codebase_mapA
Extracts a token-efficient AST symbol outline map (classes, interfaces, functions, methods, exported types) across the repository.
Behavior: Read-only operation. Zero file modifications, zero persistent side-effects, and zero network calls. Returns structured Markdown.
When to use: Call this at the start of a coding task to inspect repository architecture, directory structure, and symbol hierarchies with 70%~85% token savings.
When NOT to use: Do NOT use this if you need full function implementations (use read_file_content instead), or if you already know the target task and want only relevant files (use extract_relevant_context instead).
Inputs: rootDir.
read_file_contentA
Reads raw source code from a single file, with optional line-range slicing and automatic security redaction for secrets and sensitive keys.
Behavior: Read-only operation. Zero file modifications and zero network calls. Automatically masks detected credentials. Returns formatted Markdown code block with line indicators.
When to use: Use this when you must inspect, debug, or verify exact line-by-line implementation logic of a specific file identified through previous outline or mapping steps.
When NOT to use: Do NOT use this for blind exploration of unfamiliar files (use read_file_outline or get_codebase_map first to conserve token budget).
Inputs: filePath (required), endLine, rootDir, startLine.
read_file_outlineA
Extracts the semantic AST skeleton outline of a single source file, preserving all class declarations, function signatures, interfaces, and docstrings while stripping function bodies.
Behavior: Read-only operation. Zero file modifications and zero network calls. Returns syntax-highlighted code block.
When to use: Use this to understand API contracts, public types, and method signatures of an individual file without consuming tokens on implementation details.
When NOT to use: Do NOT use this if you need complete implementation logic (use read_file_content instead), or if you need an overview of multiple repository files (use get_codebase_map instead).
Inputs: filePath (required), rootDir.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool serves a clearly distinct purpose: repo-wide symbol map, task-specific file extraction, single-file outline, and full file content. The descriptions include explicit 'when to use' and 'when NOT to use' guidance, eliminating any potential for misselection.
All four tools follow the verb_noun snake_case pattern (get_codebase_map, extract_relevant_context, read_file_outline, read_file_content). While the verbs differ (get, extract, read), the structure is consistent and the names accurately reflect each tool's function.
With exactly 4 tools, the server is well-scoped for its purpose of repository context exploration. Each tool fills a distinct role in the workflow, and there is no redundancy or unnecessary bloat.
The tool set covers the full lifecycle of code exploration: repo-wide mapping, semantic relevance filtering for tasks, single-file outlines, and raw content access. This provides a complete read-only context-gathering workflow with no obvious dead ends or missing operations.
Maintenance
Related MCP Connectors
Code intelligence platform for AI agents. 20 tools for architecture, security & impact analysis.
Codebase intelligence for AI coding agents: graph, git history, docs, decisions, code health.
Deterministic context layer for your codebase: change impact, blast radius, answers with receipts.
Codebase intelligence for AI agents — dead code, blast radius, ownership.
Related MCP Servers
- AlicenseAqualityDmaintenanceProvides intelligent code context and analysis through semantic compression, AST parsing, and multi-language support. Offers 60-80% token reduction while enabling AI assistants to understand codebases through local analysis, OpenAI-enhanced insights, and GitHub repository integration.626 npm3MIT
- AlicenseNot gradedqualityDmaintenanceTurn any codebase into an AI-readable neural map — with proof. Every claim linked to code anchors (line + SHA-256 hash), every context window optimized with greedy token budgeting, every session protected by drift detection. Tree-sitter indexing across 11 languages, cross-session learning, AI enrichment, and 28 MCP tools. Zero config — just connect and your AI agent remembers everything.3 npm14GPL 3.0
- AlicenseNot gradedqualityDmaintenanceTransforms codebases into a knowledge graph for AI agents, enabling semantic search, impact analysis, and persistent session memory with up to 94% token savings.3 npm15ISC
- AlicenseNot gradedqualityDmaintenanceMake any LLM a codebase expert instantly. Provides deep code intelligence through semantic search, architecture mapping, security analysis, and smart context that fits perfectly in token windows.MIT