Files
reverse-engineering-anything/tests/boundary/mcp/debuggerHostAvailability.test.ts
T
morluto 2234a7db57 fix(mcp)!: require absolute local paths for pcap capture and debugger sessions (#11508)
* fix(mcp)!: require absolute local paths for pcap capture and debugger sessions

The MCP server's working directory is not the caller's, so sibling local
file contracts refuse a relative path. inspect_pcap_capture (path),
start_rizin_debug_session (path, inferior_tty) and start_gdb_session
(inferior_tty) admitted one and resolved it against the server's
directory. They now use absoluteLocalPathStringSchema.

The inspect-pcap-capture CLI command declares path as a caller path, so
a relative CLI argument is still resolved against the caller's working
directory before the contract sees it. debug-with-rizin and
debug-with-gdb call their managers directly and are unchanged.

BREAKING CHANGE: MCP calls to inspect_pcap_capture,
start_rizin_debug_session and start_gdb_session with a relative path or
inferior_tty are refused with invalid_request. Pass absolute paths.

Fixes #11079

* test(mcp): call the debugger session tools with absolute paths

* fix(cli): describe the inspect-pcap-capture path without the MCP absolute requirement

The CLI resolves a relative capture path, so its help keeps the
caller-path description instead of inheriting the contract's absolute
wording.

* test(pcap): expect the absolute-path format issue beside the empty-path bound
2026-11-16 09:48:52 +08:00

65 lines
2.5 KiB
TypeScript

import { expect, it } from "vitest";
import { expandToolAvailability } from "../../../src/contracts/toolOutputSchemaPrimitives.js";
import { sessionOutputSchemas } from "../../../src/contracts/toolOutputSchemaGroups.js";
import { createApplicationMcpHarness } from "../../fixtures/applicationMcpHarness.js";
import { createTestBinarySession } from "../../fixtures/binarySession.js";
import { parseMcpToolError } from "../../fixtures/mcpToolError.js";
it("reports debugger start host restrictions without requiring an analysis target", async () => {
const session = createTestBinarySession(() => {
throw new Error("discovery must not start binary analysis");
});
const { client } = await createApplicationMcpHarness({ session });
const entries = async (detail: "summary" | "complete") => {
const response = await client.callTool({
name: "binary_session",
arguments: { detail },
});
expect(response.isError).not.toBe(true);
const parsed = sessionOutputSchemas.binary_session.parse(
response.structuredContent,
).result;
expect(parsed.open).toBe(false);
return expandToolAvailability(parsed.tool_availability);
};
for (const detail of ["summary", "complete"] as const) {
const tools = await entries(detail);
for (const name of ["start_gdb_session", "start_rizin_debug_session"]) {
expect(tools.find((tool) => tool.name === name)).toMatchObject(
process.platform === "linux"
? { available: true, reason: "available" }
: {
available: false,
reason: "unsupported_host",
remediation: expect.stringContaining("Linux"),
},
);
}
expect(
tools.find((tool) => tool.name === "gdb_session_status"),
).toMatchObject({ available: true });
}
if (process.platform !== "linux") {
for (const [name, args] of [
["start_gdb_session", {}],
[
"start_rizin_debug_session",
{ path: "/absent.bin", inferior_tty: "/dev/null" },
],
] as const) {
const response = await client.callTool({ name, arguments: args });
expect(response.isError).toBe(true);
expect(parseMcpToolError(response)).toMatchObject({
error: { code: "capability_unavailable" },
});
}
const after = await entries("complete");
for (const name of ["start_gdb_session", "start_rizin_debug_session"])
expect(after.find((tool) => tool.name === name)).toMatchObject({
available: false,
reason: "unsupported_host",
});
}
});