smartlead_add_client
Add a new client to the Smartlead email marketing system with configurable permissions and optional white-label branding settings.
Instructions
Add a new client to the system, optionally with white-label settings.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| Yes | Email address of the client | ||
| logo | No | Logo text or identifier | |
| logo_url | No | URL to the client's logo image | |
| name | Yes | Name of the client | |
| password | Yes | Password for the client's account | |
| permission | Yes | Array of permissions to grant to the client. Use ["full_access"] for full permissions. |
Implementation Reference
- src/handlers/clientManagement.ts:45-83 (handler)Core handler function that validates input parameters using isAddClientParams, creates a SmartLead API client proxy, performs POST request to '/client/save' endpoint with retry logic, and returns formatted API response or error.async function handleAddClient( args: unknown, apiClient: AxiosInstance, withRetry: <T>(operation: () => Promise<T>, context: string) => Promise<T> ) { if (!isAddClientParams(args)) { throw new McpError( ErrorCode.InvalidParams, 'Invalid arguments for smartlead_add_client' ); } try { const smartLeadClient = createSmartLeadClient(apiClient); const response = await withRetry( async () => smartLeadClient.post('/client/save', args), 'add client' ); 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/types/clientManagement.ts:7-37 (schema)TypeScript interface defining input parameters for smartlead_add_client and runtime type guard (isAddClientParams) for validation.export interface AddClientParams { name: string; email: string; permission: ClientPermission[]; logo?: string; logo_url?: string | null; password: string; } // Fetch all clients export interface FetchAllClientsParams { // This endpoint doesn't require specific parameters beyond the API key // which is handled at the API client level } // Type guards export function isAddClientParams(args: unknown): args is AddClientParams { if (typeof args !== 'object' || args === null) return false; const params = args as Partial<AddClientParams>; return ( typeof params.name === 'string' && typeof params.email === 'string' && Array.isArray(params.permission) && params.permission.every(perm => typeof perm === 'string') && typeof params.password === 'string' && (params.logo === undefined || typeof params.logo === 'string') && (params.logo_url === undefined || params.logo_url === null || typeof params.logo_url === 'string') ); }
- src/tools/clientManagement.ts:5-40 (schema)MCP tool definition including JSON input schema for smartlead_add_client parameters.export const ADD_CLIENT_TOOL: CategoryTool = { name: 'smartlead_add_client', description: 'Add a new client to the system, optionally with white-label settings.', category: ToolCategory.CLIENT_MANAGEMENT, inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Name of the client', }, email: { type: 'string', description: 'Email address of the client', }, permission: { type: 'array', items: { type: 'string' }, description: 'Array of permissions to grant to the client. Use ["full_access"] for full permissions.', }, logo: { type: 'string', description: 'Logo text or identifier', }, logo_url: { type: ['string', 'null'], description: 'URL to the client\'s logo image', }, password: { type: 'string', description: 'Password for the client\'s account', }, }, required: ['name', 'email', 'permission', 'password'], }, };
- src/index.ts:226-229 (registration)Registers the clientManagementTools array (including smartlead_add_client) to the tool registry if clientManagement category is enabled.// Register client management tools if enabled if (enabledCategories.clientManagement) { toolRegistry.registerMany(clientManagementTools); }
- src/handlers/clientManagement.ts:12-28 (registration)Dispatcher function for client management tools that routes 'smartlead_add_client' calls to the specific handleAddClient 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}`); } }