Skip to main content
Glama

chaingpt_get_chat_history

Retrieve chat history for a specific chat blob ID. Supports pagination with limit and offset, and sorting by creation date in ascending or descending order. Access history entries linked to your API key or a particular session.

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

  • Registration of the 'chaingpt_get_chat_history' tool on the MCP server, with its description and schema binding.
    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,
          };
        }
      }
    );
  • Handler function that executes the tool logic: calls generalchat.getChatHistory() with parameters and returns the chat history response.
    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,
        };
      }
    }
  • Input schema (chatHistorySchema) defining the validation for sdkUniqueId, limit, offset, sortBy, and sortOrder parameters using Zod.
    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'."),
    }
  • src/tools/index.ts:4-7 (registration)
    registerTools() calls registerChatTools(), which registers the tool on the server.
    export const registerTools = () => {
        registerChatTools();
        registerNewsTools();
    }
  • src/index.ts:10-16 (registration)
    MCP server creation (name 'chaingpt-mcp') where tools are registered.
    export const server = new McpServer({
      name: 'chaingpt-mcp',
      version: '0.1.0',
    });
    
    // Load the capabilities
    registerTools();
Behavior3/5

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

With no annotations, the description must disclose behavioral traits. It mentions default behavior tied to API key and the selectable chat blob ID, but fails to mention read-only nature, authentication requirements, rate limits, or what happens when limit is exceeded. It describes retrieval but does not confirm non-destructive behavior.

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 includes a docstring with Args and Returns sections, making it structured but not overly concise. It could be shortened by removing redundant repetition of schema details while keeping key behaviors.

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?

The tool has 5 required parameters and no output schema. The description does not explain the return format, pagination behavior, error conditions, or any constraints like maximum limit. The return value is vaguely described as 'The chat history' without structure, leaving the agent underinformed.

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%, so the schema documents all 5 parameters fully. The description repeats parameter information in a structured Args list, adding little beyond the schema. It provides default values and order information, but no unique semantic insight.

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 'Get the chat history for a given chat blob id' using a specific verb and resource. It distinguishes from siblings like 'chaingpt_get_ai_crypto_news' and 'chaingpt_invoke_chat' by focusing on chat history retrieval.

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 context on when to use the sdkUniqueId (to filter by chat blob) versus default (all chat blobs), but does not explicitly compare to alternative tools or state when not to use this tool. The guidance is implicit but not comprehensive.

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

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