Skip to content

Commit 4b54ad6

Browse files
cliffhallclaude
andcommitted
fix(everything): name resource-prompt's allowed argument values
Prompt arguments carry no JSON Schema, only a description, so a client had no way to learn that resourceType accepts only "Text" or "Blob", or that resourceId must be a positive integer, before the prompt rejected the call. Both descriptions now say so, built from the RESOURCE_TYPE_* constants, and a protocol-level test reads them back from prompts/list in both eras, along with a check that every prompt argument is described. Closes #3985 Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: cliffhall <[email protected]>
1 parent 446be48 commit 4b54ad6

4 files changed

Lines changed: 69 additions & 5 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+
`resource-prompt` now names the values its arguments accept in `prompts/list`: `resourceType` must be "Text" or "Blob", and `resourceId` must be a positive integer. Prompt arguments carry no schema, so clients had no way to learn these before calling the prompt.

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

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
* `{resourceId}` variable.
66
*/
77
import { afterEach, beforeEach, describe, expect, it } from "vitest";
8-
import { connect, textOf, type Session } from "./harness.js";
8+
import { connect, connectModern, textOf, type Session } from "./harness.js";
9+
import {
10+
RESOURCE_TYPE_BLOB,
11+
RESOURCE_TYPE_TEXT,
12+
} from "../resources/templates.js";
913

1014
let session: Session;
1115

@@ -235,3 +239,48 @@ describe("completion/complete for resource templates", () => {
235239
expect(completion.values).toEqual(expected);
236240
});
237241
});
242+
243+
/**
244+
* Prompt arguments carry no JSON Schema over the wire, only a name, a
245+
* description and `required`, so the description is the one place a client
246+
* can learn what an argument accepts (#3985). Checked in both eras, since each
247+
* is served by its own code path.
248+
*/
249+
describe.each([
250+
["2025-era", connect],
251+
["2026-07-28", connectModern],
252+
])("prompts/list argument descriptions (%s)", (_era, open) => {
253+
let listed: Session;
254+
255+
beforeEach(async () => {
256+
listed = await open();
257+
});
258+
259+
afterEach(async () => {
260+
await listed.close();
261+
});
262+
263+
it("describes every argument of every prompt", async () => {
264+
const { prompts } = await listed.client.listPrompts();
265+
const undescribed = prompts.flatMap((prompt) =>
266+
(prompt.arguments ?? [])
267+
.filter((argument) => !argument.description?.trim())
268+
.map((argument) => `${prompt.name}.${argument.name}`),
269+
);
270+
expect(undescribed).toEqual([]);
271+
});
272+
273+
it("names resource-prompt's allowed values in its argument descriptions", async () => {
274+
const { prompts } = await listed.client.listPrompts();
275+
const prompt = prompts.find((p) => p.name === "resource-prompt");
276+
const descriptionOf = (name: string) =>
277+
prompt?.arguments?.find((argument) => argument.name === name)
278+
?.description;
279+
expect(descriptionOf("resourceType")).toBe(
280+
`Type of resource to fetch. Must be "${RESOURCE_TYPE_TEXT}" or "${RESOURCE_TYPE_BLOB}".`,
281+
);
282+
expect(descriptionOf("resourceId")).toBe(
283+
"ID of the resource to fetch. Must be a positive integer (1 or greater).",
284+
);
285+
});
286+
});

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -806,12 +806,12 @@ describe("prompts/list", () => {
806806
"_meta": undefined,
807807
"arguments": [
808808
{
809-
"description": "Type of resource to fetch",
809+
"description": "Type of resource to fetch. Must be "Text" or "Blob".",
810810
"name": "resourceType",
811811
"required": true,
812812
},
813813
{
814-
"description": "ID of the text resource to fetch",
814+
"description": "ID of the resource to fetch. Must be a positive integer (1 or greater).",
815815
"name": "resourceId",
816816
"required": true,
817817
},

‎src/everything/resources/templates.ts‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@ export const RESOURCE_TYPES: string[] = [
2626
* The completion logic matches the input against available resource types.
2727
*/
2828
export const resourceTypeCompleter = completable(
29-
z.string().describe("Type of resource to fetch"),
29+
// Prompt arguments carry no JSON Schema, only a description, so the
30+
// description is the only place a client can learn the allowed values (#3985)
31+
z
32+
.string()
33+
.describe(
34+
`Type of resource to fetch. Must be "${RESOURCE_TYPE_TEXT}" or "${RESOURCE_TYPE_BLOB}".`,
35+
),
3036
(value: string) => {
3137
return RESOURCE_TYPES.filter((t) => t.startsWith(value));
3238
},
@@ -49,7 +55,11 @@ export const resourceTypeCompleter = completable(
4955
* This helps validate and suggest appropriate resource IDs.
5056
*/
5157
export const resourceIdForPromptCompleter = completable(
52-
z.string().describe("ID of the text resource to fetch"),
58+
z
59+
.string()
60+
.describe(
61+
"ID of the resource to fetch. Must be a positive integer (1 or greater).",
62+
),
5363
(value: string) => {
5464
const resourceId = Number(value);
5565
return Number.isInteger(resourceId) && resourceId > 0 ? [value] : [];

0 commit comments

Comments
 (0)