codebase-snapshot 0.20.13 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/CHANGELOG.md +33 -6
  2. package/README.md +41 -19
  3. package/SECURITY.md +2 -2
  4. package/dist/bin.js +12482 -10348
  5. package/dist/{chunk-GNVRD7XS.js → chunk-TDPYLX7X.js} +6062 -4438
  6. package/dist/cli.cjs +11759 -9645
  7. package/dist/cli.d.cts +76 -2
  8. package/dist/cli.d.ts +76 -2
  9. package/dist/cli.js +549 -14
  10. package/dist/{generate-worker-DMzNbsAW.d.cts → generate-worker-D56JeXwx.d.cts} +2 -2
  11. package/dist/{generate-worker-CRMESc0b.d.ts → generate-worker-DakxZs-l.d.ts} +2 -2
  12. package/dist/index.cjs +6037 -4435
  13. package/dist/index.d.cts +281 -63
  14. package/dist/index.d.ts +281 -63
  15. package/dist/index.js +1 -1
  16. package/dist/mcp.cjs +10231 -4354
  17. package/dist/mcp.d.cts +13 -7
  18. package/dist/mcp.d.ts +13 -7
  19. package/dist/mcp.js +1 -1
  20. package/dist/{types-C5ytHMYz.d.ts → types-D5XYzksd.d.cts} +50 -2
  21. package/dist/{types-C5ytHMYz.d.cts → types-D5XYzksd.d.ts} +50 -2
  22. package/docs/about.md +86 -0
  23. package/docs/agent.md +28 -6
  24. package/docs/answer.md +99 -48
  25. package/docs/benchmarks.md +34 -34
  26. package/docs/brief.md +80 -81
  27. package/docs/cli.md +100 -25
  28. package/docs/codebase-token-budget.md +14 -13
  29. package/docs/contents.md +66 -0
  30. package/docs/deploy.md +2 -2
  31. package/docs/faq.md +112 -0
  32. package/docs/glossary.md +152 -0
  33. package/docs/health.md +1 -1
  34. package/docs/how-to-feed-a-repo-to-claude.md +6 -0
  35. package/docs/impact.md +102 -0
  36. package/docs/install.md +4 -3
  37. package/docs/llm-codebase-context.md +166 -0
  38. package/docs/mcp-server-for-codebase.md +155 -0
  39. package/docs/mcp.md +43 -66
  40. package/docs/migration.md +83 -90
  41. package/docs/output.md +1 -3
  42. package/docs/security-review.md +8 -8
  43. package/docs/slice.md +1 -1
  44. package/docs/tools.md +159 -185
  45. package/docs/troubleshooting.md +11 -11
  46. package/docs/vs-code2prompt.md +7 -0
  47. package/docs/vs-gitingest.md +7 -0
  48. package/docs/vs-repomix.md +10 -1
  49. package/docs/workspace.md +1 -1
  50. package/package.json +8 -2
