proxy_analyze_traffic
Analyzes HTTP/HTTPS traffic patterns and statistics by domain, method, status, or hour, enabling detailed insights into web proxy activity for informed decision-making.
Instructions
Analyze captured traffic patterns and statistics
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| domain | No | Analyze specific domain only | |
| groupBy | No | Group analysis results by | domain |
| timeframe | No | Time frame for analysis | 24h |
Implementation Reference
- src/tools/tool-handlers.js:437-453 (handler)Tool handler implementation in ToolHandlers._handleAnalysisTool switch case. Validates arguments earlier, calls TrafficAnalyzer.analyzeTraffic with parameters, formats and returns the analysis as text content.case 'proxy_analyze_traffic': if (!this.trafficAnalyzer) { return { error: "Traffic analyzer not available", isError: true }; } const analysis = this.trafficAnalyzer.analyzeTraffic({ domain: args.domain, timeframe: args.timeframe, groupBy: args.groupBy }); return { content: [{ type: "text", text: `📊 Traffic Analysis (${args.timeframe})\n\n${JSON.stringify(analysis, null, 2)}` }] };
- Tool definition and input schema definition in the exported TOOLS object, used for validation and MCP tool listing.proxy_analyze_traffic: { name: "proxy_analyze_traffic", description: "Analyze captured traffic patterns and statistics", inputSchema: { type: "object", properties: { domain: { type: "string", description: "Analyze specific domain only" }, timeframe: { type: "string", enum: ["1h", "24h", "7d", "30d", "all"], description: "Time frame for analysis", default: "24h" }, groupBy: { type: "string", enum: ["domain", "method", "status", "hour"], description: "Group analysis results by", default: "domain" } } } },
- Core analysis logic in TrafficAnalyzer class. Filters entries by time/domain, computes summary statistics (requests, domains, avg time, error rate), groups by specified field using _groupEntries.analyzeTraffic(options = {}) { const entries = this.getEntries({ domain: options.domain, since: this._getTimeframeSince(options.timeframe || '24h') }); if (entries.length === 0) { return { summary: { totalRequests: 0, uniqueDomains: 0, timeframe: options.timeframe || '24h' } }; } const analysis = { summary: { totalRequests: entries.length, uniqueDomains: new Set(entries.map(e => e.domain)).size, timeframe: options.timeframe || '24h', avgResponseTime: this._calculateAverage(entries.map(e => e.responseTime)), errorRate: entries.filter(e => e.statusCode >= 400).length / entries.length }, grouped: this._groupEntries(entries, options.groupBy || 'domain') }; return analysis; }