Skip to main content
Glama

get_conversation

Retrieve complete conversation content by ID from indexed AI chat histories. Use after searching to access specific dialogue details.

Instructions

    Get the full content of a specific conversation by ID.
    Use search_conversations() first to find conversation IDs.
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
conversation_idYes

Implementation Reference

  • The get_conversation tool implementation, which retrieves messages for a specific conversation ID from the database.
    @mcp.tool()
    def get_conversation(conversation_id: str) -> str:
        """
        Get the full content of a specific conversation by ID.
        Use search_conversations() first to find conversation IDs.
        """
        con = get_conversations()
        messages = con.execute("""
            SELECT role, content, msg_timestamp
            FROM conversations
            WHERE conversation_id = ?
            ORDER BY msg_index ASC
        """, [conversation_id]).fetchall()
    
        if not messages:
            return f"Conversation not found: {conversation_id}"
    
        output = [f"## Conversation ({len(messages)} messages)\n"]
        for role, content, ts in messages[:20]:
            output.append(f"### {role.upper()} [{ts}]")
            output.append(str(content)[:1000] if content else "(empty)")
            if content and len(str(content)) > 1000:
                output.append(f"_... ({len(str(content))} chars total)_")
            output.append("")
    
        if len(messages) > 20:
            output.append(f"_... {len(messages) - 20} more messages_")
    
        return "\n".join(output)
  • The registration function where MCP tools (including get_conversation) are registered.
    def register(mcp):
        """Register conversation tools with the MCP server."""

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/mordechaipotash/brain-mcp'

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