proxy_export_har
Export HTTP/HTTPS traffic logs in HAR format using a domain filter, timestamp, and custom filename for detailed monitoring and analysis.
Instructions
Export traffic log as HAR (HTTP Archive) format
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| domain | No | Filter by specific domain | |
| filename | No | Output filename (without .har extension) | |
| since | No | ISO timestamp to export entries since |
Implementation Reference
- src/tools/tool-handlers.js:357-370 (handler)Handler case for 'proxy_export_har' tool that invokes trafficAnalyzer.exportHAR with user arguments and formats a success response with export details.case 'proxy_export_har': const harFile = await this.trafficAnalyzer.exportHAR({ domain: args.domain, since: args.since ? new Date(args.since) : undefined, filename: args.filename }); return { content: [{ type: "text", text: `📁 HAR file exported: ${harFile.filename}\nEntries: ${harFile.entryCount}\nSize: ${harFile.fileSize} bytes` }] };
- Tool definition including name, description, and input schema for validating arguments: domain (string), since (ISO string), filename (string).proxy_export_har: { name: "proxy_export_har", description: "Export traffic log as HAR (HTTP Archive) format", inputSchema: { type: "object", properties: { domain: { type: "string", description: "Filter by specific domain" }, since: { type: "string", description: "ISO timestamp to export entries since" }, filename: { type: "string", description: "Output filename (without .har extension)" } } } },
- Core helper method that performs the actual HAR export: filters traffic entries, builds HAR 1.2 format JSON, writes to file (with default naming), and returns file metadata used by the tool handler.async exportHAR(options = {}) { const entries = this.getEntries({ domain: options.domain, since: options.since }); const har = { log: { version: "1.2", creator: { name: "Web Proxy MCP Server", version: "1.0" }, pages: [], entries: entries.map(entry => this._convertToHAREntry(entry)) } }; const filename = options.filename ? `${options.filename}.har` : `traffic-${new Date().toISOString().slice(0, 19).replace(/:/g, '-')}.har`; const filepath = path.resolve(filename); const content = JSON.stringify(har, null, 2); await fs.writeFile(filepath, content); return { filename, filepath, entryCount: entries.length, fileSize: content.length }; }