Skip to content

Commit d4fb2f4

Browse files
cliffhallclaude
andcommitted
test(everything): assert per-session resources for #4808, drop KNOWN BUG marker
The gzip-file-as-resource suite pinned #4808 (a second session's registration evicting the first session's resource of the same name). With session resources now tracked per server, the test asserts the correct behavior: both sessions read their own content and session A still lists the resource. The KNOWN BUG marker is removed, the testing skill's marker example no longer cites #4808, and a changeset records the fix. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: cliffhall <[email protected]>
1 parent 342a3fa commit d4fb2f4

4 files changed

Lines changed: 24 additions & 21 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@modelcontextprotocol/server-everything": patch
3+
---
4+
5+
Session resources are now tracked per server, so two sessions that create a session resource with the same name (for example via `gzip-file-as-resource`) no longer evict each other's resource (#4808).

‎.claude/skills/testing/SKILL.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ above the test (or above its `describe`/class when the whole block pins the
238238
same bug):
239239

240240
```ts
241-
// KNOWN BUG #4808: pins current (wrong) behavior; the fix changes this assertion.
241+
// KNOWN BUG #<N>: pins current (wrong) behavior; the fix changes this assertion.
242242
```
243243

244244
In Python the same text follows `#`. A bug with no issue yet reads

‎src/everything/__tests__/gzip-file-as-resource.test.ts‎

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
* (#4854), with its default limits: fetching a `data:` or local `http:` URL,
44
* returning the gzipped file as a resource link or an embedded resource,
55
* registering it for later reads, and the errors for bad protocols, oversized
6-
* or empty responses and failed fetches. It also pins #4808: two sessions that
7-
* use the same file name evict each other's resource. The configurable limits
8-
* are in `gzip-limits.test.ts`.
6+
* or empty responses and failed fetches. It also guards #4808: two sessions
7+
* that use the same file name each keep their own resource. The configurable
8+
* limits are in `gzip-limits.test.ts`.
99
*/
1010
import { createServer as createHttpServer, type Server } from "node:http";
1111
import { once } from "node:events";
@@ -150,24 +150,21 @@ describe("gzip-file-as-resource", () => {
150150
expect(gunzipSync(blob).toString()).toBe("second");
151151
});
152152

153-
// KNOWN BUG #4808: pins current (wrong) behavior; the fix changes this assertion.
154-
it("evicts another session's resource of the same name (#4808)", async () => {
155-
// Characterization of #4808: session resources are tracked in one
156-
// module-level map keyed by URI, so the second session's registration
157-
// removes the first session's resource from the first session's server.
153+
it("keeps each session's resource when two sessions use the same name (#4808)", async () => {
154+
// Regression guard for #4808: session resources are tracked per server,
155+
// so the second session's registration leaves the first session's
156+
// resource (and its content) in place.
158157
const a = await open();
159158
const b = await open();
159+
const second = `data:text/plain;base64,${Buffer.from("from b").toString("base64")}`;
160160
await gzip(a, { name: "shared.gz", data: DATA_URI });
161-
await gzip(b, { name: "shared.gz", data: DATA_URI });
161+
await gzip(b, { name: "shared.gz", data: second });
162162

163-
await expect(
164-
a.client.readResource({ uri: "demo://resource/session/shared.gz" }),
165-
).rejects.toThrow("Resource demo://resource/session/shared.gz not found");
166-
expect(
167-
gunzipSync(
168-
await readBlob(b, "demo://resource/session/shared.gz"),
169-
).toString(),
170-
).toBe(TEXT);
163+
const uri = "demo://resource/session/shared.gz";
164+
expect(gunzipSync(await readBlob(a, uri)).toString()).toBe(TEXT);
165+
expect(gunzipSync(await readBlob(b, uri)).toString()).toBe("from b");
166+
const { resources } = await a.client.listResources();
167+
expect(resources.map((r) => r.uri)).toContain(uri);
171168
});
172169

173170
it("rejects a URL that is not http, https or data", async () => {

‎src/everything/resources/session.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ import {
55
import { Resource, ResourceLink } from "@modelcontextprotocol/sdk/types.js";
66

77
/**
8-
* Tracks registered session resources by URI to allow updating/removing on re-registration.
9-
* This prevents "Resource already registered" errors when a tool creates a resource
10-
* with the same URI multiple times during a session.
8+
* Tracks registered session resources per server, by URI, to allow updating/removing on
9+
* re-registration. This prevents "Resource already registered" errors when a tool creates
10+
* a resource with the same URI multiple times during a session, without touching another
11+
* session's server that registered the same URI (#4808).
1112
*/
1213
const registeredResources = new WeakMap<
1314
McpServer,

0 commit comments

Comments
 (0)