Skip to main content
Glama
jonathan-politzki

Smartlead Simplified MCP Server

smartlead_export_campaign_leads

Export campaign lead data to CSV format for analysis or integration with other systems using the campaign ID.

Instructions

Export all leads data from a campaign as CSV.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
campaign_idYesID of the campaign to export leads from

Implementation Reference

  • The core handler function that validates the input parameters using isExportCampaignLeadsParams, makes a GET request to the Smartlead API endpoint `/campaigns/{campaign_id}/leads-export` with text response type, and returns the CSV data or handles errors.
    async function handleExportCampaignLeads(
      args: unknown, 
      apiClient: AxiosInstance,
      withRetry: <T>(operation: () => Promise<T>, context: string) => Promise<T>
    ) {
      if (!isExportCampaignLeadsParams(args)) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Invalid arguments for smartlead_export_campaign_leads'
        );
      }
    
      try {
        const response = await withRetry(
          async () => apiClient.get(`/campaigns/${args.campaign_id}/leads-export`, {
            responseType: 'text'
          }),
          'export campaign leads'
        );
    
        return {
          content: [
            {
              type: 'text',
              text: `CSV Data:\n${response.data}`,
            },
          ],
          isError: false,
        };
      } catch (error: any) {
        return {
          content: [{ 
            type: 'text', 
            text: `API Error: ${error.response?.data?.message || error.message}` 
          }],
          isError: true,
        };
      }
    }
  • The tool metadata definition including the exact name, description, category, and JSON schema for input validation (requires campaign_id as number). This is included in the campaignTools array for registration.
    export const EXPORT_CAMPAIGN_LEADS_TOOL: CategoryTool = {
      name: 'smartlead_export_campaign_leads',
      description: 'Export all leads data from a campaign as CSV.',
      category: ToolCategory.CAMPAIGN_MANAGEMENT,
      inputSchema: {
        type: 'object',
        properties: {
          campaign_id: {
            type: 'number',
            description: 'ID of the campaign to export leads from',
          },
        },
        required: ['campaign_id'],
      },
    };
  • src/index.ts:197-199 (registration)
    Registers the entire campaignTools array (which includes the smartlead_export_campaign_leads tool) to the MCP tool registry if the campaignManagement category is enabled by license/features.
    if (enabledCategories.campaignManagement) {
      toolRegistry.registerMany(campaignTools);
    }
  • Switch case in handleCampaignTool that maps the tool name to the specific handler function.
    case 'smartlead_export_campaign_leads': {
      return handleExportCampaignLeads(args, apiClient, withRetry);
    }
  • src/index.ts:346-347 (registration)
    Top-level dispatch in MCP callTool handler that routes CAMPAIGN_MANAGEMENT category tools to handleCampaignTool based on tool metadata.
    case ToolCategory.CAMPAIGN_MANAGEMENT:
      return await handleCampaignTool(name, toolArgs, apiClient, withRetry);

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jonathan-politzki/smartlead-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server