Skip to main content
Glama
dazanza
by dazanza

add_or_update_member

Add new subscribers or update existing ones in Mailchimp audiences using email as the unique identifier. Maintains current subscription status while managing contact information and tags.

Instructions

Add a new subscriber or update an existing one in a Mailchimp audience. Uses email as the unique key (upsert). Will not change subscription status of existing members.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
list_idYesAudience/list ID
emailYesEmail address of the contact
first_nameNoFirst name
last_nameNoLast name
tagsNoTags to apply (e.g. ['Lead', 'Strategy'])

Implementation Reference

  • The handler function for 'add_or_update_member', which processes the input parameters, hashes the email, calls Mailchimp API to set the member, and optionally applies tags.
    async ({ list_id, email, first_name, last_name, tags }) => {
      const subscriberHash = crypto.createHash("md5").update(email.toLowerCase()).digest("hex");
      const body = {
        email_address: email,
        status_if_new: "subscribed",
        merge_fields: {},
      };
      if (first_name) body.merge_fields.FNAME = first_name;
      if (last_name) body.merge_fields.LNAME = last_name;
      const result = await mailchimp.lists.setListMember(list_id, subscriberHash, body);
      if (tags && tags.length > 0) {
        await mailchimp.lists.updateListMemberTags(list_id, subscriberHash, {
          tags: tags.map((t) => ({ name: t, status: "active" })),
        });
      }
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(
              {
                success: true,
                email: result.email_address,
                status: result.status,
                is_new: result.status === "subscribed" && !result.last_changed,
                tags_applied: tags || [],
              },
              null,
  • server.js:339-348 (registration)
    The registration of the 'add_or_update_member' tool, including its schema definition.
    server.tool(
      "add_or_update_member",
      "Add a new subscriber or update an existing one in a Mailchimp audience. Uses email as the unique key (upsert). Will not change subscription status of existing members.",
      {
        list_id: z.string().describe("Audience/list ID"),
        email: z.string().describe("Email address of the contact"),
        first_name: z.string().optional().describe("First name"),
        last_name: z.string().optional().describe("Last name"),
        tags: z.array(z.string()).optional().describe("Tags to apply (e.g. ['Lead', 'Strategy'])"),
      },

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/dazanza/mailchimp-mcp'

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