lean-context
# lean-context
**A local MCP server that gives coding agents just enough code and command output, and keeps the rest one call away.** It measures what that saves.
An agent that greps, then reads three whole files to find one function, then pastes a 2,000-line test run into its context, pays for all of it, every turn it stays in context. lean-context replaces those habits with cheaper ones: ranked snippets instead of grep-and-read, outlines and single symbols instead of whole files, distilled command output instead of raw logs. Runs offline, no API key, no outbound network, no native build step.
```
┌────────────┐ ctx_search "where is the JWT verified" ┌──────────────┐ SQLite FTS5 index ┌───────────┐
│ MCP client │ ───────────────────────────────────────► │ lean-context │ ◄───────────────────► │ your repo │
│ (the model)│ ◄── jwt.ts:76-128 verifyToken + 8 lines ─ │ │ ── spawn, no shell ─► │ npm test │
└────────────┘ └──────────────┘ └───────────┘
```
## Measured, not promised
From `npm run bench` (details, method and limits in [docs/benchmark.md](docs/benchmark.md)); token counts are estimates:
| | baseline | lean-context | median saving | recall |
|---|---|---|---:|---|
| 35 navigation tasks, find and read the answer | grep, read top-3 files | `ctx_search` + `ctx_symbol` | **79.4%** | 34/35 (baseline 35/35) |
| same, against the best case for grep | grep, read files until the right one (oracle stop) | same | **55.5%** | |
| same, only locating the answer | grep, read until found | `ctx_search` | 75.1% | 35/35 |
| 10 command outputs (vitest, jest, tsc, pytest, npm, cargo, go, app log, git log) | raw output, capped at 30k chars | `ctx_run` | **92.9%** | 30/30 error facts kept |
Honest reading: on small files, reading the one right file is cheap, and when grep's own output already shows the definition line, grep wins. The large wins are on descriptive questions, large files and long command output.
## Tokens saved per model
The table above uses the built-in estimate. The same benchmark, re-run under each model family's tokenizer, gives absolute token counts per model. [`bench/models.ts`](bench/models.ts) runs it and writes the tables.
<!-- token-report:start -->
Bundled fixture: 45 files, 35 navigation tasks and 10 command outputs. The benchmark is re-run under each tokenizer, so the engine's budgets are in that tokenizer's units too.
**Finding the answer** (35 tasks; tokens summed over all tasks; the median is per task):
| Model | Counted as | Baseline | Baseline tokens | lean-context tokens | Saved (total) | Median per task |
|---|---|---|---:|---:|---:|---:|
| Claude Fable 5.2, Opus 5.5, Sonnet 5.5, Haiku 5.5 | estimate: o200k_base x 1.2 | grep, read top 3 files | 111,818 | 25,517 | 86,301 (77.2%) | 78.4% |
| | | grep, read until the right file (best case) | 54,516 | 25,517 | 28,999 (53.2%) | 51.5% |
| GPT-6 Astra, Sol, Terra, Luna | o200k_base (assumed for GPT-6) | grep, read top 3 files | 93,184 | 21,265 | 71,919 (77.2%) | 78.4% |
| | | grep, read until the right file (best case) | 45,429 | 21,265 | 24,164 (53.2%) | 51.4% |
| GPT-5.5 | o200k_base | grep, read top 3 files | 93,184 | 21,265 | 71,919 (77.2%) | 78.4% |
| | | grep, read until the right file (best case) | 45,429 | 21,265 | 24,164 (53.2%) | 51.4% |
**Command output** (10 logs; baseline is the raw output capped at 30,000 characters, as Claude Code's Bash tool does):
| Model | Counted as | Baseline tokens | `ctx_run` tokens | Saved (total) | Median per log |
|---|---|---:|---:|---:|---:|
| Claude Fable 5.2, Opus 5.5, Sonnet 5.5, Haiku 5.5 | estimate: o200k_base x 1.2 | 91,654 | 6,754 | 84,900 (92.6%) | 92.6% |
| GPT-6 Astra, Sol, Terra, Luna | o200k_base (assumed for GPT-6) | 76,378 | 6,556 | 69,822 (91.4%) | 91.3% |
| GPT-5.5 | o200k_base | 76,378 | 6,556 | 69,822 (91.4%) | 91.3% |
**Recall under each counter** (a saving that loses the answer is a failure):
| Counter | Navigation: answer found | Baseline (top 5 files) | Logs: error facts kept |
|---|---:|---:|---:|
| heuristic-v1 | 34 of 35 | 35 of 35 | 10 of 10 |
| o200k_base | 34 of 35 | 35 of 35 | 10 of 10 |
| o200k_base x 1.2 (estimate) | 34 of 35 | 35 of 35 | 10 of 10 |
The built-in heuristic (`heuristic-v1`) counted 125,090 tokens for the top-3 baseline where o200k_base counted 93,184 (34.2%), and 88,185 where o200k_base counted 76,378 (15.5%) for the log baseline.
<!-- token-report:end -->
How to read this:
- **The fixture, not your code.** The tasks and logs are the bundled ones. Run `npm run bench -- --repo <dir> --counter o200k` for your own codebase. Savings depend on file size: reading a small file is cheap, so the wins are larger on big files, descriptive questions and long command output.
- **The percentage is the portable result.** Baseline and returned text are counted with the same tokenizer, so the ratio moves far less between tokenizers than the absolute numbers do.
- **OpenAI rows** use `o200k_base`, which is exact for that encoding (the GPT-4o, GPT-4.1 and GPT-5 families). Whether the GPT-6 family uses it is not confirmed, so those rows say "assumed". OpenAI model names come from third-party listings checked on 2026-11-24 and may change.
- **Claude rows are an estimate**: the `o200k_base` count times 1.2, because OpenAI tokenizers undercount Claude by roughly 15–20%, more on code. Exact Claude counts need Anthropic's `count_tokens` endpoint and an API key; the benchmark calls no network service. The Claude rows are therefore not a measurement.
- **Tokens, not dollars.** Cached context is cheaper to resend, so with prompt caching the bill shrinks by less than the token count, while the context window and the model's focus still benefit.
Reproduce, or refresh the tables:
```bash
npm install --no-save gpt-tokenizer # once; leaves package.json alone
npx tsx bench/models.ts --write # re-run under each tokenizer and rewrite the tables above
```
## How it differs from mcp-gate, and using both
[mcp-gate](https://github.com/pi314x/mcp-gate) saves tokens on **tool definitions**: it hides MCP tools a task does not need. lean-context saves tokens on **what the agent reads and what commands print**. They do not overlap: mcp-gate shrinks the fixed cost per turn, lean-context the variable cost per action. Use both: put mcp-gate in front of your many MCP servers, and register lean-context directly (it has seven small tools; routing it through the gate would only add a step).
## Quick start (Claude Code)
Requires Node 22.5 or later (for the built-in `node:sqlite`).
```bash
cd /path/to/lean-context
npm install
npm run build
# in your project (optional, enables ctx_run; review the allowlist first)
cp /path/to/lean-context/lean-context.config.example.json ./lean-context.config.json
# register it for this project
claude mcp add lean-context -- node /path/to/lean-context/dist/index.js --root "$PWD"
```
Then, optionally:
- Append [examples/claude-code/CLAUDE.md](examples/claude-code/CLAUDE.md) to your project's `CLAUDE.md`.
- Install the read guard hook: copy [examples/claude-code/read-guard.mjs](examples/claude-code/read-guard.mjs) to `.claude/hooks/` in your project and merge [examples/claude-code/settings.json](examples/claude-code/settings.json) into `.claude/settings.json`.
- A project `.mcp.json` example is in [examples/claude-code/.mcp.json](examples/claude-code/.mcp.json).
`node dist/index.js --index --root <dir>` builds the index and prints what it found, without serving. The index lives in `<root>/.lean-context/`, which contains a `.gitignore` of `*`, so it never shows up in git and your own `.gitignore` is not touched.
### Over Streamable HTTP
stdio is the default and is what a host that spawns the process uses. For a host that connects to a URL, or to serve several clients from one index, run it as an HTTP server:
```bash
export LEAN_CONTEXT_TOKEN=$(node -p "require('crypto').randomBytes(24).toString('hex')") # recommended; see the security notes below
node /path/to/lean-context/dist/index.js --http --root "$PWD" # http://127.0.0.1:3838/mcp
claude mcp add --transport http lean-context http://127.0.0.1:3838/mcp \
--header "Authorization: Bearer $LEAN_CONTEXT_TOKEN"
```
`--host` and `--port` change the address (`LEAN_CONTEXT_HOST`, `LEAN_CONTEXT_PORT`); `--port 0` picks a free port and logs the URL. `/healthz` answers health checks. A project `.mcp.json` example is in [examples/claude-code/.mcp.http.json](examples/claude-code/.mcp.http.json). `npm run start:http` is the same as `node dist/index.js --http`.
The one endpoint serves both protocol eras. What each client keeps to itself:
| Transport | A client is | Its own state |
|---|---|---|
| **stdio** | the process | everything: one process, one client |
| **Streamable HTTP, 2025-era client** | its `Mcp-Session-Id` | an engine of its own: the "unchanged since earlier" memory, stored `ctx_run` output (its handles), the session statistics |
| **Streamable HTTP, 2026-07-28 client** | stateless, so a scope: the authenticated client id, else the `x-lean-context-scope` header, else one shared scope | the same, per scope; the shared scope never answers "unchanged" |
The index, its file watcher and the lifetime statistics are shared by all clients. State is per client because an engine remembers what it returned: shared across clients, it would tell one of them "unchanged since earlier" about lines only another client received, and one client could read another's command output. Without a token or a scope header, stateless clients cannot be told apart and share one scope, which is why that scope never makes the "unchanged" claim. When several clients share an endpoint, give each its own `x-lean-context-scope`, or put authentication in front.
## Tools
| Tool | Returns | Default budget |
|---|---|---|
| `ctx_search({query, budget_tokens?, path_glob?, max_results?})` | Ranked hits: `path:start-end`, the enclosing symbol, a trimmed snippet with line numbers. Overlapping chunks merged, identical copies folded ("same text in …"), weak matches dropped, a count of what the budget left out, and the exact call to expand the top hit. | 1,500 |
| `ctx_outline({path, budget_tokens?})` | Declarations and signatures with line ranges, first line of doc comments, imports collapsed to a count, fields grouped. Typically 3x+ smaller than the file. | 2,000 |
| `ctx_symbol({name, path?, budget_tokens?, force?})` | The full body of a function, class, method, type or constant with line numbers. `Type.method` / `Type::method` qualify; ambiguous names list candidates; unknown names suggest similar ones. | 4,000 |
| `ctx_read({path, start?, end?, budget_tokens?, force?})` | Numbered lines. A whole file over the budget comes back as its outline plus a hint; a range over the budget is cut with `… N lines elided …` and the call to continue. | 3,000 |
| `ctx_run({command, args?, budget_tokens?, cwd?, timeout_ms?})` | Distilled output of an allowlisted command: exit status, a summary for known formats, errors with their stack or code frames, folded repeats (`line (x37)`), head and tail, every gap labelled with its raw line range. The full output is stored under a handle. | 800 |
| `ctx_expand({handle, grep?, context?, start?, end?, tail?, budget_tokens?})` | Part of a stored output: regex matches with line numbers, a range, or the tail. | 2,000 |
| `ctx_stats()` | Tokens returned versus the naive baseline, per tool, this session and all sessions. | |
Every tool's output is cut to `budget_tokens` as a last step, so it never exceeds it (by the server's own estimate). Paths in and out are relative to the project root with forward slashes, on every platform. An identical repeat of a `ctx_read`/`ctx_symbol` in the same session returns a one-line "unchanged" note instead of a second copy (`force: true` gets it again; `dedupeReads: false` turns this off).
Known output formats for `ctx_run`: vitest, jest, tsc, pytest, cargo test, go test, npm/pnpm, git status, git log, git diff. Everything else goes through the generic reducer, which does not depend on recognising the format.
## How savings are accounted
Each call records `returned` (tokens sent) and `baseline` (what an agent without lean-context would plausibly have paid for the same information: the whole files of the top hits for a search, the whole file for an outline or symbol, the raw output for a command, nothing for `ctx_expand`). Baselines are capped like the real tools cap them (Read: 2,000 lines, Bash: 30,000 characters). Full definitions: [docs/accounting.md](docs/accounting.md).
Token counts come from a pluggable `TokenCounter`. The default is a documented heuristic (`heuristic-v1`), not Claude's tokenizer; it has not been calibrated against it and likely over-counts. `ctx_stats` always prints the method. Never read these numbers as billing.
## How retrieval works
- **Index**: SQLite via Node's built-in `node:sqlite` with an FTS5 table (`bm25()` ranking). Verified on Node 22.23: FTS5, `bm25()` and contentless-delete tables are available, so there is no native addon and no hand-written inverted index.
- **Tokens**: identifiers are indexed whole and split (camelCase, PascalCase, snake_case, kebab-case, dotted paths, digits), plus light stems, so `getUserById`, `get_user_by_id` and "get user by id" all meet. Field weights: symbol name 6, path (plus the file's leading doc comment) 2.5, body 1.
- **Chunks**: declaration boundaries from per-language rules (TypeScript/JavaScript, Python, Go, Rust, Java, C#, Solidity; Kotlin and C/C++ only basically and without dedicated tests), Markdown by heading, JSON/YAML/TOML by top-level key, overlapping 40-line windows otherwise. A class or namespace over 20 lines is split into its members; long bodies into windows; small constants and fields are merged. The same detector powers `ctx_outline` and `ctx_symbol`.
- **Queries**: words are identifier-split and stemmed; a small stopword list drops only words that are not also common identifiers (`get`, `list`, `map`, `type`, `error` stay). Terms are OR-ed; a re-rank rewards covering more of the query's rarer terms and halves the score of chunks that cover less than half of three or more terms (a minimum-match rule that degrades instead of returning nothing). Mild priors: functions over constants, implementation over tests, imports and docs unless the query asks for them.
- **Freshness**: incremental indexing keyed on mtime and size, then content hash. A recursive file watcher marks changed files; before every query those are re-indexed, the files about to be shown are re-checked against the disk, and a full re-scan runs every 60 s regardless. Without a watcher (`--no-watch`, or a platform without recursive watch) every query re-scans.
- **Ignored**: `.gitignore` (root and nested), plus defaults: dependency and build folders, caches, lockfiles, logs, binaries, minified files, files over 1 MB.
- **Hybrid retrieval** (off): an `Embedder` interface, vector storage and reciprocal-rank fusion with BM25 exist and are tested with a deterministic hashing "embedder". **No real embedding model is bundled or verified**, so there is no semantic search: a query that shares no words (or word parts) with the code finds nothing.
### Regex, not a parser
Declarations are found by per-language rules over text with strings and comments masked, plus bracket balance. That handles the common shapes well (the tests cover each language), but it is not a parser: unusual formatting, macros that generate code, deeply nested closures, JSX edge cases, C++ templates or a stray unbalanced bracket in a regex literal can produce a wrong end line or a missed declaration. When that happens, `ctx_read` with a range still works.
## Security model of `ctx_run`
`ctx_run` executes programs, so it is **deny by default**: with no configuration it refuses everything.
- Only commands that match a rule in `run.allow` of the configuration file run. A rule names a bare program (no paths), optionally the allowed leading arguments (`"status"`, `"run test*"`), and argument patterns that are always refused (`-c`, `--output*`, `--no-index`, …). See [lean-context.config.example.json](lean-context.config.example.json) for a conservative list: read-only git, test/build scripts, `tsc`, `vitest`, `pytest`, `cargo test|check|clippy`, `go test|vet`.
- Commands run through `spawn` **without a shell**, so `;`, `&&`, `|`, `$(...)` and backticks are plain characters in an argument. On Windows, `.cmd` shims written by npm are resolved to the Node script they wrap and run with `node`; any other batch file goes through `cmd.exe` only if no argument contains a character cmd.exe interprets (`& | < > ^ % ! " ( )`), otherwise it is refused.
- Arguments that are absolute paths, start with `~`, contain `..` or point outside the project root are refused; NUL and line breaks are refused; `cwd` must be inside the root.
- The environment is reduced to a fixed list of harmless variables (PATH, HOME, TEMP, locale, toolchain homes) plus names you add in `run.env`. Tokens, keys and cloud credentials in your shell are not passed on. `CI=1`, `NO_COLOR=1`, `GIT_PAGER=cat` and similar are set.
- A timeout (default 5 minutes) and an output cap (default 16 MB) kill the process tree.
- Full output is kept in memory only (last 30 runs, 128 MB), never written to disk.
What this does **not** protect against, honestly:
- An allowed command runs code from the repository. `npm test`, `pytest` or `cargo test` execute whatever the project's tests and scripts do; `npm run build*` runs any script whose name starts with `build`. Allowing them means trusting the repository as much as you would when running them yourself.
- The configuration is read once at start. By default it is `<root>/lean-context.config.json`, which an agent that can write files could edit for the *next* start. If that matters, keep the configuration outside the project and pass `--config`.
- Tools like `tsc` or `npm run build` write build output; the allowlist limits what runs, not what an allowed program writes inside the project.
- Argument checks are pattern-based per program; they cover the known dangerous git flags but cannot know every flag of every tool. Keep the allowlist short.
`ctx_read`, `ctx_outline` and `ctx_symbol` refuse paths outside the root lexically (`..`, absolute paths, other drives) and after resolving symlinks and junctions; the indexer does not follow symlinked directories and indexes symlinked files only when they stay inside.
## Security model of the HTTP endpoint
Over HTTP the server can read the project and run the commands you allowed, for whoever can reach the port. So:
- It binds to `127.0.0.1` by default and validates the `Host` and `Origin` headers (DNS-rebinding protection). Name extra hosts in `LEAN_CONTEXT_ALLOWED_HOSTS` (comma separated) when a reverse proxy fronts it.
- It **refuses to start on any other address without `LEAN_CONTEXT_TOKEN`**. With a token, every MCP request must carry `Authorization: Bearer <token>`, compared in constant time. The token comes from the environment, not a flag, so it stays out of process listings.
- Without a token on loopback it starts, and warns on stderr: any process on this machine that can reach the port can read the project and run allowed commands. On a shared machine, set a token. Requests without an `Origin` header (anything that is not a browser) are accepted, so the token is what stops them.
- There is no TLS. For access beyond the machine, put a TLS-terminating reverse proxy in front, keep lean-context on loopback and name the proxy's host in `LEAN_CONTEXT_ALLOWED_HOSTS`.
- Bounds: at most 50 clients with their own state per protocol era (the least recently used goes first), idle clients are dropped after 30 minutes, a request body over 1 MiB is refused, and each client's stored command output is capped at 32 MB instead of the stdio default of 128 MB.
- Everything in the `ctx_run` model above applies unchanged: the allowlist, no shell, the reduced environment, the path checks.
## Enforcement hook (optional)
Instructions only work when the model follows them. `examples/claude-code/read-guard.mjs` is a `PreToolUse` hook for Claude Code that denies the built-in `Read` tool on a file estimated above 6,000 tokens (`LEAN_CONTEXT_READ_MAX_TOKENS`) when no `offset`/`limit` is given, and tells the model to use `ctx_outline`, `ctx_symbol`, `ctx_read`, or `Read` with offset and limit. Images, PDFs and notebooks pass. `LEAN_CONTEXT_READ_GUARD=off` disables it.
The contract used: the hook gets JSON on stdin with `tool_name`, `tool_input` (`file_path`, `offset`, `limit`) and `cwd`; to deny, it prints `{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"…"}}` and exits 0; to allow, it prints nothing. The script and this contract are tested here by feeding it JSON (`tests/hook.test.ts`). **Not verified in a live Claude Code session**: that the reason text reaches the model exactly as written, how `$CLAUDE_PROJECT_DIR` expands in the hook command on Windows, and that a ranged `Read` satisfies Claude Code's "read before edit" check (it is expected to). Nothing was installed into any real Claude Code settings.
## Configuration
`--config FILE`, `LEAN_CONTEXT_CONFIG`, or `<root>/lean-context.config.json` if present. Unknown keys are rejected with the path of the offending key.
| Key | Default | Meaning |
|---|---|---|
| `index.maxFileBytes` | 1,000,000 | larger files are not indexed |
| `index.ignore` | `[]` | extra gitignore-style patterns (`!pattern` re-includes) |
| `index.watch` | `true` | recursive file watcher |
| `run.allow` | `[]` | the allowlist, see above |
| `run.timeoutMs`, `run.maxOutputBytes`, `run.env` | 300,000, 16 MB, `[]` | limits and extra environment names |
| `store.maxEntries`, `store.maxBytes` | 30, 128 MB | stored command outputs |
| `dedupeReads` | `true` | short note for identical repeat reads |
## Development
```bash
npm install
npm test # builds, then 88 tests: unit, engine, security, hook, HTTP, and end-to-end tests of the built server over stdio and HTTP
npm run typecheck
npm run build
npm run bench # fixture benchmark; exits non-zero if the acceptance bar is missed
npm run bench -- --repo ../your-project # your code (index in the OS temp dir, nothing written to the project)
npm run perf -- --root ../your-project
```
There is no lint step: mcp-gate, whose conventions this follows, has none either; `tsc` runs in strict mode with `noUncheckedIndexedAccess`.
| Path | Role |
|---|---|
| `src/engine.ts` | the seven tools, their schemas (zod) and the accounting |
| `src/server.ts`, `src/index.ts` | MCP wiring (low-level `Server`), CLI |
| `src/http.ts` | the Streamable HTTP endpoint: both protocol eras, one engine per client, token, Host and Origin checks |
| `src/index-db.ts`, `src/db.ts` | SQLite index, freshness, statistics |
| `src/search.ts`, `src/tokenize.ts`, `src/embed.ts` | ranking, tokenization, optional dense retrieval and fusion |
| `src/symbols.ts`, `src/mask.ts`, `src/chunker.ts`, `src/lang.ts` | declaration detection and chunking |
| `src/distill/` | ANSI cleanup, format summaries, the generic reducer |
| `src/runner.ts`, `src/paths.ts`, `src/walk.ts` | allowlist and process execution, path confinement, file walking |
| `bench/` | benchmark, fixtures, log generator, perf script |
After changing dependencies, run `npm ci`, not another `npm install`: with npm 11.6, a plain `npm install` prunes the optional native binding of vitest's bundler (`rolldown`) and rewrites `package-lock.json` without it, after which `npm test` stops at startup with "Cannot find native binding". The lockfile in this repository is complete (it lists every platform's binding), so `npm ci` restores it.
Dependencies, and why each: `@modelcontextprotocol/server` (the protocol; same SDK and version line as mcp-gate), `@modelcontextprotocol/node` (the Node HTTP adapter and the Host/Origin validators; same as mcp-gate), `zod` (input and config validation; same as mcp-gate), `ignore` (correct `.gitignore` semantics are subtle; small, no dependencies), `picomatch` (the `path_glob` parameter; small, no dependencies). Dev only: `@modelcontextprotocol/client` (end-to-end test), `typescript`, `tsx`, `vitest`, `@types/*`.
## Decisions made while building this
- Node 22.5+ instead of 20+: `node:sqlite` removes any native build, which matters on Windows. Its experimental warning is filtered at load, only that one.
- Deny-by-default `ctx_run` with the allowlist in a config file, and no built-in allowlist: running commands should be an explicit choice.
- The cache directory ignores itself instead of editing the project's `.gitignore`.
- HTTP gives every client its own engine over the shared index, and refuses a non-loopback bind without a token, because a reachable endpoint can read the project and run allowed commands.
- The search baseline counts at most 3 files and never the grep call; `ctx_expand` counts as pure cost. Conservative on purpose.
- Benchmark acceptance is judged against the stated top-3 baseline; the oracle-stopping number is reported next to it and is lower.
- No embedding model: making one work offline needs a model download first, and it could not be verified here. The fusion path exists for when one is added.
- The optional Anthropic `count_tokens` calibration script was not written: it was the lowest priority and no API key was available to run it.
## Roadmap
- A real local embedder (a small MiniLM-class model via `@huggingface/transformers`, loaded on demand, off by default) and measuring whether fusion helps recall on paraphrased queries.
- tree-sitter grammars as an optional, more exact symbol detector.
- Calibrating the token counter against `count_tokens`, then publishing per-language ratios.
- More output formats (pnpm/yarn workspaces, gradle, dotnet test, eslint).
- A separate package: an API-side proxy that applies prompt caching and compaction to the conversation itself.
## License
MIT. See [LICENSE](LICENSE).
TDQS
Scored across 7 tools
Each tool targets a distinct retrieval mode: ranked search (ctx_search), file skeleton (ctx_outline), single symbol body (ctx_symbol), raw line range (ctx_read), command execution (ctx_run), output paging (ctx_expand), and metrics (ctx_stats). The descriptions explicitly cross-reference each other to steer selection (e.g. 'expand a hit with ctx_symbol or ctx_read', 'full output is kept under a handle for ctx_expand'). The nearest pair, ctx_read vs ctx_symbol, is cleanly separated by addressing lines versus addressing a named declaration.
All seven tools use the same ctx_ prefix plus a single short verb/noun (search, outline, symbol, read, run, expand, stats) in snake_case. No style mixing or variant spellings, so the set reads as one coherent family.
Seven tools is a tight, well-scoped surface for a context-budgeting read server, and each tool has a clearly non-redundant role in the read/search/execute/refine loop. Nothing looks like filler or a duplicate path to the same result.
The core lifecycle of cheap context retrieval is fully covered: discover (search), skim (outline), drill in (symbol/read), act (run), and recover large output (expand), plus self-metrics. The main gap is file-level discovery — there is no glob/list-directory tool, so an agent must reach for search to learn what files exist. Read-only scope makes the absence of write/edit tools appropriate rather than a gap.