stop_network_capture
Stop active network capture sessions in WebScout MCP to retrieve captured traffic data including requests, responses, WebSocket frames, and streaming information with timestamps for analysis.
Instructions
Stop the active network capture session and return all captured data. Returns comprehensive network traffic including requests, responses, WebSocket frames, and streaming data with timestamps and headers. Use this to analyze captured network activity or save data for later processing.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sessionId | Yes | Session ID obtained from initialize_session |
Implementation Reference
- src/tools/networkCapture.js:199-253 (handler)The primary handler function that executes the stop_network_capture tool logic: retrieves capture data from session, disables CDP monitoring, prepares comprehensive results with summary and raw data, and cleans up session storage.export async function stopNetworkCapture(sessionId) { const session = global.activeSessions?.get(sessionId); if (!session) { throw new Error(`Session ${sessionId} not found.`); } const captureData = session.networkCapture; if (!captureData) { throw new Error( `No active network capture for session ${sessionId}. Call startNetworkCapture first.` ); } // Clean up CDP session if (captureData.cdpClient) { try { await captureData.cdpClient.send("Network.disable"); await captureData.cdpClient.send("Fetch.disable"); await captureData.cdpClient.detach(); } catch (e) { // Ignore cleanup errors } } // Calculate capture duration const endTime = Date.now(); const duration = endTime - captureData.startTime; // Prepare result const result = { sessionId, captureId: `capture_${captureData.startTime}`, duration, startTime: new Date(captureData.startTime).toISOString(), endTime: new Date(endTime).toISOString(), summary: { totalRequests: captureData.requests.length, totalResponses: captureData.responses.length, totalWsFrames: captureData.wsFrames.length, streamingResponses: captureData.streamingResponses.length, }, options: captureData.options, data: { requests: captureData.requests, responses: captureData.responses, wsFrames: captureData.wsFrames, streamingResponses: captureData.streamingResponses, }, }; // Clean up session data delete session.networkCapture; return result; }
- src/index.js:349-363 (schema)The input schema and metadata definition for the stop_network_capture tool, registered in the MCP server's listTools response.{ name: "stop_network_capture", description: "Stop the active network capture session and return all captured data. Returns comprehensive network traffic including requests, responses, WebSocket frames, and streaming data with timestamps and headers. Use this to analyze captured network activity or save data for later processing.", inputSchema: { type: "object", properties: { sessionId: { type: "string", description: "Session ID obtained from initialize_session", }, }, required: ["sessionId"], }, },
- src/index.js:567-576 (registration)The dispatch case in the MCP CallToolRequestSchema handler that validates input and calls the stopNetworkCapture handler function.case "stop_network_capture": { const { sessionId } = args; if (!sessionId) { throw new McpError( ErrorCode.InvalidParams, "sessionId parameter is required" ); } result = await stopNetworkCapture(sessionId); break;
- src/tools/reverseEngineer.js:22-27 (helper)Re-export of the stopNetworkCapture function from networkCapture.js, allowing centralized imports in index.js.export { startNetworkCapture, stopNetworkCapture, getNetworkCaptureStatus, clearNetworkCapture, } from "./networkCapture.js";