Skip to main content
Glama
jonathan-politzki

Smartlead Simplified MCP Server

smartlead_add_lead_to_campaign

Add a new lead with email and contact details to a specific email marketing campaign for automated outreach.

Instructions

Add a new lead to a campaign.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
campaign_idYesID of the campaign to add the lead to
companyNoCompany of the lead
custom_fieldsNoCustom fields for the lead
emailYesEmail address of the lead
first_nameNoFirst name of the lead
last_nameNoLast name of the lead
phoneNoPhone number of the lead
titleNoJob title of the lead

Implementation Reference

  • Core handler function that validates the input arguments and executes the POST API call to add a lead to a specific campaign in Smartlead.
    async function handleAddLeadToCampaign(
      args: unknown,
      apiClient: AxiosInstance,
      withRetry: <T>(operation: () => Promise<T>, context: string) => Promise<T>
    ) {
      if (!isAddLeadToCampaignParams(args)) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Invalid arguments for smartlead_add_lead_to_campaign'
        );
      }
    
      try {
        const response = await withRetry(
          async () => apiClient.post(`/campaigns/${args.campaign_id}/leads`, args),
          'add lead to 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 with input schema specifying parameters for adding a lead to a campaign, including required fields campaign_id and email.
    export const ADD_LEAD_TO_CAMPAIGN_TOOL: CategoryTool = {
      name: 'smartlead_add_lead_to_campaign',
      description: 'Add a new lead to a campaign.',
      category: ToolCategory.LEAD_MANAGEMENT,
      inputSchema: {
        type: 'object',
        properties: {
          campaign_id: {
            type: 'number',
            description: 'ID of the campaign to add the lead to',
          },
          email: {
            type: 'string',
            description: 'Email address of the lead',
          },
          first_name: {
            type: 'string',
            description: 'First name of the lead',
          },
          last_name: {
            type: 'string',
            description: 'Last name of the lead',
          },
          company: {
            type: 'string',
            description: 'Company of the lead',
          },
          title: {
            type: 'string',
            description: 'Job title of the lead',
          },
          phone: {
            type: 'string',
            description: 'Phone number of the lead',
          },
          custom_fields: {
            type: 'object',
            description: 'Custom fields for the lead',
          },
        },
        required: ['campaign_id', 'email'],
      },
    };
  • Type guard function for validating input parameters match AddLeadToCampaignParams interface, used in the handler for runtime checks.
    export function isAddLeadToCampaignParams(args: unknown): args is AddLeadToCampaignParams {
      if (
        typeof args !== 'object' ||
        args === null ||
        !('campaign_id' in args) ||
        !('email' in args) ||
        typeof (args as { campaign_id: unknown }).campaign_id !== 'number' ||
        typeof (args as { email: unknown }).email !== 'string'
      ) {
        return false;
      }
      
      const params = args as AddLeadToCampaignParams;
      
      // Optional fields validation
      if (params.first_name !== undefined && typeof params.first_name !== 'string') {
        return false;
      }
      if (params.last_name !== undefined && typeof params.last_name !== 'string') {
        return false;
      }
      if (params.company !== undefined && typeof params.company !== 'string') {
        return false;
      }
      if (params.title !== undefined && typeof params.title !== 'string') {
        return false;
      }
      if (params.phone !== undefined && typeof params.phone !== 'string') {
        return false;
      }
      if (
        params.custom_fields !== undefined && 
        (typeof params.custom_fields !== 'object' || params.custom_fields === null)
      ) {
        return false;
      }
      
      return true;
    }
  • src/index.ts:207-209 (registration)
    Registers all lead management tools, including smartlead_add_lead_to_campaign, to the tool registry when the leadManagement category is enabled.
    if (enabledCategories.leadManagement) {
      toolRegistry.registerMany(leadTools);
    }
  • src/index.ts:350-352 (registration)
    Dispatches calls to lead management tools, including smartlead_add_lead_to_campaign, to the handleLeadTool function based on tool category.
    case ToolCategory.LEAD_MANAGEMENT:
      return await handleLeadTool(name, toolArgs, apiClient, withRetry);
    case ToolCategory.CAMPAIGN_STATISTICS:

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