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);

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