Skip to main content
Glama

resubscribeContact

Re-enable email communication with previously unsubscribed contacts in Mailmodo by resubscribing them using their email address.

Instructions

Resubscribe contact in mailmodo

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
emailYes

Implementation Reference

  • Full handler registration block for the 'resubscribeContact' MCP tool, including description, input schema, and the async execution function that calls the API helper and returns a textual response.
    server.tool(
      "resubscribeContact",
      "Resubscribe contact in mailmodo",
      {
          email: z.string()
      },
      async (params) => {
        try {
          const respone = await resubscribeContact(mmApiKey,params.email);
          
          // 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.success ?`Successfully resubscribed '${params.email} 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 unsubscribe",
            }],
            isError: true
          };
        }
      }
    );
  • Input validation schema using Zod for the tool parameters: requires an 'email' string.
    {
        email: z.string()
    },
  • The core helper function that performs the HTTP POST request to the Mailmodo API to resubscribe a contact by email, handles errors, and returns a standardized response.
    export async function resubscribeContact(
        mmApiKey: string,
        email: string
    ): Promise<AddContactToListResponse> {
        if (!email) {
            throw new Error('Email is a required field');
        }
    
        try {
            const response = await axios.post<AddContactToListResponse>(
                'https://api.mailmodo.com/api/v1/contacts/resubscribe',
                {
                    email,
                },
                {
                    headers: {
                        'Accept': 'application/json',
                        'Content-Type': 'application/json',
                        'mmApiKey': mmApiKey || ''
                    }
                }
            );
    
            return {success: true, message: response.data.message};
        } catch (error) {
            if (error instanceof AxiosError) {
                return {
                    success: false,
                    message: error.response?.data?.message || 'Failed to unsubscribe contact'
                };
            }
            throw new Error('An unexpected error occurred');
        }
    }
  • TypeScript type definition for the API response used by resubscribeContact (and similar functions): indicates success and optional message.
    export interface AddContactToListResponse {
        // Define your expected response structure here
        success: boolean;
        message?: string;
    }

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