codebase-snapshot 0.20.12 → 0.20.13

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.
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.9 mcp
13
+ npx -y codebase-snapshot@0.20.12 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.9", "mcp", "--cwd", "/absolute/path/to/repo"]
28
+ "args": ["-y", "codebase-snapshot@0.20.12", "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.9 mcp --cwd /absolute/path/to/repo
37
+ claude mcp add codebase-snapshot -- npx -y codebase-snapshot@0.20.12 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,11 +43,15 @@ 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.9 mcp --http --port 4789
46
+ npx -y codebase-snapshot@0.20.12 mcp --http --port 4789
47
47
  ```
48
48
 
49
- This is the Streamable HTTP shape: POST one JSON-RPC message (or an array) to `/mcp` and read
50
- the JSON-RPC answer from the response body. `GET /healthz` answers
49
+ This is the Streamable HTTP shape: POST one JSON-RPC message to `/mcp` and read the JSON-RPC
50
+ answer from the response body. Modern (`2026-07-28`) requests must also carry
51
+ `MCP-Protocol-Version`, `Mcp-Method` and — for `tools/call`, `resources/read` and
52
+ `prompts/get` — `Mcp-Name`. A missing header, or one that disagrees with the body, is refused
53
+ with HTTP `400` and JSON-RPC `-32020` before dispatch; the CORS preflight allows all three
54
+ names. Legacy requests keep the session behaviour below. `GET /healthz` answers
51
55
  `{ ok, name, version, tools, uptimeSeconds }` without a token, and `GET /metrics` answers Prometheus
52
56
  text: `snapshot_requests_total`, `snapshot_requests_by_method_total{method="…"}` (fixed labels,
53
57
  never a path or a credential), `snapshot_requests_refused_total` (every 4xx except 429: an
@@ -78,14 +82,16 @@ reachable from the network must not be readable by any page that guesses the por
78
82
  CORS is granted to loopback origins (`localhost`, `127.0.0.1`, `[::1]`, any port) and to the
79
83
  origins you list. Any other `Origin` gets `403`.
80
84
 
81
- The first `initialize` response carries an `mcp-session-id` header. Send it on every later
82
- request: era and cancellation state belong to that session, so one client's
83
- `server/discover` cannot reject another client's legacy handshake. A client that ignores the
84
- header falls back to a per-address server; two such clients on one host with the same user agent
85
- share state, which is why forwarding the header matters. An unknown `mcp-session-id` is answered
86
- with `404`, never used to mint state; sessions expire after 30 minutes idle, the oldest is evicted
87
- when the table is full, and `DELETE /mcp` closes one explicitly. JSON-RPC batches are capped at
88
- 100 messages, and the body cap applies before parsing.
85
+ Modern requests are stateless: `mcp-session-id` is ignored, never minted and never echoed. The
86
+ legacy era still opens with `initialize`, whose response carries an `mcp-session-id` header;
87
+ send it on every later legacy request. Era and cancellation state belong to that session, so one
88
+ client's `server/discover` cannot reject another client's legacy handshake. A legacy client that
89
+ ignores the header falls back to a per-address server; two such clients on one host with the same
90
+ user agent share state, which is why forwarding the header matters. An unknown `mcp-session-id`
91
+ is answered with `404`, never used to mint state; sessions expire after 30 minutes idle, the
92
+ oldest is evicted when the table is full, and `DELETE /mcp` closes one explicitly. Legacy
93
+ JSON-RPC batches are capped at 100 messages; a modern request is one message, and a modern batch
94
+ is refused. The body cap applies before parsing.
89
95
 
90
96
  ### Legacy SSE, for clients that cannot send a header
91
97
 
@@ -114,6 +120,11 @@ reads the manifest, `medium` reads one or a few parts, `expensive` reads the rep
114
120
  Two tools that answer the same question can differ by an order of magnitude, and a client choosing
115
121
  between them should not have to guess.
116
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.
127
+
117
128
  | Tool | Answers | Writes |
118
129
  | :-- | :-- | :-- |
119
130
  | `snapshot_status` | Is there a snapshot, when was it built, what does it cover? | no |
@@ -217,9 +228,11 @@ resource — `snapshot://manifest`, each `snapshot://parts/{index}`, the report
217
228
  `snapshot://prompt`, `snapshot://contract` and `snapshot://skill`.
218
229
 
219
230
  A URI this build serves but this snapshot does not contain — `snapshot://prompt` when the prompt
220
- artifact was disabled, a report when that artifact was — is answered with `-32002` (resource not
221
- found) and a message naming the artifact and the cause. An unknown URI is still "Unknown resource":
222
- the two are different mistakes and a client should be able to tell them apart.
231
+ artifact was disabled, a report when that artifact was — is answered with `-32602` (Invalid
232
+ Params) under the modern revision, and with the legacy `-32002` for a legacy client. The message
233
+ names the artifact and the cause. Modern clients also accept `-32002` from older servers, but this
234
+ server does not make a modern client guess. An unknown URI is still "Unknown resource": the two
235
+ are different mistakes and a client should be able to tell them apart.
223
236
 
224
237
  Part resources carry their size in the description, so a client choosing between them can see that
225
238
  one is 300 kB before attaching it; a part above the limit says in its description that it will be
@@ -276,25 +289,34 @@ says what happened rather than pretending the call never ran.
276
289
 
277
290
  ## Both protocol eras
278
291
 
279
- Revision `2026-07-28` removed the handshake that every client in use today still performs. The
280
- server speaks both and answers whichever arrives first.
292
+ Revision `2026-07-28` removed the handshake most deployed clients still perform. The server speaks
293
+ both and answers whichever arrives first.
281
294
 
282
295
  | Era | Revisions | Opening move |
283
296
  | :-- | :-- | :-- |
284
297
  | Legacy | `2025-11-25`, `2025-06-18` | `initialize`, then `notifications/initialized` |
285
298
  | Modern | `2026-07-28` | `server/discover`, or `_meta` on every request; a stateless request with valid `_meta` is complete on its own |
286
299
 
287
- The two disagree about an unsupported version, and the difference is observable: a legacy client is
288
- negotiated *down* to a revision the server speaks, while a modern client receives `-32022` with the
289
- list of supported revisions so it can retry.
300
+ A modern request over HTTP is complete only when its mirroring headers agree with its body, and its
301
+ cacheable results carry the fields the revision requires. Those rules are enforced in
302
+ `src/mcp/http-headers.ts` and `src/mcp/server.ts`, not just documented.
303
+
304
+ The two eras disagree about an unsupported version, and the difference is observable: a legacy
305
+ client is negotiated *down* to a revision the server speaks, while a modern client receives
306
+ `-32022` with the list of supported revisions so it can retry.
290
307
 
291
- ## Why there is no SDK
308
+ ## Why there is no runtime SDK
292
309
 
293
310
  `@modelcontextprotocol/sdk` is 4.5 MB unpacked and brings Express, Hono, Ajv, JOSE and Zod with it.
294
311
  The transport here is newline-delimited JSON-RPC, which is roughly 400 lines of readable code, and
295
312
  the package's only runtime dependency remains `typescript`. The parity test — a live `tools/list`
296
- compared against `describe --format json` — is what keeps the protocol implementation honest, not
297
- the presence of a library.
313
+ compared against `describe --format json` — is what keeps the protocol contract honest, not the
314
+ presence of a library.
315
+
316
+ The official v2 client (`@modelcontextprotocol/client`) is a **dev-only** dependency. Two
317
+ interoperability tests drive this server through it over modern stdio and modern HTTP, including
318
+ `server/discover`, `tools/list`, `tools/call`, `resources/read` and the cache fields. It is not
319
+ shipped, and it does not make the runtime depend on the SDK.
298
320
 
299
321
  ## Performance
300
322
 
package/docs/migration.md CHANGED
@@ -1,4 +1,4 @@
1
- # Migrating to 0.20.12
1
+ # Migrating to 0.20.13
2
2
 
3
3
  Nothing was removed. Every command, flag, config key and MCP tool that existed in 0.12.14 still
4
4
  works. This page maps what was added and the behaviour changes that matter when upgrading an old
@@ -54,7 +54,7 @@ stdio is still the default. `--http` adds Streamable HTTP with a bearer token an
54
54
  bind; `--no-auth` is refused on a non-loopback bind. The page and the MCP endpoint can share
55
55
  one port with `serve`.
56
56
 
57
- ## 0.18.0 to 0.20.12: what changed
57
+ ## 0.18.0 to 0.20.13: what changed
58
58
 
59
59
  | Change | Since | Why it matters |
60
60
  | :--- | :--- | :--- |
@@ -63,6 +63,7 @@ one port with `serve`.
63
63
  | The audit verifies snapshot claims, not only hashes | 0.20.1, 0.20.2 | Artifact counts, bodies, packs and workspace indexes are recomputed; a hand-edited snapshot fails. |
64
64
  | `health` skips a secret check in linear time | 0.20.3 | A large skipped-secret set no longer re-reads the snapshot per token. |
65
65
  | Security hardening across CLI, scanner, redaction, MCP, serve and remote | 0.20.4-0.20.12 | CodeQL, audit and live-verdict findings: path confinement, redaction continuations, rate limiting, 413 flushing, part-size caps, IPv6 remote parsing, git/walk parity and clone cleanup. |
66
+ | MCP 2026-07-28 transport conformance | 0.20.13 | Required HTTP routing headers and header/body agreement, cache hints on every cacheable result, `-32602` for a missing modern resource, and stateless handling of `mcp-session-id`. Official v2 client tests cover modern stdio and HTTP. |
66
67
 
67
68
  ## Behaviour changes to know
68
69
 
@@ -74,6 +75,10 @@ one port with `serve`.
74
75
  must run everywhere.
75
76
  3. **The 0.20.12 HTTP/MCP limits are stricter.** Empty JSON-RPC batches are invalid, oversized
76
77
  bodies return 413 before the socket closes, and content tools refuse a part above 16 MiB.
78
+ 4. **The 0.20.13 modern transport is stricter.** A `2026-07-28` HTTP request must carry
79
+ `MCP-Protocol-Version`, `Mcp-Method` and, for named calls, `Mcp-Name`; a mismatch is
80
+ refused before dispatch instead of being silently routed on the body. Modern cacheable
81
+ results carry `ttlMs: 0` and `cacheScope: "private"`, and a missing resource is `-32602`.
77
82
 
78
83
  `validate` on a snapshot written by an older version still works: newer manifest keys are
79
84
  optional, and an artifact the manifest does not record is not required to exist.
@@ -57,6 +57,12 @@ executable config in it is refused, because a fetched repository is not a truste
57
57
  `--no-auth` is refused on a non-loopback bind.
58
58
  - **Constant-time** token comparison; the token is generated with `crypto.randomBytes`.
59
59
  - **CORS only for loopback origins** and explicit `--allow-origin` values; everything else is 403.
60
+ The allowed request headers include `Mcp-Method` and `Mcp-Name` so a browser can send the
61
+ modern routing headers.
62
+ - **Header/body agreement.** A modern request is refused with HTTP 400 and `-32020` when
63
+ `MCP-Protocol-Version`, `Mcp-Method` or `Mcp-Name` is missing or disagrees with the parsed
64
+ body. Routing decisions cannot be made from a header the handler did not verify against the
65
+ value it executes.
60
66
  - **Bounded work**: 2 MiB bodies, 60 requests per 10 s per address, one JSON document per response,
61
67
  and at most four MCP tool calls in flight across all HTTP sessions. The session and rate maps are
62
68
  capped and evicted, so a client cannot grow either without bound.
@@ -114,7 +120,7 @@ to treat file content as data. This is a real, documented limitation, not a solv
114
120
 
115
121
  ## What changed since this review was written
116
122
 
117
- The review was written at 0.12.34. Between then and 0.20.12 the surfaces it covers grew; each
123
+ The review was written at 0.12.34. Between then and 0.20.13 the surfaces it covers grew; each
118
124
  addition was reviewed with the same question — what new input arrives, and what does it reach?
119
125
 
120
126
  - **`GET /metrics`** (0.13.3) publishes counters with a fixed label set. Repo paths, tokens and
@@ -158,6 +164,9 @@ addition was reviewed with the same question — what new input arrives, and wha
158
164
  for a missing local source and cleans an in-flight clone on close; IPv6 remote literals parse;
159
165
  `**` counts as one wildcard and brace products are bounded; and the describe contract, tool
160
166
  annotations and documentation statements were corrected where the source disagreed.
167
+ - **The 0.20.13 MCP conformance pass** checked the modern Streamable HTTP rules against the
168
+ published revision and the official v2 client: header/body agreement, cache fields and
169
+ resource errors.
161
170
 
162
171
  The residual risks below are unchanged, including the two that are deliberate rather than solved.
163
172
 
@@ -169,6 +178,8 @@ The residual risks below are unchanged, including the two that are deliberate ra
169
178
  | Redaction masks the span only | redaction suite (hundreds of cases) |
170
179
  | Health catches a leaked secret and never echoes it | `tests/health.test.js` |
171
180
  | HTTP: 401 without token, 403 cross-origin, 413 oversize, 400 bad JSON | `tests/mcp-http.test.js` |
181
+ | Modern HTTP: required headers, mismatch 400/-32020, cache fields, -32602, CORS | `tests/mcp-modern-http.test.js` |
182
+ | Official MCP v2 client: modern stdio and modern HTTP, discovery, tools, resources | `tests/mcp-sdk-interop.test.js` |
172
183
  | SSE: token required, unknown session 404, shutdown does not hang | `tests/mcp-http.test.js` |
173
184
  | Remote: private addresses refused, credentials in URL refused, `file:` gated | `tests/remote-source.test.js` |
174
185
  | Serve: page without token, API with token, zip restricted | `tests/web-serve.test.js` |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codebase-snapshot",
3
- "version": "0.20.12",
3
+ "version": "0.20.13",
4
4
  "description": "Turn a repository into LLM-ready Markdown under a hard byte budget: a manifest of every included and skipped file, secret redaction, drift validation, and an MCP server for Claude, ChatGPT and Cursor.",
5
5
  "keywords": [
6
6
  "codebase-snapshot",
@@ -127,6 +127,7 @@
127
127
  "esbuild": "^0.28.1"
128
128
  },
129
129
  "devDependencies": {
130
+ "@modelcontextprotocol/client": "^2.4.0",
130
131
  "@types/node": "^22.0.0",
131
132
  "marked": "^18.1.3",
132
133
  "tsup": "^8.3.0"