whatsapp_send_contact
Send contact information via vCard to WhatsApp contacts or groups using the WSAPI WhatsApp MCP Server. Share contact details directly within WhatsApp conversations.
Instructions
Send a contact (vCard) message to a WhatsApp contact or group.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | Yes | Recipient phone number (with @s.whatsapp.net) or group ID (with @g.us) | |
| displayName | No | Display name for the contact (alternative to vCard) | |
| vCard | No | Raw vCard string (alternative to displayName) | |
| mentions | No | List of phone numbers to mention | |
| replyTo | No | ID of the message being replied to | |
| isForwarded | No | Whether the message should be marked as forwarded |
Implementation Reference
- src/tools/messaging-advanced.ts:364-422 (handler)The ToolHandler object implementing the 'whatsapp_send_contact' tool. Defines the tool metadata, input schema, and the handler function that validates input with sendContactMessageSchema and sends the contact via wsapiClient.post('/messages/contact').export const sendContactMessage: ToolHandler = { name: 'whatsapp_send_contact', description: 'Send a contact (vCard) message to a WhatsApp contact or group.', inputSchema: { type: 'object', properties: { to: { type: 'string', description: 'Recipient phone number (with @s.whatsapp.net) or group ID (with @g.us)', }, displayName: { type: 'string', description: 'Display name for the contact (alternative to vCard)', optional: true, }, vCard: { type: 'string', description: 'Raw vCard string (alternative to displayName)', optional: true, }, mentions: { type: 'array', items: { type: 'string' }, description: 'List of phone numbers to mention', 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'], }, handler: async (args: any) => { const input = validateInput(sendContactMessageSchema, args) as SendContactMessageInput; logger.info('Sending contact message', { to: input.to, hasDisplayName: !!input.displayName, hasVCard: !!input.vCard, }); const result = await wsapiClient.post('/messages/contact', input); logger.info('Contact message sent successfully', { messageId: result.id }); return { success: true, messageId: result.id, message: 'Contact message sent successfully', }; }, };
- src/validation/schemas.ts:108-117 (schema)Zod validation schema for the input parameters of the whatsapp_send_contact tool, used in the handler for runtime validation.export const sendContactMessageSchema = z.object({ to: chatIdSchema, displayName: z.string().min(1).max(255).optional(), vCard: z.string().min(1).optional(), mentions: z.array(phoneNumberSchema).optional(), replyTo: messageIdSchema.optional(), isForwarded: z.boolean().optional(), }).refine(data => data.displayName || data.vCard, { message: "Either displayName or vCard must be provided", });
- src/server.ts:53-79 (registration)Server method that registers all tool handlers, including those from messagingTools (containing whatsapp_send_contact), into the MCP server's internal tools Map by iterating over tool categories.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/tools/messaging.ts:541-555 (registration)Aggregation of messaging tools where advancedMessagingTools (including sendContactMessage / whatsapp_send_contact) is spread into the messagingTools object, which is then imported and registered in the server.import { advancedMessagingTools } from './messaging-advanced.js'; // Export all messaging tools export const messagingTools = { sendTextMessage, sendImageMessage, sendVideoMessage, sendLinkMessage, sendReactionMessage, editMessage, deleteMessage, markMessageAsRead, starMessage, ...advancedMessagingTools, };