Skip to main content
Glama

Read chat history

wopee_read_chat_history

Retrieve recent chat messages from your project to review conversation context. Get sender info and timestamps for the last N messages.

Instructions

Read recent messages from the current project's chat room. Returns the last N messages in chronological order, including sender info and timestamps. Use this to understand the conversation context or review what has been discussed. Requires WOPEE_PROJECT_UUID to be configured.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoNumber of recent messages to fetch (default: 20, max: 100)

Implementation Reference

  • The main implementation file for the wopee_read_chat_history tool. Exports the tool object with the handler function that: (1) validates the optional 'limit' input via zod schema, (2) fetches the chat room UUID for the project using FetchChatRoom GQL query, (3) fetches chat messages using FetchChatMessages GQL query with the room UUID and limit, (4) formats messages with timestamps and author info, and (5) returns them as text content.
    import { z } from "zod";
    import { getConfig } from "../../utils/getConfig.js";
    import { requestClient } from "../../utils/requestClient.js";
    import { _parseError } from "../shared/helpers.js";
    import { ToolName } from "../shared/types.js";
    import { FetchChatMessages, FetchChatRoom } from "../shared/gql-queries.js";
    
    const InputSchema = z.object({
      limit: z
        .number()
        .int()
        .min(1)
        .max(100)
        .default(20)
        .describe("Number of recent messages to fetch (default: 20, max: 100)"),
    });
    
    type Input = z.infer<typeof InputSchema>;
    
    export const wopeeReadChatHistory = {
      name: ToolName.WOPEE_READ_CHAT_HISTORY,
      config: {
        title: "Read chat history",
        description:
          "Read recent messages from the current project's chat room. Returns the last N messages in chronological order, including sender info and timestamps. Use this to understand the conversation context or review what has been discussed. Requires WOPEE_PROJECT_UUID to be configured.",
        inputSchema: InputSchema.shape,
      },
      handler: async (input: Input) => {
        try {
          const { WOPEE_PROJECT_UUID } = getConfig();
    
          if (!WOPEE_PROJECT_UUID)
            return {
              content: [
                { type: "text" as const, text: "WOPEE_PROJECT_UUID is not set" },
              ],
            };
    
          // First fetch the chat room for this project
          const roomResult = await requestClient<{
            fetchChatRoom: { uuid: string } | null;
          }>(FetchChatRoom, {
            projectUuid: WOPEE_PROJECT_UUID,
          });
    
          if (!roomResult?.fetchChatRoom)
            return {
              content: [
                {
                  type: "text" as const,
                  text: "No chat room found for this project",
                },
              ],
            };
    
          const result = await requestClient<{
            fetchChatMessages: Array<{
              uuid: string;
              authorType: string;
              authorName: string | null;
              content: string;
              contentType: string;
              sourcePlatform: string;
              createdAt: string;
            }>;
          }>(FetchChatMessages, {
            roomUuid: roomResult.fetchChatRoom.uuid,
            limit: input.limit,
          });
    
          const messages = result?.fetchChatMessages || [];
          if (messages.length === 0) {
            return {
              content: [
                {
                  type: "text" as const,
                  text: "No messages found in the chat room",
                },
              ],
            };
          }
    
          const formatted = messages
            .map((msg) => {
              const author = msg.authorName || msg.authorType;
              const time = new Date(msg.createdAt).toISOString();
              return `[${time}] ${author}: ${msg.content}`;
            })
            .join("\n");
    
          return {
            content: [
              {
                type: "text" as const,
                text: `Chat history (${messages.length} messages):\n\n${formatted}`,
              },
            ],
          };
        } catch (error) {
          return _parseError(error);
        }
      },
    };
  • Input schema for the tool: accepts an optional 'limit' (integer, 1-100, default 20) defining the number of recent messages to fetch.
    const InputSchema = z.object({
      limit: z
        .number()
        .int()
        .min(1)
        .max(100)
        .default(20)
        .describe("Number of recent messages to fetch (default: 20, max: 100)"),
    });
  • Import of wopeeReadChatHistory into the central tools registry.
    import { wopeeReadChatHistory } from "./wopee_read_chat_history/index.js";
  • Registration of wopeeReadChatHistory in the TOOLS array, making it available as a tool.
    wopeeReadChatHistory,
  • Enum definition ToolName.WOPEE_READ_CHAT_HISTORY = 'wopee_read_chat_history' used to identify the tool.
    WOPEE_READ_CHAT_HISTORY = "wopee_read_chat_history",
Behavior3/5

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

No annotations are provided, so the description must cover behavioral traits. It mentions reading (non-destructive), chronological order, and the requirement of WOPEE_PROJECT_UUID. However, no details about rate limits, performance, or error handling are given.

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?

The description is two sentences long, front-loads the purpose, and contains no unnecessary information. Every sentence adds value.

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?

For a simple read operation with one parameter and no output schema, the description is sufficient. It explains the tool's output (messages, sender info, timestamps) and usage context. Minor gap: no mention of message format or error conditions.

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?

The input schema has 100% coverage with a description for 'limit'. The description adds 'last N messages' and 'chronological order', but these are implied by the schema. No additional semantics beyond the schema.

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?

The description clearly states it reads recent messages from the project's chat room, specifying the resource (chat history) and the action (read). It is distinct from siblings like wopee_send_chat_message, which sends messages.

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

Usage Guidelines4/5

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

The description suggests using the tool to understand conversation context or review discussions, which provides clear use cases. However, it does not explicitly state when not to use or mention alternatives.

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/Wopee-io/wopee-mcp'

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