set-proxy-config
Configure and manage proxy settings for all cryptocurrency exchanges on the CCXT MCP Server, enabling secure and controlled access to trading platforms. Define proxy URL, credentials, and clear cache for immediate changes.
Instructions
Configure proxy settings for all exchanges
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| clearCache | No | Clear exchange cache to apply changes immediately | |
| enabled | Yes | Enable or disable proxy | |
| password | No | Proxy password (optional) | |
| url | Yes | Proxy URL (e.g., http://proxy-server:port) | |
| username | No | Proxy username (optional) |
Implementation Reference
- src/tools/config.ts:49-97 (handler)The handler function that implements the set-proxy-config tool logic by setting environment variables for proxy configuration and optionally clearing the exchange cache.}, async ({ enabled, url, username, password, clearCache }) => { try { // For security and simplicity, we'll use environment variables // In a production app, you might want to use a more persistent storage method process.env.USE_PROXY = enabled.toString(); if (url) { process.env.PROXY_URL = url; } if (username !== undefined) { process.env.PROXY_USERNAME = username; } if (password !== undefined) { process.env.PROXY_PASSWORD = password; } log(LogLevel.INFO, `Proxy configuration updated. Enabled: ${enabled}`); // Clear exchange cache if requested if (clearCache) { clearExchangeCache(); log(LogLevel.INFO, "Exchange cache cleared to apply new proxy settings"); } return { content: [{ type: "text", text: JSON.stringify({ message: "Proxy configuration updated successfully", cacheCleared: clearCache, note: clearCache ? "Exchange cache was cleared. New proxy settings will be applied immediately." : "Changes will only affect newly created exchange instances. Use clear-exchange-cache tool for immediate effect." }, null, 2) }] }; } catch (error) { log(LogLevel.ERROR, `Error updating proxy configuration: ${error instanceof Error ? error.message : String(error)}`); return { content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } });
- src/tools/config.ts:44-48 (schema)Zod input schema defining parameters for the set-proxy-config tool.enabled: z.boolean().describe("Enable or disable proxy"), url: z.string().describe("Proxy URL (e.g., http://proxy-server:port)"), username: z.string().optional().describe("Proxy username (optional)"), password: z.string().optional().describe("Proxy password (optional)"), clearCache: z.boolean().default(true).describe("Clear exchange cache to apply changes immediately")
- src/tools/config.ts:43-97 (registration)The server.tool call that registers the set-proxy-config tool with schema and inline handler.server.tool("set-proxy-config", "Configure proxy settings for all exchanges", { enabled: z.boolean().describe("Enable or disable proxy"), url: z.string().describe("Proxy URL (e.g., http://proxy-server:port)"), username: z.string().optional().describe("Proxy username (optional)"), password: z.string().optional().describe("Proxy password (optional)"), clearCache: z.boolean().default(true).describe("Clear exchange cache to apply changes immediately") }, async ({ enabled, url, username, password, clearCache }) => { try { // For security and simplicity, we'll use environment variables // In a production app, you might want to use a more persistent storage method process.env.USE_PROXY = enabled.toString(); if (url) { process.env.PROXY_URL = url; } if (username !== undefined) { process.env.PROXY_USERNAME = username; } if (password !== undefined) { process.env.PROXY_PASSWORD = password; } log(LogLevel.INFO, `Proxy configuration updated. Enabled: ${enabled}`); // Clear exchange cache if requested if (clearCache) { clearExchangeCache(); log(LogLevel.INFO, "Exchange cache cleared to apply new proxy settings"); } return { content: [{ type: "text", text: JSON.stringify({ message: "Proxy configuration updated successfully", cacheCleared: clearCache, note: clearCache ? "Exchange cache was cleared. New proxy settings will be applied immediately." : "Changes will only affect newly created exchange instances. Use clear-exchange-cache tool for immediate effect." }, null, 2) }] }; } catch (error) { log(LogLevel.ERROR, `Error updating proxy configuration: ${error instanceof Error ? error.message : String(error)}`); return { content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } });