smartlead_list_campaigns
Retrieve and filter email marketing campaigns by status, with pagination controls to manage campaign lists effectively.
Instructions
List all campaigns with optional filtering.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of campaigns to return | |
| offset | No | Offset for pagination | |
| status | No | Filter campaigns by status |
Implementation Reference
- src/handlers/campaign.ts:268-304 (handler)Executes the tool by validating input with isListCampaignsParams, making a GET request to Smartlead API '/campaigns' endpoint with args as params, and returning formatted response or error.async function handleListCampaigns( args: unknown, apiClient: AxiosInstance, withRetry: <T>(operation: () => Promise<T>, context: string) => Promise<T> ) { if (!isListCampaignsParams(args)) { throw new McpError( ErrorCode.InvalidParams, 'Invalid arguments for smartlead_list_campaigns' ); } try { const response = await withRetry( async () => apiClient.get('/campaigns', { params: args }), 'list campaigns' ); 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/campaign.ts:135-157 (schema)Defines the tool metadata: name, description, category, and input schema for optional parameters (status, limit, offset).export const LIST_CAMPAIGNS_TOOL: CategoryTool = { name: 'smartlead_list_campaigns', description: 'List all campaigns with optional filtering.', category: ToolCategory.CAMPAIGN_MANAGEMENT, inputSchema: { type: 'object', properties: { status: { type: 'string', enum: ['active', 'paused', 'completed'], description: 'Filter campaigns by status', }, limit: { type: 'number', description: 'Maximum number of campaigns to return', }, offset: { type: 'number', description: 'Offset for pagination', }, }, }, };
- src/index.ts:197-199 (registration)Registers the array of campaign tools (including smartlead_list_campaigns schema) to the ToolRegistry if campaignManagement category is enabled.if (enabledCategories.campaignManagement) { toolRegistry.registerMany(campaignTools); }
- src/types/campaign.ts:149-151 (schema)Type guard function used in handler for input validation, allowing any non-null object.export function isListCampaignsParams(args: unknown): args is ListCampaignsParams { return typeof args === 'object' && args !== null; }
- src/handlers/campaign.ts:42-44 (handler)Switch case in handleCampaignTool that dispatches to the specific list campaigns handler.case 'smartlead_list_campaigns': { return handleListCampaigns(args, apiClient, withRetry); }