Skip to main content
Glama
by wsapi-chat

whatsapp_get_contact_picture

Retrieve the profile picture of a WhatsApp contact using their contact ID to display contact images within applications.

Instructions

Get the profile picture of a WhatsApp contact.

Input Schema

NameRequiredDescriptionDefault
contactIdYesContact ID (phone number with @s.whatsapp.net)

Input Schema (JSON Schema)

{ "properties": { "contactId": { "description": "Contact ID (phone number with @s.whatsapp.net)", "type": "string" } }, "required": [ "contactId" ], "type": "object" }

Implementation Reference

  • The ToolHandler implementation for 'whatsapp_get_contact_picture'. Validates the input contactId, fetches the profile picture using wsapiClient.get(`/contacts/${contactId}/picture`), logs the action, and returns the picture data.
    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', }; }, };
  • The input schema definition for the tool, specifying the required 'contactId' parameter.
    inputSchema: { type: 'object', properties: { contactId: { type: 'string', description: 'Contact ID (phone number with @s.whatsapp.net)', }, }, required: ['contactId'], },
  • src/server.ts:58-76 (registration)
    Registration logic in setupToolHandlers() that includes 'contactTools' (containing whatsapp_get_contact_picture) in toolCategories and registers each tool by name into the server's tools Map.
    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}`); }); });
  • Zod schema used internally by the handler for input validation (getContactSchema), defining contactId as a phone number pattern.
    export const getContactSchema = z.object({ contactId: phoneNumberSchema, });
  • Utility function validateInput used in the handler to validate arguments against getContactSchema before API call.
    export function validateInput<T>(schema: z.ZodSchema<T>, data: unknown): T { const result = schema.safeParse(data); if (!result.success) { const errors = result.error.errors.map(err => `${err.path.join('.')}: ${err.message}`); throw new Error(`Validation failed: ${errors.join(', ')}`); } return result.data; }

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