* 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
87 lines
2.6 KiB
TypeScript
87 lines
2.6 KiB
TypeScript
import { parseMcpToolError } from "../../fixtures/mcpToolError.js";
|
|
import { describe, expect, it } from "vitest";
|
|
import { connectGhidraMcp } from "./ghidraMcpHarness.js";
|
|
|
|
describe("Ghidra MCP capability routing", () => {
|
|
it("routes composed and capability tools", async () => {
|
|
const harness = await connectGhidraMcp("ghidra-routing");
|
|
const { calls, mcp } = harness;
|
|
try {
|
|
const batch = await mcp.callTool({
|
|
name: "batch_decompile",
|
|
arguments: { addresses: ["fixture_main"] },
|
|
});
|
|
expect(batch.isError).not.toBe(true);
|
|
expect(batch.structuredContent).toMatchObject({
|
|
normalized_result: {
|
|
succeeded: 1,
|
|
failed: 0,
|
|
items: [{ status: "ok" }],
|
|
},
|
|
});
|
|
|
|
const availableNames = (await mcp.listTools()).tools.map(
|
|
({ name }) => name,
|
|
);
|
|
expect(availableNames).toContain("set_comment");
|
|
const denied = await mcp.callTool({
|
|
name: "set_comment",
|
|
arguments: { address: "0x1000", comment: "must not mutate" },
|
|
});
|
|
expect(denied.isError).toBe(true);
|
|
expect(parseMcpToolError(denied)).toMatchObject({
|
|
error: {
|
|
code: "capability_unavailable",
|
|
category: "unsupported_provider",
|
|
},
|
|
});
|
|
expect(calls).not.toContain("set_comment");
|
|
|
|
const status = await mcp.callTool({
|
|
name: "binary_session",
|
|
arguments: {},
|
|
});
|
|
expect(status.structuredContent).toMatchObject({
|
|
result: {
|
|
open: true,
|
|
analysis_provider_binding: {
|
|
provider: { id: "ghidra", version: "12.1.4" },
|
|
},
|
|
tool_availability: expect.arrayContaining([
|
|
expect.objectContaining({
|
|
name: "binary_overview",
|
|
available: true,
|
|
}),
|
|
expect.objectContaining({
|
|
name: "get_objc_classes",
|
|
available: true,
|
|
}),
|
|
expect.objectContaining({
|
|
name: "batch_decompile",
|
|
available: true,
|
|
}),
|
|
expect.objectContaining({
|
|
name: "trace_feature",
|
|
available: true,
|
|
}),
|
|
expect.objectContaining({
|
|
name: "get_call_graph",
|
|
available: true,
|
|
}),
|
|
expect.objectContaining({
|
|
name: "find_xrefs_to_name",
|
|
available: true,
|
|
}),
|
|
expect.objectContaining({
|
|
name: "set_comment",
|
|
available: false,
|
|
}),
|
|
]),
|
|
},
|
|
});
|
|
} finally {
|
|
await harness.close();
|
|
}
|
|
}, 30_000);
|
|
});
|