@@ -0,0 +1,166 @@
1
+ # LLM codebase context, explained
2
+
3
+ **LLM codebase context is the part of a repository a model is allowed to see when it answers a
4
+ question about that repository.** It has to be selected, bounded, readable and current. Copying
5
+ every file into a prompt is the simplest version, and usually the worst one: it spends the context
6
+ window on files the question never needed and gives the model no way to tell whether the copy is
7
+ stale.
8
+
9
+ This guide covers what "codebase context" means, why raw dumps fail, the four practical approaches,
10
+ and a repeatable way to build context with codebase-snapshot.
11
+
12
+ ## What is LLM codebase context?
13
+
14
+ A model has no ambient access to your repository. Everything it knows about the code arrives in the
15
+ request: the system prompt, the conversation, and whatever files or retrieval results the client
16
+ attaches. That attached material is the codebase context.
17
+
18
+ Good codebase context has four properties:
19
+
20
+ - **Relevant.** It contains the files and symbols that can answer the question.
21
+ - **Bounded.** It fits the window with room for instructions and a reply.
22
+ - **Attributable.** The model can name the file and line a claim came from.
23
+ - **Current.** It is possible to tell whether the context still matches the working tree.
24
+
25
+ A codebase snapshot is one way to produce all four at once. It is not the only way, and it is not
26
+ always the right way. A small bug in one file is better handled by opening the file than by packing
27
+ the repository.
28
+
29
+ ## Why a raw codebase dump fails
30
+
31
+ The arithmetic is unforgiving. A token is roughly 3.5 bytes of source code, so a 1 MB repository is
32
+ about 285,000 tokens before any instructions. A 128k window cannot hold it; a 200k window can hold
33
+ the code but not much of a conversation. Real applications are five to twenty times larger than a
34
+ small library.
35
+
36
+ The failure is not only size. A dump is usually:
37
+
38
+ 1. **Unfiltered.** Vendored dependencies, generated files, lockfiles and test fixtures ride along
39
+ because the packer copies what it finds.
40
+ 2. **Undifferentiated.** The model sees every file with the same weight. The one module the
41
+ question depends on is buried among hundreds that are irrelevant.
42
+ 3. **Unaccounted.** A packer that silently skips or truncates a file leaves the model unaware that
43
+ its picture has a hole. The answer sounds complete and is not.
44
+ 4. **Undated.** The model cannot know whether the snapshot was generated five minutes or five
45
+ months ago. A stale snapshot is worse than no snapshot because it reads as current.
46
+
47
+ The tooling answer is not "write a better prompt". It is to produce a smaller, indexed artefact and
48
+ to make freshness checkable.
49
+
50
+ ## Four ways to give a model codebase context
51
+
52
+ | Approach | What it is good at | Where it breaks |
53
+ | :-- | :-- | :-- |
54
+ | Paste files by hand | One file or one symbol; complete control | Does not scale past a handful of files; easy to miss a caller |
55
+ | Pack the repository | A stable artefact attached to one conversation; offline and inspectable | Size; stale copies; no principled choice of what matters |
56
+ | Bounded retrieval over a local index (MCP) | A question answered from the few files that matter; live edits | Needs a client that speaks MCP; the index has to be built |
57
+ | Code graph or embedding index | Cross-repo and semantic questions at scale | Infrastructure, embeddings and a server; overkill for one repository |
58
+
59
+ Most teams end up combining the second and third: a packed snapshot for a first, broad review, and
60
+ a live MCP server for follow-up questions. The rest of this page shows the packed route, because it
61
+ is the one that works in a fresh clone and in any chat client that accepts attachments.
62
+
63
+ ## Build codebase context with codebase-snapshot
64
+
65
+ ### 1. Generate the snapshot
66
+
67
+ npx codebase-snapshot generate
68
+
69
+ The default writes ./snapshot with Markdown parts, a manifest, a prompt and reports. The run is
70
+ deterministic: unchanged input produces byte-identical parts and the same fingerprint. The parts
71
+ never exceed the configured byte budget.
72
+
73
+ ### 2. Read the prompt before the parts
74
+
75
+ PROMPT.md states the fingerprint, the commit, the parts, what was left out and how to attach the
76
+ files. Paste it as the first message. It is the instruction sheet that turns a pile of Markdown into
77
+ context the model can use.
78
+
79
+ ### 3. Attach only what fits
80
+
81
+ A hosted chat often accepts ten files. A 12-part snapshot cannot be delivered whole. Either raise
82
+ --max-part-bytes so the same content becomes fewer parts, or scope the run with include/exclude
83
+ patterns to the directories the question is about. The prompt's delivery section does the
84
+ arithmetic for the current run.
85
+
86
+ ### 4. Ask a bounded question
87
+
88
+ "Using the attached snapshot, trace how authentication reaches the database. Cite the file and line
89
+ for each hop; if the answer is not in the attached files, say what is missing." The second clause is
90
+ what stops a model from filling a gap with a plausible invention.
91
+
92
+ ### 5. Validate before reusing the context
93
+
94
+ npx codebase-snapshot validate
95
+
96
+ validate re-hashes the tree and exits non-zero on drift. Put it in CI or a pre-commit hook. When it
97
+ fails, regenerate; do not keep asking questions against a snapshot that no longer describes the
98
+ code.
99
+
100
+ For a live alternative, run the MCP server and let the client call the tools:
101
+
102
+ npx codebase-snapshot mcp
103
+
104
+ The read tools use the working tree by default, so an uncommitted edit is visible without a
105
+ regeneration. See [MCP server for a codebase](mcp-server-for-codebase.md).
106
+
107
+ ## How much codebase context fits?
108
+
109
+ Use the destination, not the tool's default. The snapshot budget should leave room for the system
110
+ prompt, the question and the reply.
111
+
112
+ | Window | Practical context ceiling | What that means |
113
+ | :-- | --: | :-- |
114
+ | 32k | ~20k tokens | One small module or a slice, not a repository |
115
+ | 128k | ~80k tokens | One 300 KB part, or a scoped folder |
116
+ | 200k | ~130k tokens | Two or three parts, or a larger slice |
117
+ | 1M | ~700k tokens | A medium repository whole, with room for analysis |
118
+
119
+ The estimates are conservative on purpose. A 128k window filled to 120k leaves no space for a
120
+ useful answer, and models often perform worse when the relevant material is diluted.
121
+
122
+ ## Keep context current
123
+
124
+ A snapshot is a moment, not a subscription. The repository moves; the file on disk does not. The
125
+ controls that make freshness visible are:
126
+
127
+ - **Fingerprint.** The manifest records a content fingerprint; two runs over the same input agree.
128
+ - **Validate.** The command compares the snapshot with the tree and exits non-zero on drift.
129
+ - **Git state.** The manifest records the branch, commit and dirty state at generation time.
130
+ - **Live index.** The MCP read tools overlay uncommitted edits and new files, and say so in a trust
131
+ envelope.
132
+
133
+ Read [Stale context is your bug](stale-context-is-your-bug.md) for the CI pattern.
134
+
135
+ ## What leaves the repository?
136
+
137
+ The CLI and the MCP server run locally. There is no account, upload or telemetry. Generated
138
+ artifacts contain redacted source, not your credentials: sensitive paths are excluded by default,
139
+ and secret-shaped values in ordinary files are replaced with a marker. The audit report names the
140
+ file and line but not the value.
141
+
142
+ Redaction is not a guarantee. If you need a formal data-handling statement, read the
143
+ [security review](security-review.md), which lists the residual risks instead of hiding them.
144
+
145
+ ## How to choose a codebase context tool
146
+
147
+ Ask five questions:
148
+
149
+ 1. **Does it fit the destination?** A tool that produces one 40 MB file has not solved the
150
+ attachment problem.
151
+ 2. **Does it account for omissions?** Every skipped or shortened file should have a reason.
152
+ 3. **Can it prove freshness?** A hash or a validate command, not a promise.
153
+ 4. **Does it handle secrets?** Default exclusions, span redaction and an audit.
154
+ 5. **Can an agent use it without a human?** A machine-readable contract and bounded tools, or at
155
+ least static pages it can fetch.
156
+
157
+ Those five questions are also the design brief for codebase-snapshot. The comparisons with
158
+ [repomix](vs-repomix.md), [gitingest](vs-gitingest.md) and [code2prompt](vs-code2prompt.md) apply the
159
+ same questions honestly.
160
+
161
+ ## Related
162
+
163
+ - [How to feed a repository to Claude or ChatGPT](how-to-feed-a-repo-to-claude.md)
164
+ - [How many tokens is a codebase?](codebase-token-budget.md)
165
+ - [Budgeting LLM context](how-to-context-budget.md)
166
+ - [All documentation](contents.md)
@@ -0,0 +1,155 @@
1
+ # MCP server for a codebase
2
+
3
+ **An MCP server for a codebase lets an AI client ask a local process for the few files, symbols or
4
+ impact facts a question needs, instead of attaching the whole repository.** codebase-snapshot ships
5
+ one: seven tools (six read-only) over stdio or Streamable HTTP, a live index that sees uncommitted
6
+ edits, and a persistent snapshot when you need a shared artefact.
7
+
8
+ This guide covers what the server exposes, how to wire it into Claude, Cursor, Claude Code or any
9
+ generic MCP client, what it can read, and where its limits are.
10
+
11
+ ## Why a local MCP server instead of a packed file
12
+
13
+ A packed file is a good first move: it is inspectable, portable and works in a chat that only
14
+ accepts attachments. It has two costs. Every follow-up question either re-attaches the same file or
15
+ starts a new conversation, and the copy is frozen at the moment it was written.
16
+
17
+ A local MCP server changes the interaction:
18
+
19
+ - The client asks for **one** file, symbol or impact report instead of receiving all of them.
20
+ - The index is **live by default**: changed files are overlaid in memory, new files are indexed, and
21
+ a repository with no snapshot is scanned without writing one.
22
+ - Responses are **bounded**: a read is capped at 64 KiB, a resource at 512 KiB, a tool result at 64
23
+ KiB, and a text search at 4 MiB.
24
+ - Every structured response carries a **trust envelope** naming the source, freshness, coverage,
25
+ redaction count and any reason the answer is partial.
26
+
27
+ The trade-off is that the client must speak MCP. If it cannot, generate a snapshot and attach it.
28
+
29
+ ## Start the server
30
+
31
+ npx codebase-snapshot mcp
32
+
33
+ The server serves the directory it was started in. --cwd points it elsewhere; that directory is the
34
+ only one it reads. Add --http to listen on loopback instead of stdio.
35
+
36
+ A generic client needs a command and arguments. The surrounding shape belongs to the client; this
37
+ is the mcpServers form used by Claude Desktop and Cursor:
38
+
39
+ {
40
+ "mcpServers": {
41
+ "codebase-snapshot": {
42
+ "command": "npx",
43
+ "args": ["-y", "codebase-snapshot", "mcp", "--cwd", "/absolute/path/to/repo"]
44
+ }
45
+ }
46
+ }
47
+
48
+ Claude Code registers the same server from a shell:
49
+
50
+ claude mcp add codebase-snapshot -- npx -y codebase-snapshot mcp --cwd /absolute/path/to/repo
51
+
52
+ On Windows, wrap the command as cmd /c npx with the same arguments. npx is a .cmd shim there, and a
53
+ client that spawns without a shell cannot execute it directly.
54
+
55
+ ## The seven tools
56
+
57
+ | Tool | Cost | Answers |
58
+ | :-- | :-- | :-- |
59
+ | snapshot_impact | medium | What a change reaches: changed files, symbol-pruned importers, routes, candidate tests, cycles |
60
+ | snapshot_context | medium | The minimum redacted, line-numbered context for a question or file list inside a token budget |
61
+ | snapshot_locate | cheap | Paths, symbols, routes, entrypoints or bounded redacted text in one call |
62
+ | snapshot_read | medium | A line window of one redacted file, never a sensitive path |
63
+ | snapshot_validate | cheap | Status, drift, or an integrity and secret audit of the persisted snapshot |
64
+ | snapshot_explain | expensive | Why a path is included, excluded, sensitive, ignored, binary or truncated |
65
+ | snapshot_generate | expensive | Write a snapshot, or preview one with dryRun: true. The only writable tool |
66
+
67
+ Six tools are declared readOnlyHint, which most clients use to run them without asking. The full
68
+ schemas, cost classes and example calls are in the [MCP tool reference](tools.md).
69
+
70
+ ## What a call looks like
71
+
72
+ A question about a change, with candidate tests:
73
+
74
+ {
75
+ "name": "snapshot_impact",
76
+ "arguments": {
77
+ "paths": ["src/impact.ts"],
78
+ "includeCycles": true,
79
+ "includeSnippets": true
80
+ }
81
+ }
82
+
83
+ A bounded reading list before a task:
84
+
85
+ {
86
+ "name": "snapshot_context",
87
+ "arguments": {
88
+ "question": "how does impact pruning work",
89
+ "maxTokens": 12000,
90
+ "linesPerFile": 100
91
+ }
92
+ }
93
+
94
+ A read of one file:
95
+
96
+ {
97
+ "name": "snapshot_read",
98
+ "arguments": { "path": "src/impact.ts", "fromLine": 1, "lines": 120 }
99
+ }
100
+
101
+ ## Live index versus persisted snapshot
102
+
103
+ Read-only tools are live by default. They reuse a current manifest.json, overlay changed and new
104
+ files in memory when the tree has moved, or scan the confined working tree when no snapshot exists.
105
+ They never write into the repository. Pass "live": false to require the persisted snapshot; the
106
+ trust envelope then says freshness is unknown rather than claiming the file is current.
107
+
108
+ This distinction matters for agents. A stale persisted snapshot is still useful if the client knows
109
+ it is stale; it is dangerous if the envelope says current. The server only claims current when it
110
+ has compared the tree, which is what snapshot_validate drift mode is for.
111
+
112
+ ## Large repositories and monorepos
113
+
114
+ The server bounds its own work. A text search stops at 4 MiB; a TypeScript compiler pass stops at
115
+ 2,500 files and four seconds; a resource above 512 KiB is refused rather than truncated. When a cap
116
+ is hit, the response says so in trust.reasons or in the precise coverage field.
117
+
118
+ For a monorepo, point --cwd at the member that contains the code you are asking about, or generate a
119
+ workspace snapshot and pass its outDir. A workspace run writes one snapshot per member plus a
120
+ WORKSPACE.json index. The MCP server does not silently merge members: a tool call names the
121
+ repository it serves.
122
+
123
+ ## Security boundary
124
+
125
+ - The server reads only the served root. --root can add directories explicitly; a path outside them
126
+ is refused.
127
+ - Sensitive paths are never readable through snapshot_read, even when they exist on disk.
128
+ - A snapshot generated with --include-sensitive-files is refused by the MCP transport and by serve.
129
+ - HTTP binds loopback by default, requires a bearer token for /api and generates one on first run.
130
+ A non-loopback bind without a token is refused.
131
+ - Remote ingestion is HTTPS-only, refuses private addresses and does not follow redirects.
132
+ - Secrets are redacted in emitted parts and checked again by the audit.
133
+
134
+ The full threat model, including the residual risks (executable configs, DNS rebinding, prompt
135
+ injection inside repository content), is in the [security review](security-review.md).
136
+
137
+ ## Limits and when not to use it
138
+
139
+ - **The client must speak MCP.** A chat that only accepts attachments cannot use the server.
140
+ - **Heuristic languages.** TypeScript and JavaScript get the deepest symbol support; the other
141
+ language profiles classify and index but do not promise compiler-grade references.
142
+ - **No write tools beyond generate.** The server cannot edit, refactor or run tests; it is a
143
+ read-and-generate surface.
144
+ - **Not a code graph.** It follows imports and declaration spans, not a semantic graph of every
145
+ relationship. The impact report says where it is conservative.
146
+
147
+ If you need a single portable artefact, use generate. If you need a live question-answer loop and
148
+ your client supports MCP, use the server. Most teams use both.
149
+
150
+ ## Related
151
+
152
+ - [MCP tools reference](tools.md) — every schema and example call
153
+ - [MCP protocol details](mcp.md) — transports, sessions, headers and limits
154
+ - [LLM codebase context](llm-codebase-context.md) — the broader guide
155
+ - [All documentation](contents.md)
package/docs/mcp.md CHANGED
@@ -10,7 +10,7 @@ walk — that the client sees.
10
10
  ## Start it
