Skip to main content
Glama
jonathan-politzki

Smartlead Simplified MCP Server

smartlead_create_campaign

Create new email marketing campaigns in Smartlead by defining campaign names and client IDs to organize and launch targeted email outreach.

Instructions

Create a new campaign in Smartlead.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
client_idNoClient ID for the campaign
nameYesName of the campaign

Implementation Reference

  • Core handler function that executes the smartlead_create_campaign tool: validates input parameters using isCreateCampaignParams, performs POST request to Smartlead API /campaigns/create endpoint with retry logic, formats and returns the response or error.
    async function handleCreateCampaign(
      args: unknown, 
      apiClient: AxiosInstance,
      withRetry: <T>(operation: () => Promise<T>, context: string) => Promise<T>
    ) {
      if (!isCreateCampaignParams(args)) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Invalid arguments for smartlead_create_campaign'
        );
      }
    
      try {
        const response = await withRetry(
          async () => apiClient.post('/campaigns/create', args),
          'create 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,
        };
      }
    }
  • Tool definition including name, description, category, and JSON schema for input validation of smartlead_create_campaign.
    export const CREATE_CAMPAIGN_TOOL: CategoryTool = {
      name: 'smartlead_create_campaign',
      description: 'Create a new campaign in Smartlead.',
      category: ToolCategory.CAMPAIGN_MANAGEMENT,
      inputSchema: {
        type: 'object',
        properties: {
          name: {
            type: 'string',
            description: 'Name of the campaign',
          },
          client_id: {
            type: 'number',
            description: 'Client ID for the campaign',
          },
        },
        required: ['name'],
      },
    };
  • TypeScript interface and runtime type guard (isCreateCampaignParams) for input parameters used in the handler validation.
    // Type definitions for campaign management
    
    export interface CreateCampaignParams {
      name: string;
      client_id?: number;
    }
    
    export interface UpdateCampaignScheduleParams {
      campaign_id: number;
      timezone?: string;
      days_of_the_week?: number[];
      start_hour?: string;
      end_hour?: string;
      min_time_btw_emails?: number;
      max_new_leads_per_day?: number;
      schedule_start_time?: string;
    }
    
    export interface UpdateCampaignSettingsParams {
      campaign_id: number;
      name?: string;
      status?: 'active' | 'paused' | 'completed';
      settings?: Record<string, any>;
    }
    
    export interface UpdateCampaignStatusParams {
      campaign_id: number;
      status: 'PAUSED' | 'STOPPED' | 'START';
    }
    
    export interface GetCampaignParams {
      campaign_id: number;
    }
    
    export interface GetCampaignSequenceParams {
      campaign_id: number;
    }
    
    export interface ListCampaignsParams {
      status?: 'active' | 'paused' | 'completed';
      limit?: number;
      offset?: number;
    }
    
    export interface SaveCampaignSequenceParams {
      campaign_id: number;
      sequence: Array<{
        seq_number: number;
        seq_delay_details: {
          delay_in_days: number;
        };
        variant_distribution_type: 'MANUAL_EQUAL' | 'MANUAL_PERCENTAGE' | 'AI_EQUAL';
        lead_distribution_percentage?: number;
        winning_metric_property?: 'OPEN_RATE' | 'CLICK_RATE' | 'REPLY_RATE' | 'POSITIVE_REPLY_RATE';
        seq_variants: Array<{
          subject: string;
          email_body: string;
          variant_label: string;
          id?: number;
          variant_distribution_percentage?: number;
        }>;
      }>;
    }
    
    // New interface definitions for remaining campaign management endpoints
    export interface GetCampaignsByLeadParams {
      lead_id: number;
    }
    
    export interface ExportCampaignLeadsParams {
      campaign_id: number;
    }
    
    export interface DeleteCampaignParams {
      campaign_id: number;
    }
    
    export interface GetCampaignAnalyticsByDateParams {
      campaign_id: number;
      start_date: string;
      end_date: string;
    }
    
    export interface GetCampaignSequenceAnalyticsParams {
      campaign_id: number;
      start_date: string;
      end_date: string;
      time_zone?: string;
    }
    
    // Type guards
    export function isCreateCampaignParams(args: unknown): args is CreateCampaignParams {
      return (
        typeof args === 'object' &&
        args !== null &&
        'name' in args &&
        typeof (args as { name: unknown }).name === 'string'
      );
    }
  • src/index.ts:197-199 (registration)
    Registers the array of campaign tools (including smartlead_create_campaign) to the toolRegistry if the campaignManagement category is enabled by license/features.
    if (enabledCategories.campaignManagement) {
      toolRegistry.registerMany(campaignTools);
    }
  • src/index.ts:346-347 (registration)
    In the main CallToolRequest handler, dispatches to handleCampaignTool for tools in CAMPAIGN_MANAGEMENT category, which routes to the specific create campaign handler.
    case ToolCategory.CAMPAIGN_MANAGEMENT:
      return await handleCampaignTool(name, toolArgs, apiClient, withRetry);
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