whatsapp_send_video
Send video messages to WhatsApp contacts or groups using URLs or base64 data. Specify video format and add captions, mentions, or view-once options for effective communication.
Instructions
Send a video message to a WhatsApp contact or group. Can send from URL or base64.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| caption | No | Caption for the video (max 1024 characters) | |
| isForwarded | No | Whether the message should be marked as forwarded | |
| mentions | No | List of phone numbers to mention in the caption | |
| mimeType | Yes | MIME type of the video | |
| replyTo | No | ID of the message being replied to | |
| to | Yes | Recipient phone number (with @s.whatsapp.net) or group ID (with @g.us) | |
| videoBase64 | No | Base64 encoded video data (alternative to videoURL) | |
| videoURL | No | URL of the video to send (alternative to videoBase64) | |
| viewOnce | No | Whether the video should be sent as view-once |
Input Schema (JSON Schema)
{
"properties": {
"caption": {
"description": "Caption for the video (max 1024 characters)",
"optional": true,
"type": "string"
},
"isForwarded": {
"description": "Whether the message should be marked as forwarded",
"optional": true,
"type": "boolean"
},
"mentions": {
"description": "List of phone numbers to mention in the caption",
"items": {
"type": "string"
},
"optional": true,
"type": "array"
},
"mimeType": {
"description": "MIME type of the video",
"enum": [
"video/mp4",
"video/3gp",
"video/mov",
"video/avi"
],
"type": "string"
},
"replyTo": {
"description": "ID of the message being replied to",
"optional": true,
"type": "string"
},
"to": {
"description": "Recipient phone number (with @s.whatsapp.net) or group ID (with @g.us)",
"type": "string"
},
"videoBase64": {
"description": "Base64 encoded video data (alternative to videoURL)",
"optional": true,
"type": "string"
},
"videoURL": {
"description": "URL of the video to send (alternative to videoBase64)",
"optional": true,
"type": "string"
},
"viewOnce": {
"description": "Whether the video should be sent as view-once",
"optional": true,
"type": "boolean"
}
},
"required": [
"to",
"mimeType"
],
"type": "object"
}
Implementation Reference
- src/tools/messaging.ts:153-227 (handler)Complete ToolHandler implementation for 'whatsapp_send_video', including description, input schema for MCP, validation using Zod schema, logging, WSAPI call to POST /messages/video, and success response.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', }; }, };
- src/validation/schemas.ts:34-46 (schema)Zod validation schema for SendVideoMessageInput used in the handler's validateInput call. Includes refinements for required video source.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)Server setup method that imports and registers all tools from messagingTools (which includes whatsapp_send_video) into the tools Map used by MCP server for handling tool calls.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`); }
- src/validation/schemas.ts:317-317 (schema)TypeScript type definition for SendVideoMessageInput inferred from the Zod schema.export type SendVideoMessageInput = z.infer<typeof sendVideoMessageSchema>;
- src/validation/schemas.ts:305-312 (helper)validateInput helper function used in the handler to validate arguments against sendVideoMessageSchema.export function validateInput<T>(schema: z.ZodSchema<T>, data: unknown): T { const result = schema.safeParse(data); if (!result.success) { const errors = result.error.errors.map(err => `${err.path.join('.')}: ${err.message}`); throw new Error(`Validation failed: ${errors.join(', ')}`); } return result.data; }