Skip to main content
Glama
wsapi-chat

WSAPI WhatsApp MCP Server

by wsapi-chat

whatsapp_get_contact

Retrieve contact details from WhatsApp using a phone number identifier. This tool fetches information about specific WhatsApp contacts through the WSAPI service.

Instructions

Get information about a specific WhatsApp contact.

Input Schema

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

Implementation Reference

  • Defines the ToolHandler for 'whatsapp_get_contact' including input schema, description, and the async handler function that validates input using getContactSchema and fetches contact details via wsapiClient.get.
    export const getContact: ToolHandler = {
      name: 'whatsapp_get_contact',
      description: 'Get information about a specific 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 info', { contactId: input.contactId });
    
        const result = await wsapiClient.get(`/contacts/${input.contactId}`);
    
        logger.info('Retrieved contact successfully', { contactId: input.contactId });
    
        return {
          success: true,
          contact: result,
          message: 'Contact information retrieved successfully',
        };
      },
    };
  • Zod validation schema for whatsapp_get_contact input, requiring 'contactId' matching phone number pattern.
    export const getContactSchema = z.object({
      contactId: phoneNumberSchema,
    });
  • src/server.ts:56-79 (registration)
    Registers all tools from contactTools (which includes whatsapp_get_contact) 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}`);
        });
      });
    
      logger.info(`Registered ${this.tools.size} tools`);
    }
  • src/server.ts:16-16 (registration)
    Imports the contactTools object containing the whatsapp_get_contact handler.
    import { contactTools } from './tools/contacts.js';

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