messageHistory
Retrieve recent chat history from collaborative workspaces to track conversations and review shared tasks.
Instructions
Get message history from the room (default last 20, max 100).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Number of messages (default 20, max 100) | |
| offset | No | Skip N most recent messages (default 0) |
Implementation Reference
- src/server/actions/messages.ts:46-69 (handler)The handler function for 'message.history', which retrieves messages from the room storage.
server.method("message.history", { description: "Get message history (default last 20, max 100)", params: z.object({ roomId: z.string().describe("Room ID"), agentToken: z.string().describe("Your agentToken from joinRoom"), limit: z.number().optional().describe("Number of messages (default 20, max 100)"), offset: z.number().optional().describe("Skip N most recent messages (default 0)"), }), handler: async (params, ctx) => { const agent = await ctx.store.getAgentByToken(params.agentToken); if (!agent) throw new Error("Invalid agentToken"); if (agent.roomId !== params.roomId) throw new Error("agentToken does not belong to this room"); const room = await ctx.store.getRoomById(params.roomId); if (!room) throw new Error(`Room not found: ${params.roomId}`); const msgs = await ctx.store.getRoomMessages(params.roomId, params.limit ?? 20, params.offset ?? 0); return { text: JSON.stringify(msgs, null, 2), contextId: params.roomId, data: { messages: msgs }, }; }, }); - src/server/protocols/mcp/adapters.ts:109-126 (registration)MCP registration for the 'messageHistory' tool, which maps it to the 'message.history' internal method.
server.mcp("message.history", { toolName: "messageHistory", description: "Get message history from the room (default last 20, max 100).", params: z.object({ roomId: z.string().optional().describe("Room ID (UUID from joinRoom)"), limit: z.number().optional().describe("Number of messages (default 20, max 100)"), offset: z.number().optional().describe("Skip N most recent messages (default 0)"), }), annotations: { title: "Message History", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false, }, inject: (session) => ({ agentToken: session.agentToken as string }), requiresJoin: true, });