feat(mcp): return structured typed tool results

This commit is contained in:
morluto
2026-07-13 11:51:19 +00:00
parent 3be439cbf3
commit eb38e4c402
12 changed files with 203 additions and 32 deletions
+26 -3
View File
@@ -252,6 +252,17 @@ describe("full MCP integration with multi-tool sequences", () => {
},
});
expect(unavailable.isError).toBe(true);
expect(structured(unavailable)).toMatchObject({
error: {
tag: "AnalysisCapabilityUnavailableError",
category: "unsupported_provider",
details: {
providerId: "partial",
operation: "procedure_pseudo_code",
reason: "Decompiler is not installed.",
},
},
});
expect(received[0]).not.toHaveProperty("unknown_registry_approved");
expect(
structured(
@@ -354,7 +365,7 @@ describe("full MCP integration with multi-tool sequences", () => {
expect(names).not.toContain("open_binary");
});
it("propagates remote Hopper errors with structured content", async () => {
it("projects remote failures without provider or bridge details", async () => {
const client = await connect({
execute: () =>
Promise.resolve(err(new HopperRemoteError(-32000, "bridge timeout"))),
@@ -365,8 +376,20 @@ describe("full MCP integration with multi-tool sequences", () => {
arguments: {},
});
expect(result.isError).toBe(true);
expect(text(result)).toContain("HopperRemoteError");
expect(text(result)).toContain("bridge timeout");
expect(structured(result)).toMatchObject({
error: {
tag: "HopperRemoteError",
category: "execution_failure",
details: {
code: -32000,
safeMessage: "bridge timeout",
diagnosticType: "remote",
},
},
});
expect(text(result)).toBe(
"Analysis could not complete. Retry once; if it continues, run `rea doctor`.",
);
});
it("handles concurrent tool calls without corruption", async () => {