Inspect selected fields in existing captures through shared CLI/MCP Evidence. Page matching frames without changing dissection or two-pass read coverage; retain failed descriptor/process cleanup ownership and reject excess admission. Verified with real TShark 4.0.17 and 4.2.2, public Wireshark recordings, owned HTTP application traffic, real CLI/MCP workflows and schema checks. Co-authored-by: Olorinm <59321404+Olorinm@users.noreply.github.com> Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing)
32 lines
1.2 KiB
TypeScript
32 lines
1.2 KiB
TypeScript
import type { EvidenceMcpServer } from "./EvidenceMcpServer.js";
|
|
import type { PacketCaptureService } from "../application/captures/PacketCaptureService.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 the named capture contract through shared admission and retained Evidence delivery. */
|
|
export const registerCaptureTools = (
|
|
server: EvidenceMcpServer,
|
|
service: PacketCaptureService,
|
|
logger: Logger,
|
|
recordEvidence?: EvidenceWriter["recordEvidence"],
|
|
withAdmittedAnalysis?: WithAdmittedAnalysis,
|
|
): void => {
|
|
const contract = toolContract("inspect_packet_capture");
|
|
const handler = createEvidenceToolHandler(
|
|
server,
|
|
(input, options) => service.inspect(input, options),
|
|
logger,
|
|
recordEvidence,
|
|
withAdmittedAnalysis,
|
|
);
|
|
server.registerTool(
|
|
contract.name,
|
|
toolRegistrationOptions(contract),
|
|
handler(contract),
|
|
);
|
|
};
|