Inspect bounded recorded raw HTTP/XML SAZ archives and page retained capture Evidence. Preserve exact stored bytes and provenance, validate ZIP/XML integrity, and require an enforceable decoder memory bound. Verified 356 real recorded sessions against independent byte and metadata oracles, public CLI/MCP parity, retained pages, and related interface checks. Current Fiddler Everywhere GUI and non-Linux producer workflows remain unverified. Co-authored-by: zahhak <1792039+zahhak@users.noreply.github.com> Co-authored-by: N0zoM1z0 <161784452+N0zoM1z0@users.noreply.github.com>
78 lines
3.1 KiB
TypeScript
78 lines
3.1 KiB
TypeScript
import type { EvidenceMcpServer } from "./EvidenceMcpServer.js";
|
|
import type { StandardSchemaWithJSON } from "@modelcontextprotocol/server";
|
|
import type { EvidenceLookup } from "../application/EvidenceInputResolver.js";
|
|
import {
|
|
requireAnalysisViewRetention,
|
|
summarizeRetainedAnalysis,
|
|
} from "../application/analysisView/AnalysisViewService.js";
|
|
import { analysisInputErrorFromIssues } from "../domain/inputIssueProjection.js";
|
|
import { redactExplicitFailure } from "../domain/explicitSensitiveFailure.js";
|
|
import { captureSensitiveValues } from "../domain/webNetworkCapture.js";
|
|
import { err } from "../domain/result.js";
|
|
import type { WebNetworkCaptureService } from "../application/WebNetworkCaptureService.js";
|
|
import type { EvidenceWriter } from "../application/investigation/InvestigationRecordPort.js";
|
|
import { toolContract } from "../contracts/toolContracts.js";
|
|
import type { Logger } from "pino";
|
|
import type { WithAdmittedAnalysis } from "./analysisAdmission.js";
|
|
import { createEvidenceToolHandler } from "./contractToolHandler.js";
|
|
import { toolRegistrationOptions } from "./toolRegistrationOptions.js";
|
|
|
|
/** Bind historical inspection to its named contract and caller-owned Evidence writer. */
|
|
export const registerWebNetworkCaptureTool = (
|
|
server: EvidenceMcpServer,
|
|
service: WebNetworkCaptureService,
|
|
logger: Logger,
|
|
recordEvidence?: EvidenceWriter["recordEvidence"],
|
|
withAdmittedAnalysis?: WithAdmittedAnalysis,
|
|
evidenceById?: EvidenceLookup,
|
|
): void => {
|
|
const contract = toolContract("inspect_web_network_capture");
|
|
const registration = toolRegistrationOptions(contract);
|
|
// Keep the exact advertised contract; the shared service validates raw input
|
|
// before effects so caller-declared sensitivity also covers invalid arguments.
|
|
// SDK pre-validation otherwise emits unprojected issue paths as plain text.
|
|
const inputSchema: StandardSchemaWithJSON = {
|
|
"~standard": {
|
|
...registration.inputSchema["~standard"],
|
|
vendor: "rea-application",
|
|
validate: (value: unknown) => ({ value }),
|
|
},
|
|
};
|
|
const handler = createEvidenceToolHandler(
|
|
server,
|
|
async (rawInput, options) => {
|
|
const parsed = contract.inputSchema.safeParse(rawInput);
|
|
if (!parsed.success)
|
|
return err(
|
|
redactExplicitFailure(
|
|
analysisInputErrorFromIssues(
|
|
contract.name,
|
|
parsed.error.issues,
|
|
rawInput,
|
|
{ cause: parsed.error },
|
|
),
|
|
captureSensitiveValues(rawInput),
|
|
),
|
|
);
|
|
const { detail, ...input } = parsed.data;
|
|
const retention = { recordEvidence, evidenceById };
|
|
if (detail === "summary") {
|
|
const ready = requireAnalysisViewRetention(contract.name, retention);
|
|
if (!ready.ok) return ready;
|
|
}
|
|
const inspected = await service.inspect(input, options);
|
|
return detail === "summary" && inspected.ok
|
|
? summarizeRetainedAnalysis(inspected.value, retention)
|
|
: inspected;
|
|
},
|
|
logger,
|
|
recordEvidence,
|
|
withAdmittedAnalysis,
|
|
);
|
|
server.registerTool(
|
|
contract.name,
|
|
{ ...registration, inputSchema },
|
|
handler(contract),
|
|
);
|
|
};
|