Merge branch 'v2/main' into v2/fix/tool-row-keys
Both sides added a showcase config row and section after the pagination entry; kept both, structured output first. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HDdo1rNRVQnVRRdsqSrvG3
This commit is contained in:
commit
0f44288c26
1 changed files with 1161 additions and 35 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
|
||||
import { resolve } from "node:path";
|
||||
import * as z from "zod/v4";
|
||||
import { InspectorClient } from "@inspector/core/mcp/inspectorClient.js";
|
||||
import {
|
||||
|
|
@ -45,6 +46,8 @@ import {
|
|||
createAddResourceTool,
|
||||
createAddToolTool,
|
||||
createAddPromptTool,
|
||||
loadConfig,
|
||||
resolveConfig,
|
||||
} from "@modelcontextprotocol/inspector-test-server";
|
||||
import type {
|
||||
MessageEntry,
|
||||
|
|
@ -1214,6 +1217,52 @@ describe("InspectorClient", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("Structured output showcase config (#1908)", () => {
|
||||
// Drives the shipped `structured-output-http.json` end to end — the file
|
||||
// itself, the `list_items` preset registration, and the fixture's nested
|
||||
// payload. A typo in any of the three fails here rather than leaving the
|
||||
// documented showcase quietly broken.
|
||||
const showcaseConfigPath = resolve(
|
||||
import.meta.dirname,
|
||||
"../../../../../../test-servers/configs/structured-output-http.json",
|
||||
);
|
||||
|
||||
it("serves list_items with a summary block and a nested structuredContent", async () => {
|
||||
server = createTestServerHttp(
|
||||
resolveConfig(loadConfig(showcaseConfigPath)),
|
||||
);
|
||||
await server.start();
|
||||
|
||||
client = new InspectorClient(
|
||||
{ type: "streamable-http", url: server.url },
|
||||
{ environment: { transport: createTransportNode } },
|
||||
);
|
||||
await client.connect();
|
||||
|
||||
const tool = await getTool(client, "list_items");
|
||||
expect(tool.outputSchema).toBeDefined();
|
||||
|
||||
const result = await client.callTool(tool, {});
|
||||
expect(result.success).toBe(true);
|
||||
|
||||
// The text block only summarizes — the payload is the structured half.
|
||||
const content = result.result!.content as Array<{
|
||||
type: string;
|
||||
text?: string;
|
||||
}>;
|
||||
expect(content[0].type).toBe("text");
|
||||
expect(content[0].text).toBe("Found 2 items.");
|
||||
|
||||
expect(result.result!.structuredContent).toEqual({
|
||||
items: [
|
||||
{ id: 1, name: "Item A", tags: ["foo", "bar"] },
|
||||
{ id: 2, name: "Item B", tags: ["baz"] },
|
||||
],
|
||||
total: 2,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Default metadata (server-wide _meta)", () => {
|
||||
function metaOf(req: { message: unknown }): Record<string, unknown> {
|
||||
const params = (req.message as { params?: { _meta?: unknown } }).params;
|
||||
|
|
|
|||
Loading…
Reference in a new issue