Files
reverse-engineering-anything/src/server/admittedToolOperation.ts
T
morluto e94ca9f223 refactor(mcp): bind GDB and Cutter tools under external-mutation admission through the shared table (#11637)
* refactor(mcp): bind GDB and Cutter tools under external-mutation admission through the shared table

GDB start and status, and Cutter discovery, bind as values outside admission; gdb_console and cutter_command bind on the external-mutation evidence kind (gdb_console with delivery detail), and close_gdb_session on owned-cleanup. Tests build their servers through one debugger fixture, and the Rizin lifecycle regressions now run for all three debuggers.

* refactor(mcp): bind the session target, context and process capture tools through the shared table (#11640)

Value bindings can return a ReducibleValue (alternatives tried when the complete value overflows) or a DetailedFailure (facts delivered beside the error's details). A new query binding reads the analysis its required admission grants. open_binary and open_bundle_resources bind as values; get_navigation_context and inspect_address_context as queries; capture_process_scenario on the analyze kind through an application owner that records its Evidence and residual unknowns.
2026-11-16 09:28:35 +08:00

33 lines
1.3 KiB
TypeScript

import type {
ServerContext,
CallToolResult,
} from "@modelcontextprotocol/server";
import { toolReturnsTargetContent } from "../contracts/toolEffects.js";
import type { AnalysisOperationPort } from "../ports/AnalysisProvider.js";
import type { EvidenceMcpServer } from "./EvidenceMcpServer.js";
import type { WithAdmittedAnalysis } from "./analysisAdmission.js";
/**
* Run one complete tool workflow inside session admission when supplied,
* passing it the analysis admission grants (none without admission).
* `operationName` is the MCP tool name; an admission failure is marked with
* that tool's target-content provenance like any other of its results.
*/
export const runAdmittedToolOperation = async (
server: Pick<EvidenceMcpServer, "delivery">,
admission: WithAdmittedAnalysis | undefined,
operationName: string,
signal: ServerContext["mcpReq"]["signal"],
operation: (analysis?: AnalysisOperationPort) => Promise<CallToolResult>,
): Promise<CallToolResult> => {
if (admission === undefined) return operation();
const admitted = await admission(operationName, signal, operation);
return admitted.ok
? admitted.value
: server.delivery.toErrorToolResult(
admitted.error,
toolReturnsTargetContent(operationName),
);
};