mcp-server-repo-context
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., "@mcp-server-repo-context pack this repo into 8000 tokens so I can review the main files"
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.
mcp-server-repo-context
MCP server (Model Context Protocol) that gives Claude Code, Cursor, and other AI coding agents token-budgeted repository context: a directory tree, the files that matter most, code search, and token estimates. Python, zero dependencies.
AI coding agents waste tokens wandering around a repo. This MCP server lets the agent ask for exactly what it needs: "show me the tree", "pack the repo into 8,000 tokens", "search for create_app", "how many tokens is src/?". Everything is read-only and confined to the repository root.
Quick start (under a minute)
Install straight from GitHub (needs Python 3.10+):
pipx install git+https://github.com/metraflaxtech-png/mcp-server-repo-context.git
# or: uvx --from git+https://github.com/metraflaxtech-png/mcp-server-repo-context.git mcp-server-repo-context --helpClaude Code
claude mcp add repo-context -- mcp-server-repo-context serve --root .Cursor (.cursor/mcp.json in your project)
{
"mcpServers": {
"repo-context": {
"command": "mcp-server-repo-context",
"args": ["serve", "--root", "."]
}
}
}Claude Desktop and other MCP clients: use the same command and args, with an absolute path for --root.
No MCP client handy? Use the same engine from the terminal:
mcp-server-repo-context pack --budget 8000 > context.md # paste into any LLMRelated MCP server: TokenSaver MCP
Tools
Tool | What it does |
| Directory tree, respecting |
| Tree plus the most important files in one markdown document that fits |
| One file by repo-relative path, optional line range, with line numbers |
| Case-insensitive text or regex search returning |
| Estimated token cost of a file or directory before you load it |
include / exclude glob lists (for example ["*.py"]) work on repo_tree, pack_repo, search_code, and estimate_tokens.
Example output
mcp-server-repo-context pack --budget 300 on a small project:
<!-- ~98 tokens, 4 files included, 0 skipped -->
# Repository: demo
## Tree
```
├── src/
│ └── app.py
├── tests/
│ └── test_app.py
├── README.md
└── pyproject.toml
```
## File: README.md
```
# Demo API
A tiny Flask-style demo.
```
...A search_code call over stdio:
> {"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"search_code","arguments":{"query":"create_app"}}}
< {"jsonrpc":"2.0","id":2,"result":{"content":[{"type":"text","text":"src/app.py:1: def create_app():"}],"isError":false}}FAQ
What is an MCP server? The Model Context Protocol is an open standard for connecting AI assistants to tools and data. An MCP server exposes tools; clients such as Claude Code and Cursor call them.
How do I add an MCP server to Claude Code?
claude mcp add <name> -- <command> <args>. For this server: claude mcp add repo-context -- mcp-server-repo-context serve --root .
How do I add an MCP server to Cursor?
Add an entry under mcpServers in .cursor/mcp.json, as shown in the quick start.
How are tokens counted? With a fast, dependency-free estimate (roughly 4 characters per token). It is an estimate, not your model's exact tokenizer, so leave some headroom.
Is it safe to point at a private repo?
It is read-only, runs locally over stdio, makes no network calls, and rejects any path that escapes the root (including via symlinks). It does not read files over 256 KB or binary files. Still, whatever the agent reads goes to your model provider, so scope --root and exclude globs accordingly.
Does it work with other agents?
Any client that speaks MCP over stdio should work. It implements initialize, ping, tools/list, and tools/call (protocol versions 2025-06-18, 2025-03-26, 2024-11-05).
Does it respect .gitignore?
Yes, for common patterns: names, globs, trailing-slash directories, and anchored paths. Negation (!pattern) is not supported yet; see the open issues.
Development
python3 -m pip install -e ".[dev]"
python3 -m pytestCI runs the tests on Python 3.10–3.13 plus a real stdio smoke test. See CONTRIBUTING.md and the good first issues. Questions or ideas? Open a discussion. Please follow the Code of Conduct.
License
MIT © 2026 Sangram More
More from metraflaxtech-png
agent-toolbelt: ready-to-use skills, rules, and prompts for AI coding agents (Claude Code, Cursor, AGENTS.md)
prompttest: regression-test LLM prompts with YAML suites in CI
agents-md-sync: one source for AGENTS.md, CLAUDE.md, Cursor rules, and Copilot instructions
Available Tools
5 toolsestimate_tokensA
Estimate how many LLM tokens a file or directory would cost before you load it.
Inputs: path, exclude, include.
pack_repoB
Pack the repo tree plus the most important files into one markdown document that fits a token budget. Skipped files are listed, never truncated silently.
Inputs: path, exclude, include, budget_tokens.
read_fileC
Read one text file by repo-relative path, optionally a line range.
Inputs: path (required), end_line, start_line.
repo_treeA
Show the repository directory tree (respects .gitignore). Use first to orient yourself in an unfamiliar codebase.
Inputs: path, exclude, include.
search_codeC
Search the repository for a text or regex query; returns path, line number, and the matching line.
Inputs: query (required), regex, exclude, include, +1 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool targets a clearly distinct operation: tree orientation (repo_tree), bulk packing (pack_repo), single-file read (read_file), content search (search_code), and cost pre-checking (estimate_tokens). The only near-overlap is repo_tree vs pack_repo, but descriptions make it clear one is a listing and the other a budgeted document bundle. An agent can pick correctly without guessing.
Four of five names follow a verb_noun pattern (read_file, search_code, estimate_tokens, pack_repo), all in consistent snake_case. repo_tree is a noun-only name, a minor deviation from the otherwise predictable convention.
Five tools is well-scoped for a read-only repo-context server, and each covers a distinct step in the workflow: orient, pack, read, search, budget. No tool feels redundant or missing at this size.
The surface covers the core read-only lifecycle: discover structure, estimate cost, search, read specific files, and bulk-pack under a token budget. Minor gaps remain, such as glob/filtered file listing or a lightweight existence/size check without reading content, but agents can work around these via repo_tree and search_code.
Maintenance
Related MCP Connectors
Cache source-backed repository context so coding agents can reuse knowledge across sessions.
Securely search and manage workspace context files for AI agents and teams.
Code-map tools for AI agents: see a repo's structure first, then edit only what matters.
Read-only production context for AI agents: Docker/K8s health, deploys, logs, traffic, code graph
Related MCP Servers
- AlicenseNot gradedqualityNot gradedmaintenanceProvides AI agents with secure, read-only file system access to analyze and understand project codebases, enabling multi-repository context aggregation and cross-project code tracing.5MIT
- AlicenseAqualityBmaintenanceEnables coding agents to get a compact, token-budgeted map of any repository in one call, including file tree, language stats, entry points, and key symbols, so they read only what they need.41MIT
- FlicenseNot gradedqualityBmaintenanceEnables AI coding agents to retrieve focused, bounded repository context locally and read-only, reducing token usage while never modifying the repository or executing its code.-

Graphicle MCP Serverofficial
AlicenseBqualityAmaintenanceEnables coding agents to query a repository's code graph and project memory through cited excerpts, navigate symbols and dependencies, and optionally inspect pull requests, all within a configurable token budget.22641Apache 2.0