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/services/whatsapp.ts:2194-2203 (helper)The WhatsAppService.getProfilePicUrl method that actually fetches the profile picture URL from WhatsApp via the Baileys socket's profilePictureUrl API.
async getProfilePicUrl(jid: string): Promise<string | null> { const socket = this.getSocket(); try { const normalized = this.resolveLookupJid(jid); const url = await socket.profilePictureUrl(normalized, "image"); return url || null; } catch (_error) { return null; } } - 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)", ), }, - src/server.ts:110-114 (registration)Execution metadata registration for 'get_profile_pic' in TOOL_EXECUTION_METADATA, marking it as readOnly, idempotent, and openWorld.
get_profile_pic: { readOnlyHint: true, idempotentHint: true, openWorldHint: true, }, - src/server.ts:243-244 (registration)The registerContactTools function is called in registerTools, which registers all contact tools including get_profile_pic.
registerAuthTools(server, this.whatsapp); registerContactTools(server, this.whatsapp);