Skip to main content
Glama
jonathan-politzki

Smartlead Simplified MCP Server

smartlead_get_campaigns_by_lead

Retrieve all email marketing campaigns associated with a specific lead by providing the lead ID to track campaign participation and engagement.

Instructions

Fetch all campaigns that a lead belongs to.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
lead_idYesID of the lead to fetch campaigns for

Implementation Reference

  • The handler function that implements the core logic: validates input using isGetCampaignsByLeadParams and performs a GET request to `/leads/${lead_id}/campaigns` via the API client.
    async function handleGetCampaignsByLead(
      args: unknown, 
      apiClient: AxiosInstance,
      withRetry: <T>(operation: () => Promise<T>, context: string) => Promise<T>
    ) {
      if (!isGetCampaignsByLeadParams(args)) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Invalid arguments for smartlead_get_campaigns_by_lead'
        );
      }
    
      try {
        const response = await withRetry(
          async () => apiClient.get(`/leads/${args.lead_id}/campaigns`),
          'get campaigns by lead'
        );
    
        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's metadata, description, category, and input schema requiring a numeric lead_id.
    export const GET_CAMPAIGNS_BY_LEAD_TOOL: CategoryTool = {
      name: 'smartlead_get_campaigns_by_lead',
      description: 'Fetch all campaigns that a lead belongs to.',
      category: ToolCategory.CAMPAIGN_MANAGEMENT,
      inputSchema: {
        type: 'object',
        properties: {
          lead_id: {
            type: 'number',
            description: 'ID of the lead to fetch campaigns for',
          },
        },
        required: ['lead_id'],
      },
    };
  • Type guard function used in the handler to validate that the input arguments contain a valid numeric lead_id.
    export function isGetCampaignsByLeadParams(args: unknown): args is GetCampaignsByLeadParams {
      return (
        typeof args === 'object' &&
        args !== null &&
        'lead_id' in args &&
        typeof (args as { lead_id: unknown }).lead_id === 'number'
      );
    }
  • src/index.ts:197-199 (registration)
    Registers the campaign tools (including smartlead_get_campaigns_by_lead) with the central ToolRegistry if the campaignManagement category is enabled.
    if (enabledCategories.campaignManagement) {
      toolRegistry.registerMany(campaignTools);
    }
  • Switch case in handleCampaignTool that routes calls to this specific tool to its handler function.
    case 'smartlead_get_campaigns_by_lead': {
      return handleGetCampaignsByLead(args, apiClient, withRetry);
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 states the action ('Fetch') but does not cover critical aspects like whether this is a read-only operation, potential rate limits, authentication needs, error handling, or what the output looks like (e.g., list format, pagination). This leaves significant gaps for an agent to understand the tool's behavior.

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, clear sentence that efficiently conveys the core purpose without any unnecessary words. It is front-loaded and wastes no space, making it easy to parse and understand quickly.

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

Completeness3/5

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

For a simple read operation with one parameter and no output schema, the description is minimally adequate but incomplete. It lacks details on behavioral traits (e.g., safety, performance) and output format, which are important for an agent to use the tool effectively. The high schema coverage helps, but the absence of annotations and output information limits completeness.

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?

The input schema has 100% description coverage, with the 'lead_id' parameter clearly documented. The description adds no additional semantic details beyond what the schema provides, such as format examples or constraints. Given the high schema coverage, a baseline score of 3 is appropriate as the schema handles the parameter documentation adequately.

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 tool's purpose with a specific verb ('Fetch') and resource ('campaigns that a lead belongs to'), making it easy to understand what the tool does. However, it does not explicitly differentiate from sibling tools like 'smartlead_get_campaign' or 'smartlead_list_campaigns', which might have overlapping or similar functionality, preventing a perfect score.

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?

The description provides no guidance on when to use this tool versus alternatives. It lacks any mention of prerequisites, context, or exclusions, such as whether it's for a specific lead or general campaign retrieval, leaving the agent to infer usage from the name 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