Skip to main content
Glama
jonathan-politzki

Smartlead Simplified MCP Server

smartlead_save_campaign_sequence

Save email sequences for campaigns by defining email variants, timing delays, and distribution methods to optimize outreach performance.

Instructions

Save a sequence of emails for a campaign.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
campaign_idYesID of the campaign
sequenceYesSequence of emails to send

Implementation Reference

  • The handler function that executes the tool: validates input using isSaveCampaignSequenceParams, sends POST request to `/campaigns/${campaign_id}/sequences` with the sequence data, and returns the API response or error.
    async function handleSaveCampaignSequence(
      args: unknown, 
      apiClient: AxiosInstance,
      withRetry: <T>(operation: () => Promise<T>, context: string) => Promise<T>
    ) {
      if (!isSaveCampaignSequenceParams(args)) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Invalid arguments for smartlead_save_campaign_sequence'
        );
      }
    
      const { campaign_id, sequence } = args;
    
      try {
        const response = await withRetry(
          async () => apiClient.post(`/campaigns/${campaign_id}/sequences`, { sequence }),
          'save campaign sequence'
        );
    
        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,
        };
      }
    }
  • Defines the tool metadata including name, description, category, and detailed inputSchema for validation in MCP protocol.
    export const SAVE_CAMPAIGN_SEQUENCE_TOOL: CategoryTool = {
      name: 'smartlead_save_campaign_sequence',
      description: 'Save a sequence of emails for a campaign.',
      category: ToolCategory.CAMPAIGN_MANAGEMENT,
      inputSchema: {
        type: 'object',
        properties: {
          campaign_id: {
            type: 'number',
            description: 'ID of the campaign',
          },
          sequence: {
            type: 'array',
            items: {
              type: 'object',
              properties: {
                seq_number: {
                  type: 'number',
                  description: 'The sequence number (order) of this email',
                },
                seq_delay_details: {
                  type: 'object',
                  properties: {
                    delay_in_days: {
                      type: 'number',
                      description: 'Days to wait before sending this email',
                    }
                  },
                  description: 'Delay details for this sequence'
                },
                variant_distribution_type: {
                  type: 'string',
                  enum: ['MANUAL_EQUAL', 'MANUAL_PERCENTAGE', 'AI_EQUAL'],
                  description: 'How to distribute variants'
                },
                lead_distribution_percentage: {
                  type: 'number',
                  description: 'What sample % size of the lead pool to use to find the winner (for AI_EQUAL)'
                },
                winning_metric_property: {
                  type: 'string',
                  enum: ['OPEN_RATE', 'CLICK_RATE', 'REPLY_RATE', 'POSITIVE_REPLY_RATE'],
                  description: 'Metric to use for determining the winning variant (for AI_EQUAL)'
                },
                seq_variants: {
                  type: 'array',
                  items: {
                    type: 'object',
                    properties: {
                      subject: {
                        type: 'string',
                        description: 'Email subject line',
                      },
                      email_body: {
                        type: 'string',
                        description: 'Email body content in HTML',
                      },
                      variant_label: {
                        type: 'string',
                        description: 'Label for this variant (A, B, C, etc.)',
                      },
                      variant_distribution_percentage: {
                        type: 'number',
                        description: 'Percentage of leads to receive this variant (for MANUAL_PERCENTAGE)'
                      }
                    },
                    required: ['subject', 'email_body', 'variant_label'],
                  },
                  description: 'Variants of the email in this sequence'
                }
              },
              required: ['seq_number', 'seq_delay_details', 'variant_distribution_type', 'seq_variants'],
            },
            description: 'Sequence of emails to send',
          },
        },
        required: ['campaign_id', 'sequence'],
      },
    };
  • src/index.ts:197-199 (registration)
    Registers the array of campaign tools (including smartlead_save_campaign_sequence) to the tool registry if campaignManagement category is enabled by license.
    if (enabledCategories.campaignManagement) {
      toolRegistry.registerMany(campaignTools);
    }
  • Type guard function used by the handler to validate input arguments against SaveCampaignSequenceParams interface.
    export function isSaveCampaignSequenceParams(args: unknown): args is SaveCampaignSequenceParams {
      if (
        typeof args !== 'object' ||
        args === null ||
        !('campaign_id' in args) ||
        typeof (args as { campaign_id: unknown }).campaign_id !== 'number' ||
        !('sequence' in args) ||
        !Array.isArray((args as { sequence: unknown }).sequence)
      ) {
        return false;
      }
    
      const sequence = (args as { sequence: unknown[] }).sequence;
      return sequence.every(isValidSequenceItem);
    }
  • Helper function used by isSaveCampaignSequenceParams to deeply validate each item in the sequence array.
    function isValidSequenceItem(item: unknown): boolean {
      return (
        typeof item === 'object' &&
        item !== null &&
        'seq_number' in item &&
        typeof (item as { seq_number: unknown }).seq_number === 'number' &&
        'seq_delay_details' in item &&
        typeof (item as { seq_delay_details: unknown }).seq_delay_details === 'object' &&
        (item as { seq_delay_details: unknown }).seq_delay_details !== null &&
        'delay_in_days' in (item as { seq_delay_details: { delay_in_days: unknown } }).seq_delay_details &&
        typeof (item as { seq_delay_details: { delay_in_days: unknown } }).seq_delay_details.delay_in_days === 'number' &&
        'variant_distribution_type' in item &&
        typeof (item as { variant_distribution_type: unknown }).variant_distribution_type === 'string' &&
        'seq_variants' in item &&
        Array.isArray((item as { seq_variants: unknown[] }).seq_variants) &&
        (item as { seq_variants: unknown[] }).seq_variants.every(
          (variant) =>
            typeof variant === 'object' &&
            variant !== null &&
            'subject' in variant &&
            typeof (variant as { subject: unknown }).subject === 'string' &&
            'email_body' in variant &&
            typeof (variant as { email_body: unknown }).email_body === 'string' &&
            'variant_label' in variant &&
            typeof (variant as { variant_label: unknown }).variant_label === 'string'
        )
      );
    } 
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 action ('Save') without behavioral details. It doesn't disclose if this is a create/update operation, permission requirements, side effects (e.g., overwriting existing sequences), rate limits, or error handling, leaving critical behavioral traits unspecified.

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 zero wasted words. It's front-loaded with the core action and resource, making it easy to parse quickly without unnecessary elaboration.

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 tool that saves complex email sequences (involving variants, delays, distribution logic) with no annotations and no output schema, the description is inadequate. It lacks context on what 'save' entails (e.g., creation vs. update), expected outcomes, or error scenarios, leaving significant gaps for agent understanding.

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 parameters are fully documented in the schema. The description adds no additional meaning beyond implying the sequence is saved to a campaign, which is already clear from parameter names. 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 ('Save') and resource ('a sequence of emails for a campaign'), making the purpose evident. It distinguishes from siblings like smartlead_create_campaign (which creates campaigns) and smartlead_update_campaign_settings (which updates settings), but doesn't explicitly differentiate from smartlead_get_campaign_sequence (which retrieves sequences).

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. It doesn't mention prerequisites (e.g., needing an existing campaign), exclusions, or related tools like smartlead_update_campaign_settings for other modifications, leaving usage context unclear.

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