whatsapp_get_contact
Retrieve contact details from WhatsApp using a phone number identifier. This tool fetches information about specific WhatsApp contacts through the WSAPI service.
Instructions
Get information about a specific WhatsApp contact.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| contactId | Yes | Contact ID (phone number with @s.whatsapp.net) |
Implementation Reference
- src/tools/contacts.ts:39-67 (handler)Defines the ToolHandler for 'whatsapp_get_contact' including input schema, description, and the async handler function that validates input using getContactSchema and fetches contact details via wsapiClient.get.export const getContact: ToolHandler = { name: 'whatsapp_get_contact', description: 'Get information about a specific WhatsApp contact.', inputSchema: { type: 'object', properties: { contactId: { type: 'string', description: 'Contact ID (phone number with @s.whatsapp.net)', }, }, required: ['contactId'], }, handler: async (args: any) => { const input = validateInput(getContactSchema, args); logger.info('Getting contact info', { contactId: input.contactId }); const result = await wsapiClient.get(`/contacts/${input.contactId}`); logger.info('Retrieved contact successfully', { contactId: input.contactId }); return { success: true, contact: result, message: 'Contact information retrieved successfully', }; }, };
- src/validation/schemas.ts:173-175 (schema)Zod validation schema for whatsapp_get_contact input, requiring 'contactId' matching phone number pattern.export const getContactSchema = z.object({ contactId: phoneNumberSchema, });
- src/server.ts:56-79 (registration)Registers all tools from contactTools (which includes whatsapp_get_contact) into the MCP server's tools Map.// 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/server.ts:16-16 (registration)Imports the contactTools object containing the whatsapp_get_contact handler.import { contactTools } from './tools/contacts.js';