proxy_export_config
Export current proxy configuration to a file for backup, sharing, or analysis purposes. Specify file path and optionally include traffic logs.
Instructions
Export current proxy configuration to file
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "proxy_export_config"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filepath | No | Output file path | |
| includeTrafficLog | No | Include traffic log in export |
Implementation Reference
- src/tools/tool-handlers.js:411-424 (handler)The main handler for the proxy_export_config tool within _handleConfigTool. It validates args via validateToolArgs (called earlier), then calls targetManager.exportToFile with filepath and optional trafficLog from trafficAnalyzer, and returns a formatted success response with export details.
case 'proxy_export_config': const exported = await this.targetManager.exportToFile( args.filepath, args.includeTrafficLog && this.trafficAnalyzer ? { trafficLog: this.trafficAnalyzer.getAllEntries() } : undefined ); return { content: [{ type: "text", text: `📤 Configuration exported to ${exported.filepath}\nTargets: ${exported.targetCount}\nFile size: ${exported.fileSize} bytes` }] }; - Tool definition including name, description, and JSON schema for input validation (filepath required, includeTrafficLog optional boolean). Used by validateToolArgs and listTools.
proxy_export_config: { name: "proxy_export_config", description: "Export current proxy configuration to file", inputSchema: { type: "object", properties: { filepath: { type: "string", description: "Output file path" }, includeTrafficLog: { type: "boolean", description: "Include traffic log in export", default: false } } } }, - index.js:66-74 (registration)MCP server registration of all tools (including proxy_export_config) via ListToolsRequestHandler, exposing name, description, and inputSchema from the imported TOOLS object.
this.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: Object.entries(TOOLS).map(([name, tool]) => ({ name, description: tool.description, inputSchema: tool.inputSchema })) }; }); - src/proxy/target-manager.js:330-357 (helper)Core helper function in TargetManager that performs the actual file export: ensures directory exists, constructs JSON with targets and additionalData (e.g., trafficLog), writes file, returns filepath, targetCount, and fileSize.
async exportToFile(filepath, additionalData = {}) { try { const fs = await import('fs/promises'); const path = await import('path'); // Ensure directory exists const dir = path.dirname(filepath); await fs.mkdir(dir, { recursive: true }); const exportData = { version: '1.0', exportedAt: new Date().toISOString(), targets: Object.fromEntries(this.targets), ...additionalData }; const content = JSON.stringify(exportData, null, 2); await fs.writeFile(filepath, content); return { filepath, targetCount: this.targets.size, fileSize: content.length }; } catch (error) { throw new Error(`Failed to export to file: ${error.message}`); } }