mirror of
https://github.com/morluto/rea.git
synced 2026-10-12 02:19:24 +00:00
* fix(mcp): deliver tool errors within advertised schema contracts Retain complete typed JSON error content while omitting non-conforming structured errors at the public transport boundary. Recover oversized diagnostics into Evidence before removing their private structured carrier. Update schema-validated client readers and cover actual stdio delivery. Closes #1261 Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing) * test(mcp): read typed errors in canonical Evidence regressions * test(mcp): validate public error diagnostics in acceptance workflows
17 lines
654 B
TypeScript
17 lines
654 B
TypeScript
import type { CallToolResult } from "@modelcontextprotocol/server";
|
|
import { expect } from "vitest";
|
|
import { z } from "zod";
|
|
|
|
import { analysisErrorProjectionSchema } from "../../src/contracts/errorSchemas.js";
|
|
|
|
/** Read and validate the complete typed diagnostic in an MCP tool failure. */
|
|
export function parseMcpToolError(result: CallToolResult) {
|
|
expect(result.isError).toBe(true);
|
|
const text = result.content.find((item) => item.type === "text");
|
|
if (text?.type !== "text") throw new Error("Tool error omitted text content");
|
|
return z
|
|
.object({ error: analysisErrorProjectionSchema })
|
|
.strict()
|
|
.parse(JSON.parse(text.text));
|
|
}
|