Skip to main content
Glama

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
NameRequiredDescriptionDefault
limitNoNumber of messages (default 20, max 100)
offsetNoSkip N most recent messages (default 0)

Implementation Reference

  • 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 },
        };
      },
    });
  • 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,
    });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kushneryk/join.cloud'

If you have feedback or need assistance with the MCP directory API, please join our Discord server