repo-context-mcp
This server provides three focused MCP tools to help AI coding agents understand a repository efficiently without dumping the entire codebase:
repo_map: Generates a lightweight repository map with directory tree, file count, and likely entrypoints/manifests. Respects
.gitignoreand supports configurable depth (up to 20 levels) and entry limits (up to 5,000 files).search_code: Performs fast substring search across source files, returning
path:linehits with surrounding context. Case-insensitive by default with optional case sensitivity, skips.gitignoreand vendor directories, and can return up to 500 results.pack_context: Creates a token-budgeted markdown bundle of the most relevant source files, prioritizing entrypoints and focus keywords. Supports configurable file count (up to 200) and token budget (up to 200,000 tokens), ideal for LLM prompts, PR reviews, or task kickoffs.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@repo-context-mcp Map the repo and pack context for the auth module"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
repo-context-mcp
MCP server that helps AI coding agents understand a repository — without dumping the entire monorepo into the prompt.
Works with Codex, Claude Code, Cursor, Cline, and any client that speaks Model Context Protocol.
Why
AI agents waste tokens re-walking node_modules, missing entrypoints, or pasting random files. repo-context-mcp exposes three focused tools:
Tool | Purpose |
| Lightweight tree + manifests/entrypoints |
| Fast substring search with path:line hits |
| Token-budgeted markdown pack for LLM prompts |
Local-only. No cloud. No telemetry. Stdio transport.
Related MCP server: codeweave-mcp
Install
# run from source
git clone https://github.com/nduc99911/repo-context-mcp.git
cd repo-context-mcp
npm install
npm run build
# or via npx (after publish)
npx -y repo-context-mcpRequires Node.js 18+.
CLI (no MCP client)
npm run build
# repository map
node dist/cli.js map .
node dist/cli.js map examples/sample-repo
# search
node dist/cli.js search login examples/sample-repo
# token-aware pack
node dist/cli.js pack . --focus auth,api --max-tokens 8000
# JSON for scripts / CI
node dist/cli.js map . --json
node dist/cli.js pack . --focus src --jsonAfter global install / npx:
npx repo-context-mcp map .
npx repo-context-mcp pack . --focus authMCP client config
Claude Desktop / Claude Code
{
"mcpServers": {
"repo-context": {
"command": "npx",
"args": ["-y", "repo-context-mcp"],
"env": {
"REPO_CONTEXT_ROOT": "/absolute/path/to/your/repo"
}
}
}
}Cursor
Settings → MCP → add server with command npx and args ["-y", "repo-context-mcp"].
Codex / generic stdio
REPO_CONTEXT_ROOT=/path/to/repo node /path/to/repo-context-mcp/dist/server.jsFrom this repository after build:
npm run build
node dist/cli.js serve
# or: node dist/server.jsSee also examples/mcp-config.claude.json and examples/mcp-config.local.json.
Optional env:
Variable | Meaning |
| Default repository root when tools omit |
Each tool also accepts an explicit root argument.
Tools
repo_map
root?: string
max_depth?: number # default 6
max_entries?: number # default 400Returns a markdown tree, file count, and likely entrypoints (package.json, README.md, src/index.ts, AGENTS.md, …). Skips node_modules, .git, dist, etc.
search_code
query: string
root?: string
max_results?: number # default 50
case_sensitive?: booleanSubstring search across source-like extensions.
pack_context
root?: string
focus?: string[] # keywords / path fragments to prioritize
max_tokens?: number # default 12000 (approx)
max_files?: number # default 40Ranks files (entrypoints + focus matches), respects a rough token budget (~4 chars/token), and returns a single markdown document ready to paste into an agent prompt or PR review.
Library API
You can use the core without MCP:
import {
buildRepoMap,
formatRepoMap,
searchCode,
packContext,
} from "repo-context-mcp";
const map = buildRepoMap({ root: process.cwd() });
console.log(formatRepoMap(map));
const hits = searchCode({ root: process.cwd(), query: "TODO" });
const pack = packContext({
root: process.cwd(),
focus: ["auth"],
maxTokens: 8000,
});
console.log(pack.markdown);Demo (no MCP client)
npm install
npm test
npm run build
# map the sample tree
node --input-type=module -e "import { buildRepoMap, formatRepoMap } from './dist/index.js'; console.log(formatRepoMap(buildRepoMap({ root: 'examples/sample-repo' })));"Security
Reads files only under the requested
root.Does not execute project code.
Skips common vendor dirs and obvious binaries.
Still: only point it at repositories you trust.
See SECURITY.md.
Project status
v0.1.1 — MCP server + CLI + gitignore + PR Action.
Roadmap:
.gitignorerespectCLI (
map/search/pack) +--jsonGitHub Action: pack context on each PR
Optional ripgrep backend for large monorepos
Baseline symbol index (tree-sitter) for
find_symbolConfigurable ignore file (
.repo-contextignore)
Contributing
See CONTRIBUTING.md.
npm install
npm test
npm run lint
npm run buildLicense
MIT © Nguyen Duc
Built as a real maintainer / agent-tooling utility for the MCP ecosystem — not a placeholder repo. Issues and PRs welcome.
Available Tools
3 toolspack_contextA
Pack a token-budgeted markdown bundle of the most relevant source files for an LLM. Prefer entrypoints and paths matching focus keywords. Use for PR review or task kickoff.
Inputs: root, focus, max_files, max_tokens.
repo_mapA
Build a lightweight repository map: directory tree, file count, and likely entrypoints/manifests. Use this first to orient before reading files. Honors .gitignore.
Inputs: root, max_depth, max_entries.
search_codeA
Search source files for a substring (case-insensitive by default). Returns path:line hits with surrounding line text. Skips .gitignore and vendor dirs.
Inputs: query (required), root, max_results, case_sensitive.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
Each tool performs a unique, non-overlapping function: repo_map provides structural overview, search_code locates specific lines, and pack_context bundles relevant files for LLM consumption. There is no ambiguity about when to use which tool.
All tool names follow a consistent verb_noun pattern (repo_map, search_code, pack_context) using lowercase with underscores. The naming is uniform and predictable.
With exactly 3 tools, the server is well-scoped for its purpose—providing repo context. Each tool earns its place without redundancy, and the count is neither too sparse nor overwhelming.
The tool set covers the complete workflow of understanding a repository: mapping the structure, searching for specific content, and packing the most relevant files into a context bundle. There are no obvious gaps for the stated purpose.
Maintenance
Related MCP Connectors
An MCP server that gives your AI access to the source code and docs of all public github repos
Shared memory MCP server for Claude Code, Codex, Gemini CLI and Cursor. Cited, editable.
AI tool directory MCP server, live since July 2026. Tools, agents, models, companies, services.
Repository knowledge graph MCP server for codebase understanding and debugging.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceAn MCP server for semantic code search & navigation that helps AI agents work efficiently without burning through costly tokens. Instead of reading entire files, agents can search conceptually and jump directly to the specific functions, classes, and code chunks they need.121MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that gives AI agents structured code understanding and precise code intelligence via local indexing of AST, call graphs, and semantic search.77 npm4Apache 2.0
- AlicenseAqualityDmaintenanceAn MCP server that helps AI agents comprehend a codebase by providing tools for navigating, searching, and understanding code structure and history.10MIT
- AlicenseAqualityDmaintenanceUniversal MCP server that analyzes any codebase and provides structured context to AI assistants. Dynamic, accurate, and token-efficient.1812 npmMIT