11
11
 
12
12
  ```bash
13
- npx -y codebase-snapshot@0.20.12 mcp
13
+ npx -y codebase-snapshot@0.21.0 mcp
14
14
  ```
15
15
 
16
16
  The server serves the directory it was started in. `--cwd <path>` points it elsewhere, and that
@@ -25,7 +25,7 @@ Claude Desktop and Cursor:
25
25
  "mcpServers": {
26
26
  "codebase-snapshot": {
27
27
  "command": "npx",
28
- "args": ["-y", "codebase-snapshot@0.20.12", "mcp", "--cwd", "/absolute/path/to/repo"]
28
+ "args": ["-y", "codebase-snapshot@0.21.0", "mcp", "--cwd", "/absolute/path/to/repo"]
29
29
  }
30
30
  }
31
31
  }
@@ -34,7 +34,7 @@ Claude Desktop and Cursor:
34
34
  Claude Code registers the same thing from a shell:
35
35
 
36
36
  ```bash
37
- claude mcp add codebase-snapshot -- npx -y codebase-snapshot@0.20.12 mcp --cwd /absolute/path/to/repo
37
+ claude mcp add codebase-snapshot -- npx -y codebase-snapshot@0.21.0 mcp --cwd /absolute/path/to/repo
38
38
  ```
