Skip to main content
Glama

repo-context-mcp

MCP server that helps AI coding agents understand a repository — without dumping the entire monorepo into the prompt.

CI License: MIT Node.js >= 18 MCP

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

repo_map

Lightweight tree + manifests/entrypoints

search_code

Fast substring search with path:line hits

pack_context

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-mcp

Requires 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 --json

After global install / npx:

npx repo-context-mcp map .
npx repo-context-mcp pack . --focus auth

MCP 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.js

From this repository after build:

npm run build
node dist/cli.js serve
# or: node dist/server.js

See also examples/mcp-config.claude.json and examples/mcp-config.local.json.

Optional env:

Variable

Meaning

REPO_CONTEXT_ROOT

Default repository root when tools omit root

Each tool also accepts an explicit root argument.

Tools

repo_map

root?: string
max_depth?: number      # default 6
max_entries?: number    # default 400

Returns 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?: boolean

Substring 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 40

Ranks 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:

  • .gitignore respect

  • CLI (map / search / pack) + --json

  • GitHub Action: pack context on each PR

  • Optional ripgrep backend for large monorepos

  • Baseline symbol index (tree-sitter) for find_symbol

  • Configurable ignore file (.repo-contextignore)

Contributing

See CONTRIBUTING.md.

npm install
npm test
npm run lint
npm run build

License

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 tools
pack_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.

ParametersJSON Schema
NameRequiredDescriptionDefault
rootNoRepository root. Defaults to REPO_CONTEXT_ROOT or cwd.
focusNoKeywords or path fragments to prioritize (e.g. ['auth', 'src/api']).
max_filesNoMaximum files to include (default 40).
max_tokensNoApproximate token budget (default 12000).

TDQS

A4.2/5.0
Behavior4/5

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.

Conciseness5/5

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.

Completeness4/5

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.

Parameters3/5

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.

Purpose5/5

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.

Usage Guidelines4/5

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
rootNoAbsolute or relative path to the repository root. Defaults to REPO_CONTEXT_ROOT or cwd.
max_depthNoMaximum directory depth (default 6).
max_entriesNoMaximum files to include (default 400).

TDQS

A4.2/5.0
Behavior4/5

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.

Conciseness5/5

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.

Completeness4/5

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.

Parameters3/5

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.

Purpose5/5

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.

Usage Guidelines4/5

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
rootNoRepository root. Defaults to REPO_CONTEXT_ROOT or cwd.
queryYesSubstring to search for.
max_resultsNoMaximum hits (default 50).
case_sensitiveNoCase-sensitive search (default false).

TDQS

A4.2/5.0
Behavior4/5

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.

Conciseness5/5

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.

Completeness4/5

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.

Parameters3/5

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.

Purpose5/5

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.

Usage Guidelines4/5

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

A4.4/5.0
Disambiguation5/5

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.

Naming Consistency5/5

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.

Tool Count5/5

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.

Completeness5/5

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

ActivityMaintained
ResponsivenessSyncing

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

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    An 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.
    119
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    An MCP server that gives AI agents structured code understanding and precise code intelligence via local indexing of AST, call graphs, and semantic search.
    76
    4
    Apache 2.0
  • A
    license
    A
    quality
    B
    maintenance
    An MCP server that helps AI agents comprehend a codebase by providing tools for navigating, searching, and understanding code structure and history.
    10
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Universal MCP server that analyzes any codebase and provides structured context to AI assistants. Dynamic, accurate, and token-efficient.
    14
    MIT

Latest Blog Posts

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