clear_chat_history
Remove chat history from Grok MCP sessions to manage conversation data and maintain privacy.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| session | No | default |
Implementation Reference
- src/server.py:77-83 (handler)The clear_chat_history async function is the handler that implements the tool logic. It takes a session parameter (default "default"), constructs a path to a JSON file in the "chats" directory, checks if it exists, and deletes it using path.unlink() if found, returning a confirmation message.
@mcp.tool() async def clear_chat_history(session: str = "default"): path = Path("chats") / f"{session}.json" if not path.exists(): return f"No session `{session}` found." path.unlink() return f"Cleared history for session `{session}`." - src/server.py:77-77 (registration)The @mcp.tool() decorator registers the clear_chat_history function as an MCP tool with the FastMCP server instance (mcp). The tool name is automatically derived from the function name.
@mcp.tool()