Skip to main content
Glama
EvandroSchechtel

WhatsApp Business MCP Server

send_media_message

Send images, videos, audio, or documents to WhatsApp contacts using the WhatsApp Business Cloud API. Specify recipient number, media type, and file URL or ID to deliver media messages.

Instructions

Send an image, video, audio, or document to a WhatsApp number.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
toYesRecipient phone number in international format
media_typeYesType of media to send
media_urlNoPublic URL of the media file
media_idNoMedia ID from a previous upload
captionNoCaption for the media (images and videos only)
filenameNoFilename for documents

Implementation Reference

  • The actual implementation of sendMediaMessage which sends a POST request to the WhatsApp Business Cloud API.
    async sendMediaMessage(
      to: string,
      mediaType: "image" | "video" | "audio" | "document",
      media: { link?: string; id?: string; caption?: string; filename?: string }
    ) {
      return this.request(`/${this.config.phoneNumberId}/messages`, "POST", {
        messaging_product: "whatsapp",
        to,
        type: mediaType,
        [mediaType]: media,
      });
    }
  • src/index.ts:162-186 (registration)
    Registration of the send_media_message MCP tool, including parameter validation using Zod and a wrapper for pre/post execution hooks.
      "send_media_message",
      "Send an image, video, audio, or document to a WhatsApp number.",
      {
        to: z.string().describe("Recipient phone number in international format"),
        media_type: z.enum(["image", "video", "audio", "document"]).describe("Type of media to send"),
        media_url: z.string().optional().describe("Public URL of the media file"),
        media_id: z.string().optional().describe("Media ID from a previous upload"),
        caption: z.string().optional().describe("Caption for the media (images and videos only)"),
        filename: z.string().optional().describe("Filename for documents"),
      },
      async ({ to, media_type, media_url, media_id, caption, filename }) => {
        const media: Record<string, string> = {};
        if (media_url) media.link = media_url;
        if (media_id) media.id = media_id;
        if (caption) media.caption = caption;
        if (filename) media.filename = filename;
    
        return executeWithHooks(
          "send_media_message",
          { to, media_type, media_url, media_id, caption, filename },
          config,
          () => wa.sendMediaMessage(to, media_type, media)
        );
      }
    );

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/EvandroSchechtel/mcp-whatsapp'

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