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

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
NameRequiredDescriptionDefault
toYesRecipient phone number (with @s.whatsapp.net) or group ID (with @g.us)
displayNameNoDisplay name for the contact (alternative to vCard)
vCardNoRaw vCard string (alternative to displayName)
mentionsNoList of phone numbers to mention
replyToNoID of the message being replied to
isForwardedNoWhether the message should be marked as forwarded

Implementation Reference

  • 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', }; }, };
  • 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`); }
  • 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, };

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