Skip to content

Commit 63dc92f

Browse files
cliffhallclaude
andcommitted
fix(everything): label dynamic blob resources application/octet-stream
blobResource() returned base64 content typed text/plain while the blob resource template declares application/octet-stream, so resources/read, get-resource-reference, get-resource-links and resource-prompt all reported the wrong type. It now uses application/octet-stream. The "binary blob resource" description arm in get-resource-links is now live, so its v8 ignore is removed. The four pinning tests assert the corrected type and their KNOWN BUG #4984 markers are gone. Closes #4984 Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: cliffhall <[email protected]>
1 parent 571e2b3 commit 63dc92f

6 files changed

Lines changed: 15 additions & 19 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+
Label dynamic blob resources `application/octet-stream`, matching their resource template, instead of `text/plain`. This applies to `resources/read`, the `get-resource-reference` and `get-resource-links` tools, and the `resource-prompt` prompt; blob resource links are now described as "binary blob resource".

‎src/everything/__tests__/prompts.test.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ describe("resource-prompt", () => {
9696
});
9797
});
9898

99-
// KNOWN BUG #4984: blobResource() labels blob content text/plain instead of a binary MIME type; the fix changes this assertion.
10099
it("embeds a blob resource", async () => {
101100
const result = await session.client.getPrompt({
102101
name: "resource-prompt",
@@ -107,7 +106,7 @@ describe("resource-prompt", () => {
107106
type: "resource",
108107
resource: {
109108
uri: "demo://resource/dynamic/blob/2",
110-
mimeType: "text/plain",
109+
mimeType: "application/octet-stream",
111110
blob: expect.any(String),
112111
},
113112
},

‎src/everything/__tests__/resources.test.ts‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,12 @@ describe("dynamic resource templates", () => {
6161
]);
6262
});
6363

64-
// KNOWN BUG #4984: blobResource() labels blob content text/plain instead of a binary MIME type; the fix changes this assertion.
65-
it("fabricates a blob resource from its id, labelled text/plain", async () => {
66-
// Characterization: the template advertises application/octet-stream,
67-
// but the content says text/plain (#4854 baseline).
64+
it("fabricates a blob resource from its id, labelled application/octet-stream", async () => {
65+
// The content's type matches the one the blob template advertises.
6866
const uri = "demo://resource/dynamic/blob/9";
6967
const { contents } = await session.client.readResource({ uri });
7068
expect(contents).toEqual([
71-
{ uri, mimeType: "text/plain", blob: expect.any(String) },
69+
{ uri, mimeType: "application/octet-stream", blob: expect.any(String) },
7270
]);
7371
const blob = "blob" in contents[0] ? contents[0].blob : "";
7472
expect(Buffer.from(blob, "base64").toString()).toMatch(

‎src/everything/__tests__/tools.test.ts‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ describe("trigger-long-running-operation", () => {
206206
});
207207

208208
describe("get-resource-links", () => {
209-
// KNOWN BUG #4984: blobResource() labels blob content text/plain instead of a binary MIME type; the fix changes this assertion.
210209
it("returns three links by default, blob for odd ids and text for even", async () => {
211210
const result = await call("get-resource-links");
212211
const content = contentOf(result);
@@ -218,10 +217,8 @@ describe("get-resource-links", () => {
218217
type: "resource_link",
219218
uri: "demo://resource/dynamic/blob/1",
220219
name: "Blob Resource 1",
221-
// Characterization: blobResource() reports text/plain, so every link
222-
// is described as a plaintext resource (#4854 baseline).
223-
description: "Resource 1: plaintext resource",
224-
mimeType: "text/plain",
220+
description: "Resource 1: binary blob resource",
221+
mimeType: "application/octet-stream",
225222
},
226223
{
227224
type: "resource_link",
@@ -234,8 +231,8 @@ describe("get-resource-links", () => {
234231
type: "resource_link",
235232
uri: "demo://resource/dynamic/blob/3",
236233
name: "Blob Resource 3",
237-
description: "Resource 3: plaintext resource",
238-
mimeType: "text/plain",
234+
description: "Resource 3: binary blob resource",
235+
mimeType: "application/octet-stream",
239236
},
240237
]);
241238
});
@@ -271,15 +268,14 @@ describe("get-resource-reference", () => {
271268
);
272269
});
273270

274-
// KNOWN BUG #4984: blobResource() labels blob content text/plain instead of a binary MIME type; the fix changes this assertion.
275271
it("returns an embedded blob resource", async () => {
276272
const result = await call("get-resource-reference", {
277273
resourceType: "Blob",
278274
resourceId: 7,
279275
});
280276
const embedded = contentOfType(contentOf(result)[1], "resource").resource;
281277
expect(embedded.uri).toBe("demo://resource/dynamic/blob/7");
282-
expect(embedded.mimeType).toBe("text/plain");
278+
expect(embedded.mimeType).toBe("application/octet-stream");
283279
const blob = "blob" in embedded ? embedded.blob : "";
284280
expect(Buffer.from(blob, "base64").toString()).toMatch(
285281
/^Resource 7: This is a base64 blob created at /,

‎src/everything/resources/templates.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export const blobResource = (uri: URL, resourceId: number) => {
105105
).toString("base64");
106106
return {
107107
uri: uri.toString(),
108-
mimeType: "text/plain",
108+
mimeType: "application/octet-stream",
109109
blob: resourceText,
110110
};
111111
};

‎src/everything/tools/get-resource-links.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,9 @@ export const registerGetResourceLinksTool = (server: McpServer) => {
7373
uri: resource.uri,
7474
name: `${isOdd ? "Text" : "Blob"} Resource ${resourceId}`,
7575
description: `Resource ${resourceId}: ${
76-
/* v8 ignore start -- the false arm is dead: blobResource() also reports text/plain (pinned in tools.test.ts) */
7776
resource.mimeType === "text/plain"
7877
? "plaintext resource"
7978
: "binary blob resource"
80-
/* v8 ignore stop */
8179
}`,
8280
mimeType: resource.mimeType,
8381
});

0 commit comments

Comments
 (0)