get_chat_history
Retrieve conversation history from Grok MCP to maintain context and continuity across chat sessions.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| session | No | default |
Implementation Reference
- src/server.py:66-76 (handler)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)