get_profile_pic
Retrieve the profile picture URL for a WhatsApp contact or group by providing their JID. Enables access to profile images for display or further processing.
Instructions
Get profile picture URL for a contact or group JID.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| jid | Yes | The JID of the contact or group (e.g., 123456789@s.whatsapp.net or 123456789-12345678@g.us) |
Implementation Reference
- src/tools/contacts.ts:145-187 (handler)The MCP tool handler for 'get_profile_pic'. It accepts a 'jid' parameter (zod string), calls whatsappService.getProfilePicUrl(jid), and returns the profile picture URL as JSON. Handles errors and missing profile pictures.
server.tool( "get_profile_pic", "Get profile picture URL for a contact or group JID.", { jid: z .string() .describe( "The JID of the contact or group (e.g., 123456789@s.whatsapp.net or 123456789-12345678@g.us)", ), }, async ({ jid }): Promise<CallToolResult> => { try { const url = await whatsappService.getProfilePicUrl(jid); if (!url) { return { content: [ { type: "text", text: `Profile picture not found for JID: ${jid}`, }, ], isError: true, }; } return { content: [ { type: "text", text: JSON.stringify({ jid, url }, null, 2) }, ], }; } catch (error: any) { log.error(`Error in get_profile_pic tool for JID ${jid}:`, error); return { content: [ { type: "text", text: `Error getting profile picture for ${jid}: ${error.message}`, }, ], isError: true, }; } }, ); - src/tools/contacts.ts:148-154 (schema)Input schema for the get_profile_pic tool: a required 'jid' string parameter describing the contact or group JID.
{ jid: z .string() .describe( "The JID of the contact or group (e.g., 123456789@s.whatsapp.net or 123456789-12345678@g.us)", ), },