whatsapp_get_contact_picture
Retrieve profile pictures from WhatsApp contacts using their contact ID. This tool enables viewing contact images through the WSAPI WhatsApp MCP Server.
Instructions
Get the profile picture of a 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:155-183 (handler)The complete ToolHandler for 'whatsapp_get_contact_picture'. Defines the name, description, inputSchema, and the handler function that validates input using getContactSchema, logs the action, fetches the profile picture via wsapiClient.get(`/contacts/${contactId}/picture`), and returns the result.export const getContactPicture: ToolHandler = { name: 'whatsapp_get_contact_picture', description: 'Get the profile picture of a 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 picture', { contactId: input.contactId }); const result = await wsapiClient.get(`/contacts/${input.contactId}/picture`); logger.info('Retrieved contact picture successfully', { contactId: input.contactId }); return { success: true, picture: result, message: 'Contact picture retrieved successfully', }; }, };
- src/validation/schemas.ts:173-175 (schema)Zod validation schema 'getContactSchema' used by the tool handler for input validation. Ensures contactId matches phone number pattern.export const getContactSchema = z.object({ contactId: phoneNumberSchema, });
- src/tools/contacts.ts:247-255 (registration)Export of the contactTools object that bundles getContactPicture (whatsapp_get_contact_picture) for registration in the MCP server.export const contactTools = { getContacts, getContact, createContact, updateContact, getContactPicture, getContactBusinessProfile, subscribeToContactPresence, };
- src/server.ts:56-76 (registration)Server registration logic that imports and registers all tools from contactTools (including whatsapp_get_contact_picture) 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}`); }); });