Skip to main content
Glama

thinking_trajectory

Track how ideas about a topic evolve over time by analyzing conversation history to show genesis, patterns, and thinking stages.

Instructions

    Track the evolution of thinking about a topic over time.

    Args:
        topic: The concept/term to track
        view: What to show:
            - "full" (default): Complete trajectory with genesis, temporal pattern, semantic matches, thinking stages
            - "velocity": How often the concept appears over time with trend analysis
            - "first": When the concept first appeared — the genesis moment
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
topicYes
viewNofull

Implementation Reference

  • The `thinking_trajectory` tool is defined here as an MCP tool, which tracks the evolution of thoughts on a given topic over time.
    @mcp.tool()
    def thinking_trajectory(topic: str, view: str = "full") -> str:
        """
        Track the evolution of thinking about a topic over time.
    
        Args:
            topic: The concept/term to track
            view: What to show:
                - "full" (default): Complete trajectory with genesis, temporal pattern, semantic matches, thinking stages
                - "velocity": How often the concept appears over time with trend analysis
                - "first": When the concept first appeared — the genesis moment
        """
        if view == "velocity":
            return _concept_velocity(topic)
        elif view == "first":
            return _first_mention(topic)
    
        output = [f"## Thinking Trajectory: '{topic}'\n"]
        cfg = get_config()
    
        # 1. Semantic matches from embeddings
        embedding = get_embedding(topic)
        semantic_results = []
        if embedding and cfg.lance_path.exists():
            lance_results = lance_search(embedding, limit=20, min_sim=0.3)
            semantic_results = [(r[2], r[3], r[0], r[1], r[4]) for r in lance_results]
    
        # 2. Keyword matches with temporal distribution
        try:
            conv_con = get_conversations()
            pattern = f"%{topic}%"
            temporal_dist = conv_con.execute("""
                SELECT
                    strftime(created, '%Y-%m') as period,
                    COUNT(*) as mentions
                FROM conversations
                WHERE content ILIKE ? AND role = 'user'
                GROUP BY period
                ORDER BY period
            """, [pattern]).fetchall()
        except Exception:
            temporal_dist = []
    
        # 3. First mention
        try:
            first_mention = conv_con.execute("""
                SELECT created, conversation_title, substr(content, 1, 200) as preview
                FROM conversations
                WHERE content ILIKE ? AND role = 'user'
                ORDER BY created ASC
                LIMIT 1
            """, [pattern]).fetchone()
        except Exception:
            first_mention = None
    
        if first_mention:
            output.append("### Genesis")
            output.append(f"**First appeared**: {str(first_mention[0])[:10]}")
            output.append(f"**Context**: {first_mention[1] or 'Untitled'}")
            output.append(f"> {first_mention[2]}...\n")
    
        if temporal_dist:
            output.append("### Temporal Pattern")
            total = sum(t[1] for t in temporal_dist)

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