39
39
 
40
40
  On Windows, wrap the command as `cmd /c npx` with the same arguments — `npx` is a `.cmd` shim
@@ -43,7 +43,7 @@ there, and clients that spawn without a shell cannot execute it directly.
43
43
  ## Over HTTP, for clients that cannot spawn a process
44
44
 
45
45
  ```bash
46
- npx -y codebase-snapshot@0.20.12 mcp --http --port 4789
46
+ npx -y codebase-snapshot@0.21.0 mcp --http --port 4789
47
47
  ```
48
48
 
49
49
  This is the Streamable HTTP shape: POST one JSON-RPC message to `/mcp` and read the JSON-RPC
@@ -110,57 +110,34 @@ into logs and is documented as such. A heartbeat every 15 s keeps the connection
110
110
  shutdown ends the streams rather than waiting on them. Request bodies are capped at 2 MB, the rate is
111
111
  capped at 60 requests per 10 seconds per address, and every response is one bounded JSON document.
112
112
 
113
- ## The 26 tools
113
+ ## The 7 tools
114
114
 
115
115
  Each tool has an entry with a ready-to-send call in the [tool reference](tools.md).
116
116
 
117
-
118
117
  Every tool states its cost class in `tools/list` as `_meta["codebase-snapshot/cost"]`: `cheap`
