Skip to content

armgit / rea

Public Imported from GitHub
0

Reverse engineer anything with agents, from app behavior down to native binaries.

test(mcp): read typed errors in canonical Evidence regressions

N0zoM1z0fd46cff017f0
diff --git a/tests/boundary/mcp/contractPresentation.test.ts b/tests/boundary/mcp/contractPresentation.test.ts
index 2a3c9f7ec..9d1d9d6bb 100644
--- a/tests/boundary/mcp/contractPresentation.test.ts
+++ b/tests/boundary/mcp/contractPresentation.test.ts
@@ -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 } },
});
}
diff --git a/tests/boundary/mcp/largeToolResult.test.ts b/tests/boundary/mcp/largeToolResult.test.ts
index 76122951a..00afa2d7a 100644
--- a/tests/boundary/mcp/largeToolResult.test.ts
+++ b/tests/boundary/mcp/largeToolResult.test.ts
@@ -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),
);