Skip to main content
Glama

sendEmailToCampaign

Send a triggered email to a campaign recipient by providing campaign ID and email address, with support for personalization parameters and optional overrides for subject, reply-to, sender name, and list addition.

Instructions

Trigger and email for email campaign trigger with personalization parameter added to the email template.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
campaignIdYesCamapign id of the campaign to be triggered
emailYesEmail address of the contact to whom you want to send the email. This is required.
subjectNoOptional: Overrides the default subject line provided when creating the campaign.
replyToNoOptional: Overrides the default reply-to email address for the campaign.
fromNameNoOptional: Overrides the sender name for the campaign.
campaign_dataNoOptional: Transient personalization parameters, not stored in the contact profile.
dataNoOptional: Personalization parameters saved to the contact's profile.
addToListNoOptional: List ID to which the contact should be added as part of triggering the campaign.

Implementation Reference

  • src/server.ts:373-438 (registration)
    Registration of the 'sendEmailToCampaign' tool on the MCP server using server.tool(), including the full schema definition for all parameters (campaignId, email, subject, replyTo, fromName, campaign_data, data, addToList).
    server.tool(
      "sendEmailToCampaign",
      "Trigger and email for email campaign trigger with personalization parameter added to the email template. ",
      {
        campaignId: z.string().describe('Camapign id of the campaign to be triggered'),
        email: z
          .string()
          .email({ message: "Invalid email address" })
          .describe("Email address of the contact to whom you want to send the email. This is required."),
      
        subject: z
          .string()
          .optional()
          .describe("Optional: Overrides the default subject line provided when creating the campaign."),
      
        replyTo: z
          .string()
          .optional()
          .describe("Optional: Overrides the default reply-to email address for the campaign."),
      
        fromName: z
          .string()
          .optional()
          .describe("Optional: Overrides the sender name for the campaign."),
      
        campaign_data: z
          .record(z.string())
          .optional()
          .describe("Optional: Transient personalization parameters, not stored in the contact profile."),
      
        data: z
          .record(z.string())
          .optional()
          .describe("Optional: Personalization parameters saved to the contact's profile."),
      
        addToList: z
          .string()
          .optional()
          .describe("Optional: List ID to which the contact should be added as part of triggering the campaign."),
      },
      async (params) => {
        try {
          const { campaignId, ...newparams } = params;
          const respone = await triggerMailmodoCampaign(mmApiKey, params.campaignId, newparams);
          
          // Here you would typically integrate with your event sending system
          // For example: eventBus.emit(eventName, eventData)
          
          // For demonstration, we'll just return a success message
          return {
            content: [{
              type: "text",
              text: respone.message ?`Successfully sent email to '${params.email} for the campaignId ${params.campaignId} with message ${respone.message}.`: `Something went wrong. Please check if the email is correct`,
            }]
          };
        } catch (error) {
          return {
            content: [{
              type: "text",
              text: error instanceof Error ? error.message : "Failed to delete",
            }],
            isError: true
          };
        }
      }
    );
  • Handler function for 'sendEmailToCampaign' that extracts campaignId from params and delegates to triggerMailmodoCampaign API call, with error handling and response formatting.
    async (params) => {
      try {
        const { campaignId, ...newparams } = params;
        const respone = await triggerMailmodoCampaign(mmApiKey, params.campaignId, newparams);
        
        // Here you would typically integrate with your event sending system
        // For example: eventBus.emit(eventName, eventData)
        
        // For demonstration, we'll just return a success message
        return {
          content: [{
            type: "text",
            text: respone.message ?`Successfully sent email to '${params.email} for the campaignId ${params.campaignId} with message ${respone.message}.`: `Something went wrong. Please check if the email is correct`,
          }]
        };
      } catch (error) {
        return {
          content: [{
            type: "text",
            text: error instanceof Error ? error.message : "Failed to delete",
          }],
          isError: true
        };
      }
    }
  • Helper function 'triggerMailmodoCampaign' that makes an HTTP POST to the Mailmodo API to trigger a campaign for a single email recipient.
    export async function triggerMailmodoCampaign(
        mmApiKey: string,
      campaignId: string,
      payload: TriggerCampaignRequest
    ): Promise<TriggerCampaignResponse> {
      try {
        const response = await axios.post<TriggerCampaignResponse>(
          `https://api.mailmodo.com/api/v1/triggerCampaign/${campaignId}`,
          payload,
          {
            headers: {
              'Accept': 'application/json',
              'Content-Type': 'application/json',
              'mmApiKey': mmApiKey || ''
            }
          }
        );
    
        return response.data;
      } catch (error) {
        if (axios.isAxiosError(error)) {
          throw new Error(`Failed to trigger Mailmodo campaign: ${error.response?.data?.message || error.message}`);
        }
        throw error;
      }
    }
  • TypeScript interfaces: TriggerCampaignRequest (input schema with email, subject, replyTo, fromName, campaign_data, data, addToList) and TriggerCampaignResponse (output schema with success, message, ref).
    export interface TriggerCampaignRequest {
      email: string;
      subject?: string;
      replyTo?: string;
      fromName?: string;
      campaign_data?: Record<string, string>;
      data?: Record<string, string>;
      addToList?: string;
    }
    
    export interface TriggerCampaignResponse {
      success: boolean;
      message: string;
      ref: string;
    }
Behavior3/5

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

The description mentions personalization parameters but does not specify behavioral traits such as whether the email is sent immediately, if data is saved permanently, or if there are rate limits. Without annotations, more detail would be helpful, but the description provides some context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence, but it is redundant and awkwardly phrased ('Trigger and email for email campaign trigger'). It could be more concise and clear without losing information.

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?

With 8 parameters, nested objects, and no output schema, the description is too short. It lacks information on return values, side effects, or how personalization and list addition work, leaving gaps for an AI agent.

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?

All parameters have schema descriptions, so the description adds minimal extra meaning. The phrase 'personalization parameter added' is already covered by the schema's campaign_data and data fields, yielding a baseline score of 3.

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 states that the tool triggers an email campaign with personalization for a single contact, which distinguishes it from sibling tools like broadcastCampaignToList. However, the phrasing is awkward and could be clearer, earning a 4.

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 does not mention that this is for individual triggering, nor does it explain when not to use it or how it relates to broadcasting or list management tools.

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/mailmodo/mailmodo-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server