proxy_import_config
Load and apply proxy server configurations from a specified file, with options to merge or replace existing settings. Simplify setup and management for automated traffic handling in the Web Proxy MCP Server.
Instructions
Import proxy configuration from file
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filepath | Yes | Path to configuration file | |
| merge | No | Merge with existing config or replace |
Implementation Reference
- src/tools/tool-handlers.js:398-409 (handler)Core execution logic for the proxy_import_config tool. Calls targetManager.importFromFile with filepath and merge options, then returns a text content response with import statistics.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}` }] };
- Tool definition including name, description, and inputSchema for parameter validation (filepath required, merge optional).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"] } },
- index.js:66-74 (registration)MCP listTools request handler that exposes the proxy_import_config tool's schema and description from the central TOOLS object.this.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: Object.entries(TOOLS).map(([name, tool]) => ({ name, description: tool.description, inputSchema: tool.inputSchema })) }; });
- index.js:77-91 (registration)MCP callTool request handler that routes proxy_import_config calls to the centralized ToolHandlers.handleTool method for execution.this.server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; try { const result = await this.toolHandlers.handleTool(name, args || {}); if (result.isError) { throw new McpError( ErrorCode.InternalError, result.error ); } return result;
- src/proxy/target-manager.js:308-322 (helper)Helper method in TargetManager that reads the config file, optionally clears existing targets, imports the JSON data, 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}`); } }