Skip to main content
Glama
jonathan-politzki

Smartlead Simplified MCP Server

smartlead_bulk_import_leads

Import multiple leads with contact details into a campaign simultaneously to streamline email marketing list management.

Instructions

Import multiple leads into a campaign at once.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
campaign_idYesID of the campaign to add the leads to
leadsYesArray of leads to import

Implementation Reference

  • Core handler function that validates input and performs bulk import of leads via POST to `/campaigns/{campaign_id}/leads/bulk` API endpoint.
    async function handleBulkImportLeads(
      args: unknown,
      apiClient: AxiosInstance,
      withRetry: <T>(operation: () => Promise<T>, context: string) => Promise<T>
    ) {
      if (!isBulkImportLeadsParams(args)) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Invalid arguments for smartlead_bulk_import_leads'
        );
      }
    
      try {
        const response = await withRetry(
          async () => apiClient.post(`/campaigns/${args.campaign_id}/leads/bulk`, {
            leads: args.leads
          }),
          'bulk import leads'
        );
    
        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 name, description, category, and input schema specifying campaign_id and array of lead objects (each requiring email).
    export const BULK_IMPORT_LEADS_TOOL: CategoryTool = {
      name: 'smartlead_bulk_import_leads',
      description: 'Import multiple leads into a campaign at once.',
      category: ToolCategory.LEAD_MANAGEMENT,
      inputSchema: {
        type: 'object',
        properties: {
          campaign_id: {
            type: 'number',
            description: 'ID of the campaign to add the leads to',
          },
          leads: {
            type: 'array',
            items: {
              type: 'object',
              properties: {
                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: ['email'],
            },
            description: 'Array of leads to import',
          },
        },
        required: ['campaign_id', 'leads'],
      },
    };
  • Runtime type guard for validating BulkImportLeadsParams, checking campaign_id, leads array, and each lead's required email plus optional fields.
    export function isBulkImportLeadsParams(args: unknown): args is BulkImportLeadsParams {
      if (
        typeof args !== 'object' ||
        args === null ||
        !('campaign_id' in args) ||
        !('leads' in args) ||
        typeof (args as { campaign_id: unknown }).campaign_id !== 'number' ||
        !Array.isArray((args as { leads: unknown }).leads)
      ) {
        return false;
      }
      
      const params = args as BulkImportLeadsParams;
      
      // Validate each lead in the leads array
      for (const lead of params.leads) {
        if (
          typeof lead !== 'object' ||
          lead === null ||
          !('email' in lead) ||
          typeof lead.email !== 'string'
        ) {
          return false;
        }
        
        // Optional fields validation
        if (lead.first_name !== undefined && typeof lead.first_name !== 'string') {
          return false;
        }
        if (lead.last_name !== undefined && typeof lead.last_name !== 'string') {
          return false;
        }
        if (lead.company !== undefined && typeof lead.company !== 'string') {
          return false;
        }
        if (lead.title !== undefined && typeof lead.title !== 'string') {
          return false;
        }
        if (lead.phone !== undefined && typeof lead.phone !== 'string') {
          return false;
        }
        if (
          lead.custom_fields !== undefined && 
          (typeof lead.custom_fields !== 'object' || lead.custom_fields === null)
        ) {
          return false;
        }
      }
      
      return true;
    }
  • src/index.ts:207-209 (registration)
    Registers the leadTools array (containing smartlead_bulk_import_leads) into the MCP toolRegistry if leadManagement category is enabled by license.
    if (enabledCategories.leadManagement) {
      toolRegistry.registerMany(leadTools);
    }
  • Switch case in handleLeadTool that dispatches smartlead_bulk_import_leads calls to the specific handleBulkImportLeads implementation.
    case 'smartlead_bulk_import_leads': {
      return handleBulkImportLeads(args, apiClient, withRetry);
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full burden but only states the basic action. It doesn't disclose behavioral traits such as permissions needed, rate limits, whether it overwrites existing leads, error handling, or response format. This is inadequate for a mutation tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with no wasted words. It's front-loaded with the core action and scope, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with no annotations and no output schema, the description is incomplete. It lacks details on behavioral aspects, error cases, or what happens on success/failure. Given the complexity of importing multiple leads, more context is needed for effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents the two parameters (campaign_id and leads). The description adds no additional meaning beyond implying bulk import, which is already clear from the schema's array structure. Baseline 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('import multiple leads') and target ('into a campaign'), specifying it's a bulk operation. It distinguishes from sibling tools like 'smartlead_add_lead_to_campaign' by emphasizing 'multiple leads at once', though it doesn't explicitly contrast with all similar tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like 'smartlead_add_lead_to_campaign' or 'smartlead_update_lead'. The description implies bulk usage but lacks explicit context, prerequisites, or exclusions for selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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