119
- reads the manifest, `medium` reads one or a few parts, `expensive` reads the repository or writes.
120
- Two tools that answer the same question can differ by an order of magnitude, and a client choosing
121
- between them should not have to guess.
122
-
123
- Modern cacheable results — `server/discover`, `tools/list`, `prompts/list`, `resources/list`,
124
- `resources/read` and `resources/templates/list` — carry `ttlMs: 0` and
125
- `cacheScope: "private"`. The snapshot is private to the caller and a regeneration can replace any
126
- part of it between two reads, so a positive TTL would invite a client to serve stale bytes.
118
+ reads the index, `medium` reads a few bounded bodies, `expensive` runs a compiler or writes.
127
119
 
128
120
  | Tool | Answers | Writes |
129
121
  | :-- | :-- | :-- |
130
- | `snapshot_status` | Is there a snapshot, when was it built, what does it cover? | no |
131
- | `snapshot_health` | Does the written snapshot match its manifest, carry any secret or host path, and cost what it claims? `maxScanBytes` bounds the text scan; `deep: true` replays every full body from the source. | no |
132
- | `snapshot_query` | Filter the index by layer, kind, path pattern or symbol | no |
133
- | `snapshot_answer` | Question to cited, line-numbered windows within a budget | no |
134
- | `snapshot_budget` | Planner output at several budgets: what raising the budget would add | no |
135
- | `snapshot_history` | The commits the snapshot was built from (reads `reports/log.md`) | no |
136
- | `snapshot_tests` | The tests that import a file (or every test and what it covers) | no |
137
- | `snapshot_workspace` | The members of a multi-repository workspace and the imports that cross between them | no |
138
- | `snapshot_entrypoints` | The files a reader should start from, manifests first | no |
139
- | `snapshot_neighbors` | Both import directions for one path | no |
140
- | `snapshot_routes` | Route handlers recorded by the summaries, with their files | no |
141
- | `snapshot_cycles` | Strongly connected components in the import graph | no |
142
- | `snapshot_stats` | Files by layer and kind, part sizes, token estimate, heaviest files | no |
143
- | `snapshot_search` | Case-insensitive text search across the emitted parts, bounded and redaction-safe | no |
144
- | `snapshot_review` | Currency, health and bounded bodies in one call, so a review can start | no |
145
- | `snapshot_symbol` | Where a function, class or constant is defined, with a window and a line number | no |
146
- | `snapshot_diff_context` | Bodies of the changed files plus the files that import them | no |
147
- | `snapshot_context` | One bounded context block from named files or symbols, read from the snapshot | no |
148
- | `snapshot_plan_for` | Given a question and a token budget, the smallest set of files that answer it, in reading order | no |
149
- | `snapshot_plan` | What would a generate at this budget include, and what would it leave out? | no |
150
- | `snapshot_generate` | Build it. Accepts `includeDiffs`, `includeLogs`, `tokenTree` and `stripComments`, so a client can ask for the opt-in reports the CLI has. | yes |
151
- | `snapshot_validate` | Is the context the agent was given still current? | no |
152
- | `snapshot_locate` | Which part holds this symbol, route or file? | no |
153
- | `snapshot_dependents` | What does this file import, and what imports it? | no |
154
- | `snapshot_read` | A window of one file, as the snapshot contains it. | no |
155
- | `snapshot_explain` | Why is this path not in the snapshot? | no |
156
-
157
- Twenty-five are declared `readOnlyHint`, which most clients use to run them without asking. Only
122
+ | `snapshot_impact` | What does this change reach? Symbol-pruned callers, routes, import cycles, candidate tests and optional snippets. Omitting `paths` and `base` compares the working tree with `HEAD`. | no |
123
+ | `snapshot_context` | The minimum redacted, line-numbered context for a question, files or symbols inside a hard token budget. `planOnly` returns the reading plan. | no |
124
+ | `snapshot_locate` | Paths, symbols, routes, entrypoints or bounded redacted text. Symbol mode can add compiler-resolved references. | no |
125
+ | `snapshot_read` | A bounded, redacted line window of one file. Sensitive paths are never readable. | no |
126
+ | `snapshot_validate` | `status` (presence, counts, fingerprint), `drift` (freshness), or `audit` (secret and integrity checks). Only drift claims `current`. | no |
127
+ | `snapshot_explain` | Why is this path included, excluded, sensitive, ignored, binary or truncated? | no |
128
+ | `snapshot_generate` | Write the snapshot, or preview it with `dryRun: true`. | yes |
129
+
130
+ Six tools are declared `readOnlyHint`, which most clients use to run them without asking. Only
158
131
  `snapshot_generate` writes.
