smartlead_fetch_all_clients
Retrieve a complete list of all clients stored in the Smartlead system to manage email marketing campaigns and client relationships.
Instructions
Retrieve a list of all clients in the system.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/handlers/clientManagement.ts:85-123 (handler)Core implementation of the smartlead_fetch_all_clients tool. Validates input parameters, creates a SmartLead API client, fetches all clients via GET /client/, formats response as JSON text, handles API errors.async function handleFetchAllClients( args: unknown, apiClient: AxiosInstance, withRetry: <T>(operation: () => Promise<T>, context: string) => Promise<T> ) { if (!isFetchAllClientsParams(args)) { throw new McpError( ErrorCode.InvalidParams, 'Invalid arguments for smartlead_fetch_all_clients' ); } try { const smartLeadClient = createSmartLeadClient(apiClient); const response = await withRetry( async () => smartLeadClient.get('/client/'), 'fetch all clients' ); return { content: [ { type: 'text', text: JSON.stringify(response.data, null, 2), }, ], isError: false, }; } catch (error: any) { return { content: [{ type: 'text', text: `API Error: ${error.response?.data?.message || error.message}` }], isError: true, }; } }
- src/tools/clientManagement.ts:42-54 (schema)Defines the tool metadata, description, category, and input schema (no required parameters).export const FETCH_ALL_CLIENTS_TOOL: CategoryTool = { name: 'smartlead_fetch_all_clients', description: 'Retrieve a list of all clients in the system.', category: ToolCategory.CLIENT_MANAGEMENT, inputSchema: { type: 'object', properties: { // This endpoint doesn't require specific parameters beyond the API key // which is handled at the API client level }, required: [], }, };
- src/index.ts:227-229 (registration)Registers the clientManagementTools array (containing smartlead_fetch_all_clients) to the central ToolRegistry if the clientManagement category is enabled.if (enabledCategories.clientManagement) { toolRegistry.registerMany(clientManagementTools); }
- src/handlers/clientManagement.ts:12-28 (handler)Category-level dispatcher that routes smartlead_fetch_all_clients calls to the specific handleFetchAllClients implementation.export async function handleClientManagementTool( toolName: string, args: unknown, apiClient: AxiosInstance, withRetry: <T>(operation: () => Promise<T>, context: string) => Promise<T> ) { switch (toolName) { case 'smartlead_add_client': { return handleAddClient(args, apiClient, withRetry); } case 'smartlead_fetch_all_clients': { return handleFetchAllClients(args, apiClient, withRetry); } default: throw new Error(`Unknown Client Management tool: ${toolName}`); } }
- Helper function that adapts the main Axios client to use SmartLead's API base URL for client management endpoints.function createSmartLeadClient(apiClient: AxiosInstance) { return { get: (url: string, config?: any) => apiClient.get(`${SMARTLEAD_API_URL}${url}`, config), post: (url: string, data?: any, config?: any) => apiClient.post(`${SMARTLEAD_API_URL}${url}`, data, config), put: (url: string, data?: any, config?: any) => apiClient.put(`${SMARTLEAD_API_URL}${url}`, data, config), delete: (url: string, config?: any) => apiClient.delete(`${SMARTLEAD_API_URL}${url}`, config) }; }