proxy_add_target
Add a new target domain for proxy monitoring, enabling traffic analysis with optional header and body capture, and control its active status for HTTP/HTTPS traffic.
Instructions
Add a new target domain for proxy monitoring
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| captureBody | No | Capture request/response body | |
| captureHeaders | No | Capture request/response headers | |
| description | No | Optional description of the target | |
| domain | Yes | Domain to monitor (e.g., example.com) | |
| enabled | No | Whether the target is active |
Implementation Reference
- src/tools/tool-handlers.js:158-173 (handler)Tool handler case for 'proxy_add_target' that validates args (via outer validation), calls targetManager.addTarget with parameters, and returns formatted success response.case 'proxy_add_target': const added = this.targetManager.addTarget( args.domain, args.description, { enabled: args.enabled, captureHeaders: args.captureHeaders, captureBody: args.captureBody } ); return { content: [{ type: "text", text: `Target added: ${args.domain}\nStatus: ${added ? 'success' : 'already exists'}\nMonitored domains: ${this.targetManager.getStats().enabled}` }] };
- src/tools/tool-definitions.js:8-40 (schema)Input schema definition for proxy_add_target tool, specifying parameters like domain (required), description, enabled, captureHeaders, captureBody.proxy_add_target: { name: "proxy_add_target", description: "Add a new target domain for proxy monitoring", inputSchema: { type: "object", properties: { domain: { type: "string", description: "Domain to monitor (e.g., example.com)" }, description: { type: "string", description: "Optional description of the target" }, enabled: { type: "boolean", description: "Whether the target is active", default: true }, captureHeaders: { type: "boolean", description: "Capture request/response headers", default: true }, captureBody: { type: "boolean", description: "Capture request/response body", default: false } }, required: ["domain"] } },
- index.js:66-74 (registration)MCP listTools registration using TOOLS object, which includes proxy_add_target schema and description.this.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: Object.entries(TOOLS).map(([name, tool]) => ({ name, description: tool.description, inputSchema: tool.inputSchema })) }; });
- index.js:77-99 (registration)MCP callTool registration that dispatches to ToolHandlers.handleTool based on tool name, executing proxy_add_target when called.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; } catch (error) { console.error(`Tool error [${name}]:`, error.message); throw new McpError( ErrorCode.InternalError, `Tool execution failed: ${error.message}` ); } });
- src/proxy/target-manager.js:19-47 (helper)Supporting utility method in TargetManager class that implements the core logic for adding a proxy target: validation, configuration normalization, storage in Map, PAC update, and logging.addTarget(domain, config = {}) { // Pre-conditions if (!domain || typeof domain !== 'string') { throw new Error('Domain is required and must be a string'); } const targetConfig = { domain: domain.toLowerCase(), enabled: config.enabled !== false, includeSubdomains: config.includeSubdomains !== false, description: config.description || '', captureHeaders: config.captureHeaders !== false, // Default to true captureBody: config.captureBody !== false, // Default to true addedAt: new Date(), ...config }; // Post-conditions: validate critical fields console.assert(typeof targetConfig.captureHeaders === 'boolean', 'captureHeaders must be boolean'); console.assert(typeof targetConfig.captureBody === 'boolean', 'captureBody must be boolean'); console.assert(typeof targetConfig.enabled === 'boolean', 'enabled must be boolean'); this.targets.set(domain.toLowerCase(), targetConfig); this._updatePacFile(); console.log(`✅ Target added: ${domain} (captureHeaders=${targetConfig.captureHeaders}, captureBody=${targetConfig.captureBody})`); return true; }