test(mcp): read typed errors in canonical Evidence regressions
This commit is contained in:
parent
7bf63ed7f8
commit
fd46cff017
|
|
@ -1,10 +1,12 @@
|
|||
import { execFile } from "node:child_process";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { promisify } from "node:util";
|
||||
import { isCallToolResult } from "@modelcontextprotocol/server";
|
||||
import { expect, it } from "vitest";
|
||||
import { z } from "zod";
|
||||
|
||||
import { GENERATED_MCP_TOOL_CATALOG } from "../../fixtures/mcpToolCatalog.js";
|
||||
import { parseMcpToolError } from "../../fixtures/mcpToolError.js";
|
||||
|
||||
const execute = promisify(execFile);
|
||||
const fixture = fileURLToPath(
|
||||
|
|
@ -41,6 +43,8 @@ it("preserves advertised schemas and handler meaning when presentation order cha
|
|||
expect(advertised.outputSchema).toEqual(canonical?.outputSchema);
|
||||
}
|
||||
for (const { name, response } of result.responses) {
|
||||
if (!isCallToolResult(response))
|
||||
throw new Error(`Invalid tools/call fixture result for ${name}`);
|
||||
if (name === "reconcile_javascript_runtime") {
|
||||
expect(response.isError).not.toBe(true);
|
||||
expect(response.structuredContent).toMatchObject({
|
||||
|
|
@ -48,7 +52,7 @@ it("preserves advertised schemas and handler meaning when presentation order cha
|
|||
});
|
||||
} else {
|
||||
expect(response.isError, name).toBe(true);
|
||||
expect(response.structuredContent, name).toMatchObject({
|
||||
expect(parseMcpToolError(response), name).toMatchObject({
|
||||
error: { details: { operation: name } },
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import { registerOfficialTools } from "../../../src/server/registerOfficialTools
|
|||
import { ToolResultDelivery } from "../../../src/server/toolResult.js";
|
||||
import { EvidenceMcpServer } from "../../../src/server/EvidenceMcpServer.js";
|
||||
import { encodeToolResult } from "../../../src/server/toolResultEncoding.js";
|
||||
import { parseMcpToolError } from "../../fixtures/mcpToolError.js";
|
||||
|
||||
const delivery = new ToolResultDelivery(STDIO_DEFAULT_MAX_BUFFER_SIZE);
|
||||
|
||||
|
|
@ -188,7 +189,7 @@ describe("large complete Evidence MCP delivery", () => {
|
|||
}),
|
||||
}),
|
||||
})
|
||||
.parse(result.structuredContent).error.details.reported_limits;
|
||||
.parse(parseMcpToolError(result)).error.details.reported_limits;
|
||||
const retained = parseEvidence(
|
||||
records.get(limits.evidence_reference.evidence_id),
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue