Skip to content

armgit / rea

Public Imported from GitHub
0

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

test(mcp): validate public error diagnostics in acceptance workflows

N0zoM1z009058ebc4a68
diff --git a/tests/acceptance/tools/historicalCaptureResources.test.ts b/tests/acceptance/tools/historicalCaptureResources.test.ts
index 057b46133..7aea0fcce 100644
--- a/tests/acceptance/tools/historicalCaptureResources.test.ts
+++ b/tests/acceptance/tools/historicalCaptureResources.test.ts
@@ -7,6 +7,7 @@ import { expect, it } from "vitest";
import { WEB_NETWORK_CAPTURE_LIMITS } from "../../../src/domain/webNetworkCapture.js";
import { connectLocalToolsMcp } from "../../fixtures/localToolsMcp.js";
+import { parseMcpToolError } from "../../fixtures/mcpToolError.js";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
const execute = promisify(execFile);
@@ -56,7 +57,7 @@ it("reports real HAR heap exhaustion through CLI and MCP and preserves server us
sensitive_values: ["caller-marked"],
});
expect(response.isError).toBe(true);
- expect(response.structuredContent).toMatchObject({
+ expect(parseMcpToolError(response)).toMatchObject({
error: {
code: "resource_constraint",
retryable: false,
@@ -110,7 +111,7 @@ it("reports real HAR heap exhaustion through CLI and MCP and preserves server us
capture_path: path,
format: "har",
});
- expect(oversized.structuredContent).toMatchObject({
+ expect(parseMcpToolError(oversized)).toMatchObject({
error: { code: "invalid_request" },
});
}, 60_000);
diff --git a/tests/acceptance/tools/inspectorLifecycle.test.ts b/tests/acceptance/tools/inspectorLifecycle.test.ts
index 8dc8f27cf..cf1c79180 100644
--- a/tests/acceptance/tools/inspectorLifecycle.test.ts
+++ b/tests/acceptance/tools/inspectorLifecycle.test.ts
@@ -6,6 +6,7 @@ import { expect, it, onTestFinished } from "vitest";
import { toolContract } from "../../../src/contracts/toolContracts.js";
import { connectLocalToolsMcp } from "../../fixtures/localToolsMcp.js";
+import { parseMcpToolError } from "../../fixtures/mcpToolError.js";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
it("observes a real Node Inspector and releases attachments after cancellation and failures", async () => {
@@ -62,7 +63,7 @@ it("observes a real Node Inspector and releases attachments after cancellation a
target_id: "../missing-target",
});
expect(missing.isError).toBe(true);
- expect(missing.structuredContent).toMatchObject({
+ expect(parseMcpToolError(missing)).toMatchObject({
error: {
code: "target_unavailable",
message: expect.stringContaining("Refresh target discovery"),
@@ -114,7 +115,7 @@ it("observes a real Node Inspector and releases attachments after cancellation a
inspector_endpoint: endpoint,
});
expect(unreachable.isError).toBe(true);
- expect(unreachable.structuredContent).toMatchObject({
+ expect(parseMcpToolError(unreachable)).toMatchObject({
error: {
code: "provider_unavailable",
message: expect.stringContaining(
diff --git a/tests/acceptance/tools/localToolContracts.test.ts b/tests/acceptance/tools/localToolContracts.test.ts
index 218d111c5..7bfc9dfc0 100644
--- a/tests/acceptance/tools/localToolContracts.test.ts
+++ b/tests/acceptance/tools/localToolContracts.test.ts
@@ -9,6 +9,7 @@ import { toolContract } from "../../../src/contracts/toolContracts.js";
import { parseEvidence } from "../../../src/domain/evidence.js";
import { itWithCaptureCapability as captureTest } from "../../boundary/process/processCaptureCapability.js";
import { connectLocalToolsMcp } from "../../fixtures/localToolsMcp.js";
+import { parseMcpToolError } from "../../fixtures/mcpToolError.js";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
const execute = promisify(execFile);
@@ -180,7 +181,7 @@ captureTest(
const failed = await call("capture_process_scenario", {
executable: missing,
});
- expect(failed.structuredContent).toMatchObject({
+ expect(parseMcpToolError(failed)).toMatchObject({
error: {
code: "process_capture_failed",
message: expect.stringContaining(missing),
diff --git a/tests/process-global/mcpDeliveryEnvironment.test.ts b/tests/process-global/mcpDeliveryEnvironment.test.ts
index acf0796b0..33bb18ed5 100644
--- a/tests/process-global/mcpDeliveryEnvironment.test.ts
+++ b/tests/process-global/mcpDeliveryEnvironment.test.ts
@@ -9,6 +9,7 @@ import { ok } from "../../src/domain/result.js";
import { run } from "../../src/main.js";
import { createServer } from "../../src/server/createServer.js";
import type { EvidenceMcpServer } from "../../src/server/EvidenceMcpServer.js";
+import { parseMcpToolError } from "../fixtures/mcpToolError.js";
const resources: Array<{ close(): Promise<void> }> = [];
afterEach(async () => {
@@ -89,8 +90,10 @@ it("keeps independent server budgets for successful results and oversized errors
}),
),
);
+ if (smallResult === undefined || largeResult === undefined)
+ throw new Error("Missing result from selected-budget server");
expect(smallResult?.isError).toBe(true);
- expect(smallResult?.structuredContent).toMatchObject({
+ expect(parseMcpToolError(smallResult)).toMatchObject({
error: {
code: "resource_constraint",
details: {
@@ -110,7 +113,9 @@ it("keeps independent server budgets for successful results and oversized errors
client.callTool({ name: "selected_failure", arguments: {} }),
),
);
- expect(smallFailure?.structuredContent).toMatchObject({
+ if (smallFailure === undefined || largeFailure === undefined)
+ throw new Error("Missing failure from selected-budget server");
+ expect(parseMcpToolError(smallFailure)).toMatchObject({
error: {
code: "resource_constraint",
details: {
@@ -122,7 +127,7 @@ it("keeps independent server budgets for successful results and oversized errors
},
},
});
- expect(largeFailure?.structuredContent).toMatchObject({
+ expect(parseMcpToolError(largeFailure)).toMatchObject({
error: {
code: "invalid_request",
details: { issues: [{ message: diagnostic }] },