Skip to main content
Glama
wsapi-chat

WSAPI WhatsApp MCP Server

by wsapi-chat

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
NameRequiredDescriptionDefault
contactIdYesContact ID (phone number with @s.whatsapp.net)

Implementation Reference

  • 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',
        };
      },
    };
  • 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,
    });
  • 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}`);
      });
    });

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