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 "Install 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-mcpMap 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.
| Name | Required | Description | Default |
|---|---|---|---|
| root | No | Repository root. Defaults to REPO_CONTEXT_ROOT or cwd. | |
| focus | No | Keywords or path fragments to prioritize (e.g. ['auth', 'src/api']). | |
| max_files | No | Maximum files to include (default 40). | |
| max_tokens | No | Approximate token budget (default 12000). |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden. It discloses meaningful behavioral details: token budgeting, relevance ranking, and the heuristic 'Prefer entrypoints and paths matching focus keywords'. However, it does not describe output structure or potential side effects, which keeps it from a 5.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is only two sentences, front-loaded with the core purpose and followed by usage guidance. Every word contributes value, with no redundancy or filler.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a relatively simple tool with a fully described 4-parameter schema and no output schema, the description covers purpose, usage, and selection behavior. It could mention the exact structure of the markdown bundle, but it is largely complete for the tool's complexity.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has 100% coverage of all four parameters with clear descriptions. The tool description adds little beyond the schema, only reinforcing the role of 'focus' keywords. Baseline 3 is appropriate since the schema does the heavy lifting.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool 'packs a token-budgeted markdown bundle of the most relevant source files for an LLM', with a specific verb and resource. It also distinguishes from siblings by implying this assembles context rather than just mapping or searching code.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Provides explicit use cases: 'Use for PR review or task kickoff.' This gives clear context for when to use the tool, but it does not explicitly name alternatives or when-not-to-use conditions, so it falls short of a 5.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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.
| Name | Required | Description | Default |
|---|---|---|---|
| root | No | Absolute or relative path to the repository root. Defaults to REPO_CONTEXT_ROOT or cwd. | |
| max_depth | No | Maximum directory depth (default 6). | |
| max_entries | No | Maximum files to include (default 400). |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the burden for behavioral disclosure. It adds a key behavioral fact: 'Honors .gitignore.' It also implies read-only behavior via 'lightweight map' and orientation. However, it does not elaborate on edge cases (e.g., symlinks, file content exclusion), but for a mapping tool this is adequate.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is just two sentences: the first defines the tool's core function and outputs, the second provides usage guidance and a key behavior. Every sentence earns its place with no waste, and the most critical information is front-loaded.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple 3-parameter tool with no output schema, the description covers the main aspects: what it produces, when to use it, and a notable behavior. It does not detail return format, but that is partially inferred from the listed outputs. Sibling differentiation could be stronger, but overall it is reasonably complete.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, with all three parameters (root, max_depth, max_entries) explained in the schema. The description adds no additional parameter semantics beyond the schema, so the baseline score of 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: 'Build a lightweight repository map: directory tree, file count, and likely entrypoints/manifests.' It specifies the verb (build), resource (repository map), and concrete outputs. This differentiates it from sibling tools like search_code (searching) and pack_context (packing) by framing it as an orientation tool.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description explicitly says 'Use this first to orient before reading files,' providing clear guidance on when to use the tool. It implies an ordering relative to sibling tools but does not explicitly name alternatives or exclusions, so it falls short of a flawless 5.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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.
| Name | Required | Description | Default |
|---|---|---|---|
| root | No | Repository root. Defaults to REPO_CONTEXT_ROOT or cwd. | |
| query | Yes | Substring to search for. | |
| max_results | No | Maximum hits (default 50). | |
| case_sensitive | No | Case-sensitive search (default false). |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden. It discloses key behaviors: case-insensitive default, return format (path:line hits with surrounding line text), and the skipping of .gitignore and vendor dirs. This goes beyond basic operation and addresses important edge cases.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Three concise sentences, each earning its place: action, return format, and skip behavior. Front-loaded with the primary purpose, no filler or redundancy.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the absence of an output schema, the description properly explains the return format. It covers default behavior and project-ignoring rules. It does not mention max_results default, but the schema covers that, so completeness is high for a search tool.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the baseline is 3. The description adds minimal extra meaning beyond the schema: it restates case-insensitivity (already in schema) and mentions output format, but does not elaborate on parameter semantics beyond what properties already describe.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool searches source files for a substring, with a specific verb ('Search') and resource ('source files'). It also distinguishes itself from siblings (repo_map, pack_context) by its unique focus on substring search with output details (path:line hits).
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides clear context on what the tool does, making it obvious when to use it (e.g., finding string occurrences in code). It does not explicitly mention alternatives, but the siblings are for mapping/packing context, so the usage is clear. It lacks explicit exclusions, but the context is sufficient.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
TDQS
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
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
An MCP server that gives your AI access to the source code and docs of all public github repos
Driflyte MCP server which lets AI assistants query topic-specific knowledge from web and GitHub.
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceAn 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.119MIT
- 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.764Apache 2.0
- AlicenseAqualityBmaintenanceAn MCP server that helps AI agents comprehend a codebase by providing tools for navigating, searching, and understanding code structure and history.10MIT
- AlicenseNot gradedqualityDmaintenanceUniversal MCP server that analyzes any codebase and provides structured context to AI assistants. Dynamic, accurate, and token-efficient.14MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/nduc99911/repo-context-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server