Skip to main content
Glama

clear_network_capture

Clear captured network data while keeping the capture session active to prevent memory issues during long-running network analysis.

Instructions

Clear all captured network data without stopping the capture session. Resets request/response buffers while keeping capture active. Useful for long-running captures where you want to periodically clear old data to prevent memory issues.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesSession ID obtained from initialize_session

Implementation Reference

  • The core handler function that executes the tool logic: retrieves the session, validates active network capture, clears all captured data arrays (requests, responses, wsFrames, streamingResponses) while preserving the capture session and CDP client, and returns a status object.
    export async function clearNetworkCapture(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}.`); } // Clear all data arrays but keep capture running captureData.requests = []; captureData.responses = []; captureData.wsFrames = []; captureData.streamingResponses = []; return { sessionId, status: "cleared", message: "Network capture data cleared, capture continues", options: captureData.options, }; }
  • Defines the tool name, description, and input schema for 'clear_network_capture', specifying that it requires a 'sessionId' string parameter.
    { name: "clear_network_capture", description: "Clear all captured network data without stopping the capture session. Resets request/response buffers while keeping capture active. Useful for long-running captures where you want to periodically clear old data to prevent memory issues.", inputSchema: { type: "object", properties: { sessionId: { type: "string", description: "Session ID obtained from initialize_session", }, }, required: ["sessionId"], }, },
  • src/index.js:591-601 (registration)
    Registers the tool dispatch in the MCP CallToolRequestSchema handler: validates the sessionId argument and calls the clearNetworkCapture function.
    case "clear_network_capture": { const { sessionId } = args; if (!sessionId) { throw new McpError( ErrorCode.InvalidParams, "sessionId parameter is required" ); } result = await clearNetworkCapture(sessionId); break; }
  • Re-exports the clearNetworkCapture function from networkCapture.js to make it available for import in index.js.
    export { startNetworkCapture, stopNetworkCapture, getNetworkCaptureStatus, clearNetworkCapture, } from "./networkCapture.js";
  • src/index.js:19-26 (registration)
    Imports the clearNetworkCapture function along with other tools from reverseEngineer.js for use in the MCP server.
    getCurrentPageInfo, initializeSession, closeSession, startNetworkCapture, stopNetworkCapture, getNetworkCaptureStatus, clearNetworkCapture, } from "./tools/reverseEngineer.js";

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pyscout/webscout-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server