Skip to main content
Glama

waha_send_media

Send media files like images, videos, or documents to WhatsApp chats using URL or base64 data. Specify chat ID, media type, and MIME type to deliver files with optional captions or replies.

Instructions

Send media files (images, videos, or documents) to a WhatsApp chat. Supports URL or base64 data.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chatIdYesChat ID (format: number@c.us)
mediaTypeYesType of media to send
fileUrlNoURL of the file to send (use either fileUrl or fileData, not both)
fileDataNoBase64 encoded file data (use either fileUrl or fileData, not both)
mimetypeYesMIME type of the file (e.g., 'image/jpeg', 'video/mp4', 'application/pdf')
filenameNoOptional filename for the media
captionNoOptional caption for the media
replyToNoOptional message ID to reply to

Implementation Reference

  • Executes the waha_send_media tool: validates input, constructs file object from URL or base64 data, calls WAHAClient.sendMedia, formats success response with media details.
    private async handleSendMedia(args: any) {
      const chatId = args.chatId;
      const mediaType = args.mediaType;
      const fileUrl = args.fileUrl;
      const fileData = args.fileData;
      const mimetype = args.mimetype;
      const filename = args.filename;
      const caption = args.caption;
      const replyTo = args.replyTo;
    
      if (!chatId) {
        throw new Error("chatId is required");
      }
    
      if (!mediaType) {
        throw new Error("mediaType is required");
      }
    
      if (!mimetype) {
        throw new Error("mimetype is required");
      }
    
      if (!fileUrl && !fileData) {
        throw new Error("Either fileUrl or fileData is required");
      }
    
      const file: any = {
        mimetype,
        filename,
      };
    
      if (fileUrl) {
        file.url = fileUrl;
      } else {
        file.data = fileData;
      }
    
      const response = await this.wahaClient.sendMedia({
        chatId,
        file,
        mediaType,
        caption,
        reply_to: replyTo,
      });
    
      const formattedResponse = formatSendMessageSuccess(
        chatId,
        response.id,
        response.timestamp
      );
    
      return {
        content: [
          {
            type: "text",
            text: `${formattedResponse}\nMedia type: ${mediaType}${caption ? `\nCaption: ${caption}` : ''}`,
          },
        ],
      };
    }
  • Tool schema definition including input schema with properties for chatId, mediaType, fileUrl/fileData, mimetype, and optional fields; defines required parameters.
      name: "waha_send_media",
      description: "Send media files (images, videos, or documents) to a WhatsApp chat. Supports URL or base64 data.",
      inputSchema: {
        type: "object",
        properties: {
          chatId: {
            type: "string",
            description: "Chat ID (format: number@c.us)",
          },
          mediaType: {
            type: "string",
            enum: ["image", "video", "document"],
            description: "Type of media to send",
          },
          fileUrl: {
            type: "string",
            description: "URL of the file to send (use either fileUrl or fileData, not both)",
          },
          fileData: {
            type: "string",
            description: "Base64 encoded file data (use either fileUrl or fileData, not both)",
          },
          mimetype: {
            type: "string",
            description: "MIME type of the file (e.g., 'image/jpeg', 'video/mp4', 'application/pdf')",
          },
          filename: {
            type: "string",
            description: "Optional filename for the media",
          },
          caption: {
            type: "string",
            description: "Optional caption for the media",
          },
          replyTo: {
            type: "string",
            description: "Optional message ID to reply to",
          },
        },
        required: ["chatId", "mediaType", "mimetype"],
      },
    },
  • src/index.ts:1079-1081 (registration)
    MCP tool dispatch registration: routes CallToolRequest for 'waha_send_media' to the handleSendMedia method.
    case "waha_send_media":
      return await this.handleSendMedia(args);
    case "waha_send_audio":
  • Underlying WAHAClient helper method that makes HTTP POST to appropriate WAHA API endpoint (/api/sendImage|Video|File) based on mediaType.
    async sendMedia(params: {
      chatId: string;
      file: {
        mimetype: string;
        url?: string;
        data?: string; // base64
        filename?: string;
      };
      mediaType: "image" | "video" | "document";
      caption?: string;
      reply_to?: string;
    }): Promise<SendMessageResponse> {
      const { chatId, file, mediaType, caption, reply_to } = params;
    
      if (!chatId) {
        throw new WAHAError("chatId is required");
      }
    
      if (!file || (!file.url && !file.data)) {
        throw new WAHAError("file with url or data is required");
      }
    
      const endpointMap = {
        image: "/api/sendImage",
        video: "/api/sendVideo",
        document: "/api/sendFile",
      };
    
      const body = {
        chatId,
        file,
        session: this.session,
        caption,
        reply_to,
      };
    
      return this.request<SendMessageResponse>(endpointMap[mediaType], {
        method: "POST",
        body: JSON.stringify(body),
      });
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but lacks critical behavioral details. It mentions support for URL or base64 data but doesn't disclose file size limits, rate limits, authentication requirements, error handling, or what happens on success (e.g., returns message ID). For a media-sending tool, this is a significant gap.

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

Conciseness5/5

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

The description is a single, efficient sentence that front-loads the core purpose without unnecessary words. Every part earns its place by specifying media types and input methods concisely.

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?

For a tool with 8 parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain return values, error cases, or behavioral constraints, leaving the agent with insufficient context to use the tool effectively beyond basic parameter filling.

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?

Schema description coverage is 100%, so the schema fully documents all 8 parameters. The description adds minimal value by mentioning URL or base64 support, which aligns with fileUrl and fileData parameters but doesn't provide additional context beyond what's in the schema descriptions.

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 clearly states the action ('send media files') and target ('to a WhatsApp chat'), specifying supported media types and input methods. It distinguishes from sibling tools like waha_send_message by focusing on media rather than text, though it doesn't explicitly contrast with waha_send_audio which might overlap in functionality.

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?

The description provides no guidance on when to use this tool versus alternatives like waha_send_message or waha_send_audio, nor does it mention prerequisites, error conditions, or typical use cases. It only states what the tool does, not when it's appropriate.

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

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