whatsapp_get_chat
Retrieve detailed information about a specific WhatsApp chat, including participants, messages, and metadata, using the chat ID to access conversation data.
Instructions
Get information about a specific chat.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chatId | Yes | Chat ID |
Implementation Reference
- src/tools/chats.ts:19-32 (handler)The core handler function for the 'whatsapp_get_chat' tool. It validates the input using getChatSchema and retrieves specific chat information via the wsapiClient.export const getChat: ToolHandler = { name: 'whatsapp_get_chat', description: 'Get information about a specific chat.', inputSchema: { type: 'object', properties: { chatId: { type: 'string', description: 'Chat ID' } }, required: ['chatId'], }, handler: async (args: any) => { const input = validateInput(getChatSchema, args); const result = await wsapiClient.get(`/chats/${input.chatId}`); return { success: true, chat: result }; }, };
- src/validation/schemas.ts:225-227 (schema)Zod schema for validating the input to whatsapp_get_chat, requiring a chatId which is either a phone number or group ID.export const getChatSchema = z.object({ chatId: chatIdSchema, });
- src/validation/schemas.ts:4-6 (helper)Helper schemas defining valid chatId formats used by getChatSchema.const phoneNumberSchema = z.string().regex(/^\d{10,15}(@s\.whatsapp\.net)?$/); const groupIdSchema = z.string().regex(/@g\.us$/); const chatIdSchema = z.union([phoneNumberSchema, groupIdSchema]);
- src/server.ts:57-79 (registration)Registration logic in the MCP server that includes chatTools (containing whatsapp_get_chat) and registers all tools into the server's tool map.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/tools/chats.ts:88-88 (helper)Export grouping all chat-related tools, including getChat, for registration in the server.export const chatTools = { getChats, getChat, setChatPresence, archiveChat, pinChat };