proxy_clear_traffic_log
Remove recorded traffic logs from the Web Proxy MCP Server. Optionally clears logs for a specific domain, with a confirmation flag to prevent accidental deletion.
Instructions
Clear the traffic log
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| confirm | Yes | Confirmation flag to prevent accidental deletion | |
| domain | No | Clear logs for specific domain only |
Implementation Reference
- src/tools/tool-handlers.js:371-385 (handler)Handler logic for the proxy_clear_traffic_log tool. Validates the confirm flag, calls trafficAnalyzer.clearEntries with optional domain, and returns a success message with cleared and remaining entry counts.case 'proxy_clear_traffic_log': if (!args.confirm) { return { error: "Confirmation required to clear traffic log", isError: true }; } const cleared = this.trafficAnalyzer.clearEntries(args.domain); return { content: [{ type: "text", text: `🗑️ Traffic log cleared\nEntries removed: ${cleared}\nRemaining: ${this.trafficAnalyzer.getEntryCount()}` }] };
- JSON schema definition for the tool inputs, requiring a confirm boolean and optionally a domain string.proxy_clear_traffic_log: { name: "proxy_clear_traffic_log", description: "Clear the traffic log", inputSchema: { type: "object", properties: { domain: { type: "string", description: "Clear logs for specific domain only" }, confirm: { type: "boolean", description: "Confirmation flag to prevent accidental deletion", default: false } }, required: ["confirm"] } },
- Core utility method in TrafficAnalyzer that implements the clearing logic: filters out entries by domain if specified, or empties the entire array and resets statistics./** * Clear entries * @param {string} domain - Optional domain filter * @returns {number} Number of cleared entries */ clearEntries(domain = null) { let cleared = 0; if (domain) { const originalLength = this.entries.length; this.entries = this.entries.filter(entry => !entry.domain.includes(domain) ); cleared = originalLength - this.entries.length; } else { cleared = this.entries.length; this.entries = []; this.stats = { totalRequests: 0, totalResponseTime: 0, domainsTracked: new Set(), startTime: new Date() }; } return cleared; }