Skip to main content
Glama

get_chat_history

Retrieve conversation history from Grok MCP to maintain context and continuity across chat sessions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionNodefault

Implementation Reference

  • The `get_chat_history` tool handler retrieves and formats the chat history for a given session. It is registered with `@mcp.tool` and marked as read-only.
    @mcp.tool(annotations=READONLY)
    async def get_chat_history(session: str = "default"):
        history = load_history(session)
        if not history:
            return f"No history found for session `{session}`."
        result = [f"**Chat History: `{session}`**\n"]
        for message in history:
            role = message["role"].capitalize()
            time = message["time"]
            result.append(f"**[{time}] {role}:** {message['content']}\n")
        return "\n".join(result)

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/merterbak/Grok-MCP'

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