Skip to main content
Glama

clear_chat_history

Remove chat history from Grok MCP sessions to manage conversation data and maintain privacy.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionNodefault

Implementation Reference

  • 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()

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