159
132
 
160
- All 26 take `outDir`, so a snapshot generated into a directory other than the configured one is
161
- still reachable: pass the same value to the read side that you passed to `snapshot_generate`. Before
162
- that, only `snapshot_generate` honoured it and every other tool looked in the configured directory
163
- and reported "there is no snapshot manifest here".
133
+ **Live by default.** Read-only tools reuse a current `manifest.json`, overlay changed and new files
134
+ in memory when the tree has moved, or scan the confined working tree when no snapshot exists. They
135
+ never write into the repository. Pass `"live": false` to require the persisted snapshot. Every
136
+ structured response carries a `trust` envelope naming the index source, freshness, coverage,
137
+ redaction count and any reason coverage is partial.
138
+
139
+ All 7 take `outDir`, so a snapshot generated into a directory other than the configured one is
140
+ still reachable: pass the same value to the read side that you passed to `snapshot_generate`.
164
141
 
165
142
  An `outDir` **tool argument** must resolve inside the repository the server serves: a prompt cannot
166
143
  drop a snapshot tree anywhere the process is able to write. The project's *configured* `outDir`
@@ -168,32 +145,25 @@ and `tmpDir` are confined the same way. If either escapes, the tool refuses and
168
145
  to move the directory inside the served root, or start the server with `--cwd` at the parent
