lean-context
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| LEAN_CONTEXT_HOST | No | HTTP server host. Default is 127.0.0.1. | |
| LEAN_CONTEXT_PORT | No | HTTP server port. Default is 3838. Use 0 to pick a free port. | |
| LEAN_CONTEXT_TOKEN | No | Bearer token for HTTP authentication. Required when binding to a non-loopback address; recommended for any HTTP use. | |
| LEAN_CONTEXT_CONFIG | No | Path to the configuration file. Default is <root>/lean-context.config.json if present. | |
| LEAN_CONTEXT_ALLOWED_HOSTS | No | Comma-separated list of extra allowed Host headers for HTTP (DNS-rebinding protection). |
Instructions
Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.
lean-context returns just enough code and command output, and keeps the rest one call away. Prefer it to whole-file reads, grep chains and raw shell output:
Finding code: ctx_search (ranked snippets with path:lines and the enclosing symbol) instead of grep followed by reading files.
Understanding a file: ctx_outline first; ctx_symbol for one function, class or method; ctx_read with start/end for exact lines. Read a whole file only when you are about to edit most of it.
Tests, builds, type checks, git: ctx_run returns the failures, errors and a summary; the full output stays under a handle that ctx_expand can grep or slice. Do not re-run a command just to see more of its output.
Do not re-read what was already returned in this conversation; an identical repeat read answers with a short note. Token figures are estimates (ctx_stats).
Capabilities
Features and capabilities supported by this server
Protocol revision2025-11-25
| Capability | Details |
|---|---|
| tools | {} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| ctx_searchA | Ranked code search over the project (BM25 on identifier-split tokens; symbol names weigh most). Returns path:start-end, the enclosing symbol and a trimmed snippet for each hit, merged and de-duplicated, within budget_tokens. Use instead of grep + reading files. Expand a hit with ctx_symbol or ctx_read. |
| ctx_outlineA | Skeleton of one file: declarations and signatures with line ranges, first line of doc comments, imports collapsed to a count. Usually a small fraction of the file. Use before reading a file. |
| ctx_symbolA | The full body of one function, class, method, type or constant, with line numbers. Accepts "name", "Type.method" or "Type::method"; give path to disambiguate. Lists candidates when the name is ambiguous. |
| ctx_readA | Read lines of a file with line numbers: give start/end. Asking for a whole file that exceeds budget_tokens returns its outline instead. Paths are relative to the project root; nothing outside it is readable. |
| ctx_runA | Run an allowlisted command (tests, builds, type checks, read-only git) without a shell and return distilled output: errors and failures with their context, a summary for known formats, repeated lines folded, head and tail. The full output is kept under a handle for ctx_expand. Commands not on the allowlist are refused. |
| ctx_expandA | Fetch part of a stored ctx_run output by handle: lines matching a regex (grep, optional context), a line range (start/end), or the tail. |
| ctx_statsA | Estimated tokens returned versus a naive baseline (whole files, raw output), per tool, for this session and all sessions of this project. |
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
No prompts | |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
No resources | |
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.