Skip to main content
Glama
wsapi-chat
by wsapi-chat

whatsapp_send_video

Send video messages to WhatsApp contacts or groups using URLs or base64 encoding. Specify recipients, MIME types, captions, and optional features like view-once mode or mentions.

Instructions

Send a video message to a WhatsApp contact or group. Can send from URL or base64.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
toYesRecipient phone number (with @s.whatsapp.net) or group ID (with @g.us)
videoBase64NoBase64 encoded video data (alternative to videoURL)
videoURLNoURL of the video to send (alternative to videoBase64)
mimeTypeYesMIME type of the video
captionNoCaption for the video (max 1024 characters)
viewOnceNoWhether the video should be sent as view-once
mentionsNoList of phone numbers to mention in the caption
replyToNoID of the message being replied to
isForwardedNoWhether the message should be marked as forwarded

Implementation Reference

  • Primary handler implementation for the 'whatsapp_send_video' tool. Defines the tool metadata, inline input schema for MCP, and the async handler function that validates input using Zod schema and sends the video via WSAPI client.
    export const sendVideoMessage: ToolHandler = { name: 'whatsapp_send_video', description: 'Send a video message to a WhatsApp contact or group. Can send from URL or base64.', inputSchema: { type: 'object', properties: { to: { type: 'string', description: 'Recipient phone number (with @s.whatsapp.net) or group ID (with @g.us)', }, videoBase64: { type: 'string', description: 'Base64 encoded video data (alternative to videoURL)', optional: true, }, videoURL: { type: 'string', description: 'URL of the video to send (alternative to videoBase64)', optional: true, }, mimeType: { type: 'string', enum: ['video/mp4', 'video/3gp', 'video/mov', 'video/avi'], description: 'MIME type of the video', }, caption: { type: 'string', description: 'Caption for the video (max 1024 characters)', optional: true, }, viewOnce: { type: 'boolean', description: 'Whether the video should be sent as view-once', optional: true, }, mentions: { type: 'array', items: { type: 'string' }, description: 'List of phone numbers to mention in the caption', optional: true, }, replyTo: { type: 'string', description: 'ID of the message being replied to', optional: true, }, isForwarded: { type: 'boolean', description: 'Whether the message should be marked as forwarded', optional: true, }, }, required: ['to', 'mimeType'], }, handler: async (args: any) => { const input = validateInput(sendVideoMessageSchema, args) as SendVideoMessageInput; logger.info('Sending video message', { to: input.to, mimeType: input.mimeType, hasCaption: !!input.caption, viewOnce: input.viewOnce, }); const result = await wsapiClient.post('/messages/video', input); logger.info('Video message sent successfully', { messageId: result.id }); return { success: true, messageId: result.id, message: 'Video message sent successfully', }; }, };
  • Zod schema (sendVideoMessageSchema) used for validating input parameters in the whatsapp_send_video handler. Includes refinements to ensure video data is provided via base64 or URL.
    export const sendVideoMessageSchema = z.object({ to: chatIdSchema, videoBase64: base64Schema.optional(), videoURL: urlSchema.optional(), mimeType: z.enum(['video/mp4', 'video/3gp', 'video/mov', 'video/avi']), caption: z.string().max(1024).optional(), viewOnce: z.boolean().optional(), mentions: z.array(phoneNumberSchema).optional(), replyTo: messageIdSchema.optional(), isForwarded: z.boolean().optional(), }).refine(data => data.videoBase64 || data.videoURL, { message: "Either videoBase64 or videoURL must be provided", });
  • src/server.ts:53-79 (registration)
    Registration logic in the MCP server where messagingTools (containing whatsapp_send_video) is included in toolCategories and registered in the tools Map for MCP tool listing and execution.
    private setupToolHandlers(): void { logger.info('Setting up tool handlers'); // Register all tool categories const toolCategories = [ messagingTools, contactTools, groupTools, chatTools, sessionTools, instanceTools, accountTools, ]; toolCategories.forEach(category => { Object.values(category).forEach(tool => { if (this.tools.has(tool.name)) { logger.warn(`Tool ${tool.name} already registered, skipping`); return; } this.tools.set(tool.name, tool); logger.debug(`Registered tool: ${tool.name}`); }); }); logger.info(`Registered ${this.tools.size} tools`); }
  • Export of messagingTools object that bundles the sendVideoMessage handler, which is later imported and registered in the MCP server.
    export const messagingTools = { sendTextMessage, sendImageMessage, sendVideoMessage, sendLinkMessage, sendReactionMessage, editMessage, deleteMessage, markMessageAsRead, starMessage, ...advancedMessagingTools, };
  • TypeScript type definition for SendVideoMessageInput inferred from the Zod schema, used in the handler for type assertion.
    export type SendVideoMessageInput = z.infer<typeof sendVideoMessageSchema>;

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/wsapi-chat/wsapi-mcp'

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