Skip to main content
Glama

chaingpt_get_chat_history

Retrieve saved chat history by unique identifier with configurable limits, offsets, and sorting options for review or analysis.

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

  • The asynchronous handler function that invokes generalchat.getChatHistory with the provided parameters (sdkUniqueId, limit, offset, sortBy, sortOrder), formats the response as a text content block, and handles errors appropriately.
    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, including descriptions matching the tool's documentation.
    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'."), }
  • The server.tool() call that registers the 'chaingpt_get_chat_history' tool, including its name, detailed description, input schema, 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, }; } } );
  • Initialization of the GeneralChat SDK client instance, configured with the ChainGPT API key from config, which is used by the tool handler.
    const generalchat = new GeneralChat({ apiKey: config.chaingpt.secretKey, });

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