Skip to main content
Glama

get_user_context

Retrieve stored user facts, patterns, and preferences to personalize responses and support ADHD productivity coaching.

Instructions

Get relevant context about the user (facts, patterns, preferences).

This retrieves stored facts about the user to help personalize responses.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The MCP tool definition for 'get_user_context' which delegates to the storage layer.
    async def get_user_context() -> str:
        """Get relevant context about the user (facts, patterns, preferences).
    
        This retrieves stored facts about the user to help personalize responses.
        """
        return await storage.get_user_context()
  • The actual implementation of the 'get_user_context' tool logic, which queries the 'user_facts' database table and formats the retrieved data.
    async def get_user_context() -> str:
        """Get relevant context about the user.
    
        Returns:
            Formatted user context
        """
        db = await get_db()
    
        cursor = await db.execute(
            "SELECT fact, category FROM user_facts ORDER BY created_at DESC LIMIT 20"
        )
        rows = await cursor.fetchall()
    
        if not rows:
            return "No user facts stored yet. Use add_user_fact() to remember important information."
    
        result = "\n=== USER CONTEXT ===\n\n"
    
        # Group by category
        categories = {}
        for row in rows:
            cat = row["category"]
            if cat not in categories:
                categories[cat] = []
            categories[cat].append(row["fact"])
    
        for category, facts in categories.items():
            result += f"{category.upper()}:\n"
            for fact in facts:
                result += f"  - {fact}\n"
            result += "\n"
    
        return result.strip()

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/94aharris/coach-ai'

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