read-chat
Retrieve recent chat messages from Minecraft players to monitor in-game conversations and interactions.
Instructions
Get recent chat messages from players
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| count | No | Number of recent messages to retrieve (default: 10, max: 100) |
Implementation Reference
- src/tools/chat-tools.ts:26-41 (handler)The asynchronous handler function for the 'read-chat' tool. It retrieves a specified number of recent chat messages from the messageStore (clamped to max), formats them with timestamps, usernames, and content, and returns a formatted response string using factory.createResponse.async ({ count = 10 }) => { const maxCount = Math.min(count, messageStore.getMaxMessages()); const messages = messageStore.getRecentMessages(maxCount); if (messages.length === 0) { return factory.createResponse("No chat messages found"); } let output = `Found ${messages.length} chat message(s):\n\n`; messages.forEach((msg, index) => { const timestamp = new Date(msg.timestamp).toISOString(); output += `${index + 1}. ${timestamp} - ${msg.username}: ${msg.content}\n`; }); return factory.createResponse(output); }
- src/tools/chat-tools.ts:23-25 (schema)Zod schema definition for the optional 'count' input parameter (number, default 10, max 100).{ count: z.number().optional().describe("Number of recent messages to retrieve (default: 10, max: 100)") },
- src/tools/chat-tools.ts:20-42 (registration)Registers the 'read-chat' tool via factory.registerTool, including name, description, schema, and inline handler.factory.registerTool( "read-chat", "Get recent chat messages from players", { count: z.number().optional().describe("Number of recent messages to retrieve (default: 10, max: 100)") }, async ({ count = 10 }) => { const maxCount = Math.min(count, messageStore.getMaxMessages()); const messages = messageStore.getRecentMessages(maxCount); if (messages.length === 0) { return factory.createResponse("No chat messages found"); } let output = `Found ${messages.length} chat message(s):\n\n`; messages.forEach((msg, index) => { const timestamp = new Date(msg.timestamp).toISOString(); output += `${index + 1}. ${timestamp} - ${msg.username}: ${msg.content}\n`; }); return factory.createResponse(output); } );