smartlead_get_campaign
Retrieve detailed information about a specific email marketing campaign using its unique ID to monitor performance and track campaign metrics.
Instructions
Get details of a specific campaign by ID.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| campaign_id | Yes | ID of the campaign to retrieve |
Implementation Reference
- src/handlers/campaign.ts:230-266 (handler)The handler function that validates input, makes the API GET request to /campaigns/{campaign_id}, and returns the campaign details or error.async function handleGetCampaign( args: unknown, apiClient: AxiosInstance, withRetry: <T>(operation: () => Promise<T>, context: string) => Promise<T> ) { if (!isGetCampaignParams(args)) { throw new McpError( ErrorCode.InvalidParams, 'Invalid arguments for smartlead_get_campaign' ); } try { const response = await withRetry( async () => apiClient.get(`/campaigns/${args.campaign_id}`), 'get 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:119-133 (schema)Tool schema definition including name, description, category, and input schema requiring 'campaign_id'.export const GET_CAMPAIGN_TOOL: CategoryTool = { name: 'smartlead_get_campaign', description: 'Get details of a specific campaign by ID.', category: ToolCategory.CAMPAIGN_MANAGEMENT, inputSchema: { type: 'object', properties: { campaign_id: { type: 'number', description: 'ID of the campaign to retrieve', }, }, required: ['campaign_id'], }, };
- src/index.ts:197-199 (registration)Registers the campaignTools array (which includes smartlead_get_campaign) with the tool registry if campaignManagement category is enabled.if (enabledCategories.campaignManagement) { toolRegistry.registerMany(campaignTools); }
- src/types/campaign.ts:131-138 (helper)Type guard function used in the handler to validate that input args contain a valid 'campaign_id' number.export function isGetCampaignParams(args: unknown): args is GetCampaignParams { return ( typeof args === 'object' && args !== null && 'campaign_id' in args && typeof (args as { campaign_id: unknown }).campaign_id === 'number' ); }
- src/handlers/campaign.ts:39-41 (registration)Switch case in handleCampaignTool that routes 'smartlead_get_campaign' calls to the specific handleGetCampaign function.case 'smartlead_get_campaign': { return handleGetCampaign(args, apiClient, withRetry); }