Skip to main content
Glama

list_chat_sessions

Retrieve available chat sessions from the Grok MCP server to continue conversations or review previous interactions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Implementation of the 'list_chat_sessions' tool. It reads JSON files from the 'chats' directory, calculates turns, and returns a formatted list of sessions.
    async def list_chat_sessions():
        Path("chats").mkdir(exist_ok=True)
        sessions = sorted(Path("chats").glob("*.json"))
        if not sessions:
            return "No chat sessions found."
        result = ["**Chat Sessions:**\n"]
        for s in sessions:
            history = json.loads(s.read_text())
            turns = len(history) // 2
            last = history[-1]["time"] if history else "empty"
            result.append(f"- `{s.stem}` — {turns} turn(s), last: {last}")
        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