smartlead_delete_campaign
Permanently delete a specific email marketing campaign by its ID using the Smartlead Simplified MCP Server to manage your campaign list.
Instructions
Delete a campaign permanently.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| campaign_id | Yes | ID of the campaign to delete |
Implementation Reference
- src/handlers/campaign.ts:463-498 (handler)The primary handler function that implements the tool logic: validates input using isDeleteCampaignParams, makes a DELETE API call to `/campaigns/${campaign_id}`, and returns the response or error.async function handleDeleteCampaign( args: unknown, apiClient: AxiosInstance, withRetry: <T>(operation: () => Promise<T>, context: string) => Promise<T> ) { if (!isDeleteCampaignParams(args)) { throw new McpError( ErrorCode.InvalidParams, 'Invalid arguments for smartlead_delete_campaign' ); } try { const response = await withRetry( async () => apiClient.delete(`/campaigns/${args.campaign_id}`), 'delete campaign' ); 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:289-303 (schema)Tool schema definition including name, description, category, and input schema requiring 'campaign_id'.export const DELETE_CAMPAIGN_TOOL: CategoryTool = { name: 'smartlead_delete_campaign', description: 'Delete a campaign permanently.', category: ToolCategory.CAMPAIGN_MANAGEMENT, inputSchema: { type: 'object', properties: { campaign_id: { type: 'number', description: 'ID of the campaign to delete', }, }, required: ['campaign_id'], }, };
- src/types/campaign.ts:188-195 (schema)Runtime type guard (isDeleteCampaignParams) and TypeScript interface (DeleteCampaignParams) for input validation.export function isDeleteCampaignParams(args: unknown): args is DeleteCampaignParams { return ( typeof args === 'object' && args !== null && 'campaign_id' in args && typeof (args as { campaign_id: unknown }).campaign_id === 'number' ); }
- src/index.ts:197-199 (registration)Registers the campaign tools (including smartlead_delete_campaign) with the tool registry if the category is enabled.if (enabledCategories.campaignManagement) { toolRegistry.registerMany(campaignTools); }
- src/handlers/campaign.ts:57-59 (registration)Switch case in handleCampaignTool that routes the tool call to the specific handleDeleteCampaign function.case 'smartlead_delete_campaign': { return handleDeleteCampaign(args, apiClient, withRetry); }