169
146
  repository.
170
147
 
171
- `snapshot_plan`, `snapshot_generate`, `snapshot_validate` and `snapshot_explain` also take the
172
- **scope and compression** switches `generate` accepts: `maxPartTokens`, `skeleton`, `sarif`,
173
- `changedSince`, `staged` and `withDependents`. They have to: `manifest.config.digest` covers those
174
- settings, so a snapshot generated with `--skeleton` was not merely un-inspectable over MCP, it was
175
- reported as configuration drift on every `snapshot_validate`. Pass the same switches you generated
176
- with, exactly as you would on the command line. The other tools do not take them, because
177
- none of them re-derives the configuration and a flag that changes nothing is the command-line form
178
- of a silent fallback.
148
+ `snapshot_generate`, `snapshot_validate` and `snapshot_explain` also take the **scope and
149
+ compression** switches `generate` accepts: `maxPartTokens`, `skeleton`, `sarif`, `changedSince`,
150
+ `staged` and `withDependents`. `manifest.config.digest` covers those settings, so a snapshot
151
+ generated with `--skeleton` must be validated with the same switch rather than reported as drift.
179
152
 
180
153
  `includeSensitiveFiles` is deliberately absent from every one of them. A prompt can ask for
181
154
  anything, and a tool that emits `.env` on request is a secret-exfiltration primitive with a
182
155
  friendly name.
183
156
 
