proxy_import_config
Import proxy configuration from a file to set up or update your Web Proxy MCP Server settings for automated traffic monitoring and analysis.
Instructions
Import proxy configuration from file
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"filepath": "<filepath>"
},
"name": "proxy_import_config"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filepath | Yes | Path to configuration file | |
| merge | No | Merge with existing config or replace |
Implementation Reference
- src/proxy/target-manager.js:308-322 (handler)Core handler function that reads the configuration file, optionally clears existing targets if merge=false, parses and imports targets using importTargets method, and returns import results.
async importFromFile(filepath, merge = false) { try { const fs = await import('fs/promises'); const data = await fs.readFile(filepath, 'utf-8'); if (!merge) { this.targets.clear(); } const imported = this.importTargets(data); return { imported, merge }; } catch (error) { throw new Error(`Failed to import from file: ${error.message}`); } } - Tool schema defining input parameters: filepath (required string) and optional merge boolean.
proxy_import_config: { name: "proxy_import_config", description: "Import proxy configuration from file", inputSchema: { type: "object", properties: { filepath: { type: "string", description: "Path to configuration file" }, merge: { type: "boolean", description: "Merge with existing config or replace", default: false } }, required: ["filepath"] } }, - src/tools/tool-handlers.js:398-410 (handler)ToolHandlers dispatch case for proxy_import_config: validates args, calls targetManager.importFromFile, formats and returns success message with stats.
case 'proxy_import_config': const imported = await this.targetManager.importFromFile( args.filepath, args.merge ); return { content: [{ type: "text", text: `📥 Configuration imported from ${args.filepath}\nTargets imported: ${imported.imported}\nTotal targets: ${this.targetManager.getStats().total}` }] }; - src/proxy/target-manager.js:219-235 (helper)Helper method called by importFromFile: parses JSON, iterates over targets, adds each via addTarget, counts imported.
importTargets(jsonData) { try { const data = JSON.parse(jsonData); let imported = 0; if (data.targets && typeof data.targets === 'object') { for (const [domain, config] of Object.entries(data.targets)) { this.addTarget(domain, config); imported++; } } return imported; } catch (error) { throw new Error(`Failed to import targets: ${error.message}`); } } - src/tools/tool-handlers.js:23-62 (registration)Main ToolHandlers.handleTool method: validates input using schema from tool-definitions, routes 'proxy_import_config' (contains 'config') to _handleConfigTool which contains the specific case.
async handleTool(name, args = {}) { // Validate arguments const validation = validateToolArgs(name, args); if (!validation.valid) { return { error: validation.error, isError: true }; } try { // Route to appropriate handler if (name.startsWith('proxy_target_') || name.includes('_target')) { return await this._handleTargetTool(name, args); } else if (name.startsWith('proxy_server_') || name.includes('_server')) { return await this._handleServerTool(name, args); } else if (name.startsWith('ssl_')) { return await this._handleSSLTool(name, args); } else if (name.includes('setup') || name.includes('pac')) { return await this._handleSetupTool(name, args); } else if (name.includes('traffic') || name.includes('har')) { return await this._handleTrafficTool(name, args); } else if (name.includes('config')) { return await this._handleConfigTool(name, args); } else if (name.includes('analyze') || name.includes('metrics')) { return await this._handleAnalysisTool(name, args); } return { error: `Unknown tool: ${name}`, isError: true }; } catch (error) { return { error: error.message, isError: true, stack: error.stack }; } }