Skip to main content
Glama

chaingpt_get_chat_history

Retrieve saved chat history by specifying a chat ID, with options to limit results, apply offsets, and sort entries for efficient access to conversation data.

Instructions

Get the chat history for a given chat blob id until the limit is reached retrieve saved chat history. By default, this will retrieve history entries associated with your API key. If you provide a specific sdkUniqueId, it will retrieve history entries associated with that chat blob id.

    Args:
        sdkUniqueId (str): The unique identifier for the chat.
        limit (int, optional): The maximum number of chat history items to return. Default is 10.
        offset (int, optional): The offset to start the chat history from. Default is 0.
        sortBy (str, optional): The field to sort the chat history by. Default is 'createdAt'.
        sortOrder (str, optional): The order to sort the chat history by. Default is 'ASC'.
    Returns:
        The chat history for the given chat blob id until the limit is reached.
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sdkUniqueIdYesThe unique id of the chat blob to get the history for. If not provided, it will return the chat history for all chat blobs until the limit is reached.
limitYesThe maximum number of chat history items to return. Default is 10.
offsetYesThe offset to start the chat history from. Default is 0.
sortByYesThe field to sort the chat history by. Default is 'createdAt'.
sortOrderYesThe order to sort the chat history by. Default is 'ASC'.

Implementation Reference

  • Handler function that executes the chaingpt_get_chat_history tool logic by calling the GeneralChat SDK's getChatHistory method and formatting the response or error.
    async (params) => {
      try {
        const response = await generalchat.getChatHistory({
          limit: params.limit,
          offset: params.offset,
          sortBy: params.sortBy,
          sortOrder: params.sortOrder,
          sdkUniqueId: params.sdkUniqueId,
        });
    
        return {
          content: [
            {
              type: "text",
              text: response.data.chatHistory,
            },
          ],
        };
      } catch (error) {
        const errorMessage =
          error instanceof Error
            ? error.message
            : "get_chat_history_Unknown_Error";
        return {
          content: [
            {
              type: "text",
              text: errorMessage,
            },
          ],
          isError: true,
        };
      }
    }
  • Zod schema defining the input parameters for the chaingpt_get_chat_history tool.
    export const chatHistorySchema = {
        sdkUniqueId: z.string().describe("The unique id of the chat blob to get the history for. If not provided, it will return the chat history for all chat blobs until the limit is reached."),
        limit: z.number().describe("The maximum number of chat history items to return. Default is 10."),
        offset: z.number().describe("The offset to start the chat history from. Default is 0."),
        sortBy: z.string().describe("The field to sort the chat history by. Default is 'createdAt'."),
        sortOrder: z.string().describe("The order to sort the chat history by. Default is 'ASC'."),
    }
  • Registration of the chaingpt_get_chat_history tool using server.tool, including tool name, description, schema reference, and inline handler function.
    server.tool(
      "chaingpt_get_chat_history",
      `Get the chat history for a given chat blob id until the limit is reached
          retrieve saved chat history. By default, this will retrieve history entries associated with your API key.
          If you provide a specific sdkUniqueId, it will retrieve history entries associated with that chat blob id.
    
          Args:
              sdkUniqueId (str): The unique identifier for the chat.
              limit (int, optional): The maximum number of chat history items to return. Default is 10.
              offset (int, optional): The offset to start the chat history from. Default is 0.
              sortBy (str, optional): The field to sort the chat history by. Default is 'createdAt'.
              sortOrder (str, optional): The order to sort the chat history by. Default is 'ASC'.
          Returns:
              The chat history for the given chat blob id until the limit is reached.
          `,
      chatHistorySchema,
      async (params) => {
        try {
          const response = await generalchat.getChatHistory({
            limit: params.limit,
            offset: params.offset,
            sortBy: params.sortBy,
            sortOrder: params.sortOrder,
            sdkUniqueId: params.sdkUniqueId,
          });
    
          return {
            content: [
              {
                type: "text",
                text: response.data.chatHistory,
              },
            ],
          };
        } catch (error) {
          const errorMessage =
            error instanceof Error
              ? error.message
              : "get_chat_history_Unknown_Error";
          return {
            content: [
              {
                type: "text",
                text: errorMessage,
              },
            ],
            isError: true,
          };
        }
      }
    );
  • src/tools/index.ts:5-5 (registration)
    Invocation of registerChatTools which registers the chaingpt_get_chat_history tool.
    registerChatTools();
  • src/index.ts:16-16 (registration)
    Top-level invocation of registerTools, which chains to registration of chaingpt_get_chat_history.
    registerTools();
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It mentions default behavior and parameter effects, but doesn't disclose critical behavioral traits like whether this is a read-only operation, authentication requirements, rate limits, error conditions, or pagination details. For a tool with 5 parameters and no annotations, this leaves significant gaps in understanding how the tool behaves beyond basic parameter descriptions.

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

Conciseness3/5

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

The description is moderately structured with purpose statement, usage notes, and parameter documentation. However, it contains redundant information (parameter details are duplicated from schema) and could be more front-loaded. The Returns section is tautological and adds no value. Some sentences don't earn their place, particularly the repetitive parameter documentation.

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

Completeness2/5

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

Given 5 parameters, no annotations, and no output schema, the description is incomplete. It covers basic functionality but lacks critical context about authentication, error handling, rate limits, response format, and when to use vs. siblings. For a data retrieval tool with multiple parameters and no structured safety/behavior annotations, this leaves too many unknowns for effective tool selection and invocation.

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 description coverage is 100%, so the schema already documents all parameters thoroughly. The description repeats parameter information in the Args section but adds minimal value beyond what's in the schema. It does clarify the conditional behavior of sdkUniqueId (retrieving all chat blobs if not provided), which provides some additional context. Baseline 3 is appropriate when schema does most of the work.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Get the chat history for a given chat blob id until the limit is reached.' It specifies the verb ('Get') and resource ('chat history'), and distinguishes it from siblings like 'chaingpt_invoke_chat' by focusing on retrieval rather than interaction. However, it doesn't explicitly differentiate from 'chaingpt_get_ai_crypto_news' beyond the resource type.

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?

The description provides some usage context: it mentions default behavior (retrieving history associated with your API key) and when to use sdkUniqueId. However, it lacks explicit guidance on when to choose this tool over alternatives like 'chaingpt_invoke_chat' or 'chaingpt_get_ai_crypto_news', and doesn't specify prerequisites or exclusions. The guidance is implied rather than explicit.

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/mikeysrecipes/chaingpt-mcp'

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