Skip to main content
Glama
by wsapi-chat

whatsapp_subscribe_contact_presence

Subscribe to real-time presence updates for a WhatsApp contact to monitor their online status and availability changes.

Instructions

Subscribe to presence updates for a specific 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

  • Core handler function for the whatsapp_subscribe_contact_presence tool. Validates input with getContactSchema, logs the action, calls wsapiClient.post to subscribe to the contact's presence updates, and returns success response.
    export const subscribeToContactPresence: ToolHandler = { name: 'whatsapp_subscribe_contact_presence', description: 'Subscribe to presence updates for a specific 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('Subscribing to contact presence', { contactId: input.contactId }); await wsapiClient.post(`/contacts/${input.contactId}/presence`, {}); logger.info('Subscribed to contact presence successfully', { contactId: input.contactId }); return { success: true, message: 'Successfully subscribed to contact presence updates', }; }, };
  • Zod validation schema (getContactSchema) used in the tool handler for input validation of contactId (references phoneNumberSchema).
    export const getContactSchema = z.object({ contactId: phoneNumberSchema, });
  • src/server.ts:53-79 (registration)
    Registers all tool objects (including contactTools containing whatsapp_subscribe_contact_presence) into the MCP server's tools Map for handling list_tools and call_tool requests.
    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:16-16 (registration)
    Imports the contactTools object which exports the whatsapp_subscribe_contact_presence handler.
    import { contactTools } from './tools/contacts.js';
  • Exports the contactTools object grouping all contact-related tools, including whatsapp_subscribe_contact_presence, for registration in the server.
    export const contactTools = { getContacts, getContact, createContact, updateContact, getContactPicture, getContactBusinessProfile, subscribeToContactPresence,

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