Skip to main content
Glama
by wsapi-chat

whatsapp_get_contact

Retrieve detailed information about a specific WhatsApp contact using their contact ID. This tool enables AI assistants to access contact data for messaging and management purposes within the WhatsApp platform.

Instructions

Get information about a specific 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 complete ToolHandler object for 'whatsapp_get_contact', defining the tool metadata, input schema, and the async handler function that validates the input contactId and retrieves the contact details from the WSAPI using 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 the whatsapp_get_contact tool input, ensuring contactId is a valid phone number format, used in validateInput within the handler.
    export const getContactSchema = z.object({ contactId: phoneNumberSchema, });
  • src/server.ts:53-79 (registration)
    The setupToolHandlers method registers all tools by importing tool groups like contactTools (which includes whatsapp_get_contact) into toolCategories and adding them to the tools Map for MCP server handling.
    private setupToolHandlers(): void { logger.info('Setting up tool handlers'); // 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:15-21 (registration)
    Imports the contactTools object from src/tools/contacts.ts, which bundles the whatsapp_get_contact handler for registration in the MCP server.
    import { messagingTools } from './tools/messaging.js'; import { contactTools } from './tools/contacts.js'; import { groupTools } from './tools/groups.js'; import { chatTools } from './tools/chats.js'; import { sessionTools } from './tools/session.js'; import { instanceTools } from './tools/instance.js'; import { accountTools } from './tools/account.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