184
157
  `snapshot_locate` is the one that makes the others usable: a twelve-part snapshot is hundreds of
185
- kilobytes, and asking "which part holds authentication?" is cheaper than reading all twelve. It
186
- searches the manifest's index — file paths, exported symbols, component names, routes, layers and
187
- kinds — and returns the part each match lives in.
158
+ kilobytes, and asking "where is authentication?" is cheaper than reading all twelve. It searches
159
+ the manifest's index and, for text mode, a bounded redacted body scan.
188
160
 
189
- `snapshot_read` is windowed on purpose. It defaults to 200 lines and reports `nextFromLine` when
190
- more remains, so an agent continues deliberately instead of pulling a whole part into a context
191
- window it has not budgeted. A single line longer than one result can carry is the exception: the
192
- page ends mid-line, `pageable` is `false` and `reason` says so, because advancing `fromLine` would
193
- silently skip the rest of that line.
161
+ `snapshot_read` is windowed on purpose. It defaults to 200 lines and reports where more remains,
162
+ so an agent continues deliberately instead of pulling a whole part into a context window it has
163
+ not budgeted. A response never exceeds 64 KiB.
194
164
 
195
165
  At most four requests run at once. A fifth gets a JSON-RPC `overloaded` error (`-32001`) naming
196
- the limit instead of being queued silently or dropped, so a client can retry and `snapshot_status`
166
+ the limit instead of being queued silently or dropped, so a client can retry and `snapshot_validate`
197
167
  stays responsive.
198
168
 
199
169
  ## Resources
@@ -221,7 +191,7 @@ publishes them separately as `reportResources`.
221
191
  A resource read is **all-or-nothing**. Above the 512 kB single-read limit the read fails with
222
192
  JSON-RPC error `-32000` (the implementation-defined server-error range) and
223
193
  `data: { uri, bytes, limit }`; the message says what to use instead — `snapshot_locate`,
224
- `snapshot_read` or `snapshot_status` for a manifest or part, the file on disk for a report, and
194
+ `snapshot_read` or `snapshot_validate` for a manifest or part, the file on disk for a report, and
225
195
  the CLI for the contract or the skill. It never returns a truncated document: half a JSON manifest
226
196
  does not parse, and half a part is a fragment that looks complete. The rule applies to every
227
197
  resource — `snapshot://manifest`, each `snapshot://parts/{index}`, the report resources,
@@ -331,7 +301,7 @@ the same repository. The numbers below are measured, not estimated:
331
301
  | A synthetic tree | 3,000 | 7.5 s |
332
302
 
333
303
  They describe how long the *write* takes, not how long the server is deaf — which is the
334
- distinction a client's request timeout actually cares about. `snapshot_plan` produces the same
304
+ distinction a client's request timeout actually cares about. `snapshot_generate` with `dryRun` produces the same
335
305
  numbers without writing anything.
336
306
 
337
307
  The worker re-reads the configuration and applies the same options this thread used, because a
@@ -349,7 +319,7 @@ to stderr. Check the client's server log — the first line says which directory
349
319
  version in the client arguments.
350
320
 
351
321
  **`Unknown resource` for a part.** Resources are computed from the manifest, so nothing but the
352
- static set exists before the first generate. Call `snapshot_status`, then `snapshot_generate`.
322
+ static set exists before the first generate. Call `snapshot_validate` with `mode: "status"`, then `snapshot_generate`.
353
323
 
354
324
  **A resource read fails with `-32000`.** The resource is larger than the 512 kB single-read limit;
355
325
  it was refused rather than truncated. `data.uri`, `data.bytes` and `data.limit` say which resource
@@ -358,3 +328,10 @@ from the snapshot directory for the manifest or a report.
358
328
 
359
329
  **A file is missing from `snapshot_locate`.** It is excluded, and `snapshot_explain` will name the
360
330
  reason — an ignore rule, the preset, a sensitive-file pattern, or your own config.
331
+
332
+
333
+ ## See also
334
+
335
+ - [MCP server for a codebase](mcp-server-for-codebase.md) — setup for Claude, Cursor and generic clients, the seven tools, security and limits.
336
+ - [MCP tools](tools.md) — every schema and an example call.
337
+ - [LLM codebase context](llm-codebase-context.md) — why a local server beats attaching a file for follow-up questions.