upload_media
Upload media files to WhatsApp Business for later use in messages. Store images, documents, or other files with a public URL to reference when sending communications.
Instructions
Upload a media file for later sending. Returns a media_id that can be used with send_media_message.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_url | Yes | Public URL of the file to upload | |
| type | Yes | MIME type (e.g., image/jpeg, application/pdf) |
Implementation Reference
- src/whatsapp-client.ts:274-282 (handler)The core logic that performs the API request to upload media to WhatsApp.
async uploadMedia(file: string, type: string) { // Note: actual file upload requires multipart/form-data // This is a simplified version. In production, use FormData. return this.request(`/${this.config.phoneNumberId}/media`, "POST", { messaging_product: "whatsapp", type, link: file, }); } - src/index.ts:391-402 (registration)Registration of the "upload_media" MCP tool.
server.tool( "upload_media", "Upload a media file for later sending. Returns a media_id that can be used with send_media_message.", { file_url: z.string().describe("Public URL of the file to upload"), type: z.string().describe("MIME type (e.g., image/jpeg, application/pdf)"), }, async ({ file_url, type }) => executeWithHooks("upload_media", { file_url, type }, config, () => wa.uploadMedia(file_url, type) ) );