whatsapp_archive_chat
Archive or unarchive WhatsApp chats to organize conversations and manage chat visibility within the WSAPI WhatsApp MCP Server.
Instructions
Archive or unarchive a chat.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chatId | Yes | Chat ID | |
| archived | Yes | Whether to archive or unarchive |
Implementation Reference
- src/tools/chats.ts:52-68 (handler)The handler implementation for the 'whatsapp_archive_chat' tool. It validates the input using updateChatArchiveSchema and makes a PUT request to the WSAPI to archive or unarchive the specified chat.export const archiveChat: ToolHandler = { name: 'whatsapp_archive_chat', description: 'Archive or unarchive a chat.', inputSchema: { type: 'object', properties: { chatId: { type: 'string', description: 'Chat ID' }, archived: { type: 'boolean', description: 'Whether to archive or unarchive' }, }, required: ['chatId', 'archived'], }, handler: async (args: any) => { const input = validateInput(updateChatArchiveSchema, args); await wsapiClient.put(`/chats/${input.chatId}/archive`, { archived: input.archived }); return { success: true, message: `Chat ${input.archived ? 'archived' : 'unarchived'} successfully` }; }, };
- src/validation/schemas.ts:249-252 (schema)Zod schema used for input validation in the whatsapp_archive_chat handler. Defines chatId (referencing chatIdSchema) and archived as boolean.export const updateChatArchiveSchema = z.object({ chatId: chatIdSchema, archived: z.boolean(), });
- src/server.ts:53-79 (registration)Registers all tools including chatTools (which contains whatsapp_archive_chat) into the server's tools Map by iterating over tool categories.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/tools/chats.ts:88-88 (registration)Exports the chatTools object grouping several chat-related tools, including archiveChat (whatsapp_archive_chat), which is later imported and registered in server.ts.export const chatTools = { getChats, getChat, setChatPresence, archiveChat, pinChat };
- src/tools/chats.ts:55-68 (schema)Inline inputSchema definition for the whatsapp_archive_chat tool, used by the MCP server for tool call validation.inputSchema: { type: 'object', properties: { chatId: { type: 'string', description: 'Chat ID' }, archived: { type: 'boolean', description: 'Whether to archive or unarchive' }, }, required: ['chatId', 'archived'], }, handler: async (args: any) => { const input = validateInput(updateChatArchiveSchema, args); await wsapiClient.put(`/chats/${input.chatId}/archive`, { archived: input.archived }); return { success: true, message: `Chat ${input.archived ? 'archived' : 'unarchived'} successfully` }; }, };