test(mcp): reuse advertised schema in inventory check (#2469)
Reuse the current advertised binary_session definition for real SDK reply validation while preserving all inventory assertions and the 10-second deadline. Avoid initializing validators for unrelated tools in this correctness check. Closes #2453. Assisted-by: Reimu (gensokyo-skills:reimu-incident-triage)
This commit is contained in:
@@ -122,11 +122,18 @@ it("advertises the complete currently available inventory with a session", async
|
|||||||
|
|
||||||
const listed = await client.listTools();
|
const listed = await client.listTools();
|
||||||
const names = listed.tools.map((t) => t.name);
|
const names = listed.tools.map((t) => t.name);
|
||||||
|
const sessionTool = listed.tools.find(
|
||||||
|
({ name }) => name === "binary_session",
|
||||||
|
);
|
||||||
|
if (sessionTool === undefined)
|
||||||
|
throw new Error("Missing advertised binary_session tool");
|
||||||
|
// Validate this reply with its current advertised schema. The SDK otherwise
|
||||||
|
// builds output validators for the entire catalog on the first cached call.
|
||||||
const status = structured(
|
const status = structured(
|
||||||
await client.callTool({
|
await client.callTool(
|
||||||
name: "binary_session",
|
{ name: "binary_session", arguments: {} },
|
||||||
arguments: {},
|
{ toolDefinition: sessionTool },
|
||||||
}),
|
),
|
||||||
);
|
);
|
||||||
const inventory = expandToolAvailability(
|
const inventory = expandToolAvailability(
|
||||||
toolContract("binary_session").outputSchema.parse(status).result
|
toolContract("binary_session").outputSchema.parse(status).result
|
||||||
|
|||||||
Reference in New Issue
Block a user