Skip to main content
Glama
jonathan-politzki

Smartlead Simplified MCP Server

smartlead_get_campaign_statistics

Retrieve and analyze email campaign performance data by fetching statistics based on campaign ID, with options to filter by email sequence, status, and date ranges for targeted insights.

Instructions

Fetch campaign statistics using the campaign's ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
campaign_idYesID of the campaign to fetch statistics for
email_sequence_numberNoEmail sequence number to filter by (e.g., "1,2,3,4")
email_statusNoEmail status to filter by (e.g., "opened", "clicked", "replied", "unsubscribed", "bounced")
limitNoMaximum number of statistics to return
offsetNoOffset for pagination
sent_time_end_dateNoFilter by sent time less than this date (e.g., "2023-10-16 10:33:02.000Z")
sent_time_start_dateNoFilter by sent time greater than this date (e.g., "2023-10-16 10:33:02.000Z")

Implementation Reference

  • Core handler function that validates input parameters, makes authenticated API request to fetch campaign statistics, and formats the response as MCP content or error.
    async function handleCampaignStatistics(
      args: unknown,
      apiClient: AxiosInstance,
      withRetry: <T>(operation: () => Promise<T>, context: string) => Promise<T>
    ) {
      if (!isCampaignStatisticsParams(args)) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Invalid arguments for smartlead_get_campaign_statistics'
        );
      }
    
      const { campaign_id, ...queryParams } = args;
    
      try {
        const response = await withRetry(
          async () => apiClient.get(`/campaigns/${campaign_id}/statistics`, { params: queryParams }),
          'get campaign statistics'
        );
    
        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,
        };
      }
    }
  • JSON Schema definition for the tool input parameters, including descriptions and validation rules.
    export const CAMPAIGN_STATISTICS_TOOL: CategoryTool = {
      name: 'smartlead_get_campaign_statistics',
      description: 'Fetch campaign statistics using the campaign\'s ID.',
      category: ToolCategory.CAMPAIGN_STATISTICS,
      inputSchema: {
        type: 'object',
        properties: {
          campaign_id: {
            type: 'number',
            description: 'ID of the campaign to fetch statistics for',
          },
          offset: {
            type: 'number',
            description: 'Offset for pagination',
          },
          limit: {
            type: 'number',
            description: 'Maximum number of statistics to return',
          },
          email_sequence_number: {
            type: 'string',
            description: 'Email sequence number to filter by (e.g., "1,2,3,4")',
          },
          email_status: {
            type: 'string',
            description: 'Email status to filter by (e.g., "opened", "clicked", "replied", "unsubscribed", "bounced")',
          },
          sent_time_start_date: {
            type: 'string',
            description: 'Filter by sent time greater than this date (e.g., "2023-10-16 10:33:02.000Z")',
          },
          sent_time_end_date: {
            type: 'string',
            description: 'Filter by sent time less than this date (e.g., "2023-10-16 10:33:02.000Z")',
          },
        },
        required: ['campaign_id'],
      },
    };
  • src/index.ts:211-214 (registration)
    Registers the array of statistics tools (including smartlead_get_campaign_statistics schema) into the central ToolRegistry based on feature configuration.
    // Register campaign statistics tools if enabled
    if (enabledCategories.campaignStatistics) {
      toolRegistry.registerMany(statisticsTools);
    }
  • src/index.ts:352-353 (registration)
    Dispatches tool calls in CAMPAIGN_STATISTICS category to the statistics handler function based on tool name.
    case ToolCategory.CAMPAIGN_STATISTICS:
      return await handleStatisticsTool(name, toolArgs, apiClient, withRetry);
  • Type guard function for runtime validation of input parameters matching the tool schema, used in the handler.
    export function isCampaignStatisticsParams(args: unknown): args is CampaignStatisticsParams {
      if (typeof args !== 'object' || args === null) {
        return false;
      }
    
      const params = args as CampaignStatisticsParams;
      
      if (typeof params.campaign_id !== 'number') {
        return false;
      }
      
      // Optional offset must be a number if present
      if (params.offset !== undefined && typeof params.offset !== 'number') {
        return false;
      }
      
      // Optional limit must be a number if present
      if (params.limit !== undefined && typeof params.limit !== 'number') {
        return false;
      }
      
      // Optional email_sequence_number must be a string if present
      if (params.email_sequence_number !== undefined && typeof params.email_sequence_number !== 'string') {
        return false;
      }
      
      // Optional email_status must be a string if present
      if (params.email_status !== undefined && typeof params.email_status !== 'string') {
        return false;
      }
      
      // Optional sent_time_start_date must be a string if present
      if (params.sent_time_start_date !== undefined && typeof params.sent_time_start_date !== 'string') {
        return false;
      }
      
      // Optional sent_time_end_date must be a string if present
      if (params.sent_time_end_date !== undefined && typeof params.sent_time_end_date !== 'string') {
        return false;
      }
      
      return true;
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It only states the basic action ('fetch') without mentioning whether this is a read-only operation, if it requires specific permissions, what the return format looks like (e.g., JSON structure, pagination details), or any rate limits. For a tool with 7 parameters and no output schema, this is a significant gap in transparency.

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 waste. It's front-loaded with the core action and resource, making it easy to parse quickly. Every word earns its place without redundancy or fluff.

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?

Given the complexity (7 parameters, no annotations, no output schema, many sibling tools), the description is incomplete. It doesn't clarify the tool's scope relative to similar tools, explain the output format, or provide behavioral context needed for safe and effective use. This leaves significant gaps for an agent to operate correctly.

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 already documents all 7 parameters thoroughly (e.g., campaign_id, email_sequence_number, email_status with examples). The description adds no additional meaning beyond the schema, such as explaining how filters combine or default behaviors. Baseline 3 is appropriate when the schema does the heavy lifting.

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

Purpose3/5

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

The description 'Fetch campaign statistics using the campaign's ID' states the action (fetch) and resource (campaign statistics), but it's vague about what 'statistics' entails compared to similar tools like smartlead_get_campaign_analytics_by_date or smartlead_get_campaign_lead_statistics. It doesn't specify whether these are aggregate metrics, per-email stats, or something else, making it less distinct from siblings.

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. With many sibling tools related to campaign statistics (e.g., smartlead_get_campaign_analytics_by_date, smartlead_get_campaign_lead_statistics), the description lacks any context about its specific use case, prerequisites, or exclusions, leaving the agent to guess based on parameter names alone.

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