proxy_analyze_traffic
Analyze captured HTTP/HTTPS traffic patterns and statistics to monitor proxy activity, identify trends, and group data by domain, method, status, or time period.
Instructions
Analyze captured traffic patterns and statistics
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| domain | No | Analyze specific domain only | |
| timeframe | No | Time frame for analysis | 24h |
| groupBy | No | Group analysis results by | domain |
Implementation Reference
- src/tools/tool-handlers.js:437-453 (handler)Tool handler case that validates args, calls trafficAnalyzer.analyzeTraffic(), and formats the response.
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 with name, description, and inputSchema for validation.
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 implementation of traffic analysis: filters entries, computes summary stats and grouped data.
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; }