Skip to main content
Glama
jonathan-politzki

Smartlead Simplified MCP Server

smartlead_delete_campaign_webhook

Remove a specific webhook from an email marketing campaign to stop receiving automated notifications or data updates for that campaign.

Instructions

Delete a specific webhook from a campaign.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
campaign_idYesID of the campaign containing the webhook
idYesID of the webhook to delete

Implementation Reference

  • The core handler function that validates input, calls the SmartLead API to delete the specified webhook from a campaign, and returns the response or error.
    async function handleDeleteCampaignWebhook(
      args: unknown,
      apiClient: AxiosInstance,
      withRetry: <T>(operation: () => Promise<T>, context: string) => Promise<T>
    ) {
      if (!isDeleteCampaignWebhookParams(args)) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Invalid arguments for smartlead_delete_campaign_webhook'
        );
      }
    
      try {
        const smartLeadClient = createSmartLeadClient(apiClient);
        const { campaign_id, id } = args;
        
        // The API documentation suggests a DELETE with a body payload
        // Different from typical REST practices but following the API spec
        const response = await withRetry(
          async () => smartLeadClient.delete(`/campaigns/${campaign_id}/webhooks`, { 
            data: { id }
          }),
          'delete campaign webhook'
        );
    
        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 JSON schema for input parameters.
    export const DELETE_CAMPAIGN_WEBHOOK_TOOL: CategoryTool = {
      name: 'smartlead_delete_campaign_webhook',
      description: 'Delete a specific webhook from a campaign.',
      category: ToolCategory.WEBHOOKS,
      inputSchema: {
        type: 'object',
        properties: {
          campaign_id: {
            type: 'string',
            description: 'ID of the campaign containing the webhook',
          },
          id: {
            type: 'integer',
            description: 'ID of the webhook to delete',
          },
        },
        required: ['campaign_id', 'id'],
      },
    };
  • src/index.ts:222-224 (registration)
    Registers all webhook tools, including 'smartlead_delete_campaign_webhook', into the MCP tool registry if the webhooks category is enabled by license.
    if (enabledCategories.webhooks) {
      toolRegistry.registerMany(webhookTools);
    }
  • Runtime type guard function for validating input parameters against the DeleteCampaignWebhookParams interface.
    export function isDeleteCampaignWebhookParams(args: unknown): args is DeleteCampaignWebhookParams {
      return (
        typeof args === 'object' &&
        args !== null &&
        'campaign_id' in args &&
        typeof (args as DeleteCampaignWebhookParams).campaign_id === 'string' &&
        'id' in args &&
        typeof (args as DeleteCampaignWebhookParams).id === 'number'
      );
    }
  • Switch case in the webhook tool dispatcher that routes calls to the specific delete handler function.
    case 'smartlead_delete_campaign_webhook': {
      return handleDeleteCampaignWebhook(args, apiClient, withRetry);
    }
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