Skip to main content
Glama

messageHistory

Read-onlyIdempotent

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,
    });
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true and idempotentHint=true, establishing the safe read-only nature. The description adds valuable pagination constraints (default 20, max 100) not in annotations, but omits error behaviors (e.g., invalid room) and return structure details.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence of 12 words with zero waste. Front-loaded with action verb ('Get'), immediately followed by resource and constraints. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Adequate for a low-complexity tool with 2 optional parameters, 100% schema coverage, and clear annotations. Description covers the essential behavioral constraints (pagination limits) and resource scope without requiring output schema documentation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, establishing baseline 3. Description reinforces the limit constraints but duplicates schema information for that parameter. Does not add semantic context for 'offset' parameter beyond what schema provides, though 'from the room' implies the context for both parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description uses specific verb 'Get' with resource 'message history' and scope 'from the room', clearly distinguishing it from sibling sendMessage (write) and roomInfo (metadata). The parenthetical constraint '(default last 20, max 100)' further clarifies the retrieval scope.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Implies usage through the verb 'Get' (retrieval vs sending), but lacks explicit when-to-use guidance or named alternatives. Does not clarify when to use this vs roomInfo or how it relates to pagination workflows with offset.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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