get_messages
Retrieve messages from a WhatsApp chat by specifying the instance name and chat JID, with optional limit for number of messages to fetch.
Instructions
Get messages from a chat
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| instanceName | Yes | Instance name | |
| limit | No | Number of messages to retrieve | |
| remoteJid | Yes | Chat JID |
Implementation Reference
- src/index.ts:953-967 (handler)The handler function that implements the core logic of the 'get_messages' tool. It calls evolutionAPI.findMessages with instanceName, remoteJid, and optional limit, then returns the messages as a JSON-formatted text content block.private async handleGetMessages(args: any) { const messages = await evolutionAPI.findMessages( args.instanceName, args.remoteJid, args.limit || 20 ); return { content: [ { type: 'text', text: JSON.stringify(messages, null, 2) } ] }; }
- src/index.ts:413-425 (registration)Registers the 'get_messages' tool in the tools array, including its name, description, and input schema. This list is used by the MCP server for tool discovery.{ name: 'get_messages', description: 'Get messages from a chat', inputSchema: { type: 'object', properties: { instanceName: { type: 'string', description: 'Instance name' }, remoteJid: { type: 'string', description: 'Chat JID' }, limit: { type: 'number', description: 'Number of messages to retrieve' } }, required: ['instanceName', 'remoteJid'] } },
- src/index.ts:416-424 (schema)Defines the input schema for the 'get_messages' tool, specifying required instanceName and remoteJid, with optional limit.inputSchema: { type: 'object', properties: { instanceName: { type: 'string', description: 'Instance name' }, remoteJid: { type: 'string', description: 'Chat JID' }, limit: { type: 'number', description: 'Number of messages to retrieve' } }, required: ['instanceName', 'remoteJid'] }
- src/index.ts:542-543 (registration)Dispatches calls to the 'get_messages' tool to its handler function in the main CallToolRequestSchema handler switch statement.case 'get_messages': return await this.handleGetMessages(args);