Skip to main content
Glama

search_episodes

Search knowledge episodes to find relevant information and patterns from user corrections, helping identify common standards and configuration updates.

Instructions

Search knowledge episodes

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMax results
queryYesSearch query

Implementation Reference

  • Main handler function implementing the search_episodes tool. Performs full-text search (FTS) on the episodes table using SQLite, with fallback to LIKE search. Returns matching episodes with metadata.
    async def _search_episodes(self, query: str, limit: int = 10) -> Dict[str, Any]:
        """Search episodes using FTS"""
        try:
            with sqlite3.connect(self.db_path) as conn:
                conn.row_factory = sqlite3.Row
                
                # Use FTS search if available, fallback to LIKE
                try:
                    cursor = conn.execute("""
                        SELECT e.id, e.name, e.content, e.source, e.timestamp,
                               rank
                        FROM episodes_search 
                        JOIN episodes e ON episodes_search.rowid = e.id
                        WHERE episodes_search MATCH ?
                        ORDER BY rank
                        LIMIT ?
                    """, (query, limit))
                except sqlite3.OperationalError:
                    # Fallback to simple search
                    cursor = conn.execute("""
                        SELECT id, name, content, source, timestamp
                        FROM episodes 
                        WHERE name LIKE ? OR content LIKE ?
                        ORDER BY timestamp DESC
                        LIMIT ?
                    """, (f"%{query}%", f"%{query}%", limit))
                
                episodes = [dict(row) for row in cursor.fetchall()]
                
                return {
                    "success": True,
                    "query": query,
                    "results": episodes,
                    "count": len(episodes)
                }
        except Exception as e:
            return {"success": False, "error": str(e)}
  • JSON Schema definition for the search_episodes tool input parameters: query (required string), limit (optional integer default 10).
    Tool(
        name="search_episodes",
        description="Search knowledge episodes",
        inputSchema={
            "type": "object",
            "properties": {
                "query": {"type": "string", "description": "Search query"},
                "limit": {"type": "integer", "description": "Max results", "default": 10},
            },
            "required": ["query"],
        },
    ),
  • Tool dispatch/registration in the main call_tool handler: matches tool name and calls the _search_episodes implementation.
    elif name == "search_episodes":
        results = await self._search_episodes(
            arguments["query"], 
            arguments.get("limit", 10)
        )
        return [TextContent(type="text", text=json.dumps(results))]
  • Identical handler implementation in the enhanced server variant.
    async def _search_episodes(self, query: str, limit: int = 10) -> Dict[str, Any]:
        """Search episodes using FTS"""
        try:
            with sqlite3.connect(self.db_path) as conn:
                conn.row_factory = sqlite3.Row
    
                try:
                    cursor = conn.execute("""
                        SELECT e.id, e.name, e.content, e.source, e.timestamp,
                               rank
                        FROM episodes_search
                        JOIN episodes e ON episodes_search.rowid = e.id
                        WHERE episodes_search MATCH ?
                        ORDER BY rank
                        LIMIT ?
                    """, (query, limit))
                except sqlite3.OperationalError:
                    cursor = conn.execute("""
                        SELECT id, name, content, source, timestamp
                        FROM episodes
                        WHERE name LIKE ? OR content LIKE ?
                        ORDER BY timestamp DESC
                        LIMIT ?
                    """, (f"%{query}%", f"%{query}%", limit))
    
                episodes = [dict(row) for row in cursor.fetchall()]
    
                return {
                    "success": True,
                    "query": query,
                    "results": episodes,
                    "count": len(episodes)
                }
        except Exception as e:
            return {"success": False, "error": str(e)}
  • Helper classifying search_episodes as SIMPLE task complexity for cost-optimized model routing (e.g., to cheaper models like Gemini Flash).
    "search_episodes": TaskComplexity.SIMPLE,
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It only states the action ('Search') without detailing how results are returned, sorted, or paginated, whether there are rate limits, authentication needs, or what happens on errors. This leaves significant gaps for a search operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient phrase with zero wasted words. It's appropriately sized for a simple tool and front-loaded with the core action, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (search operation with parameters) and lack of annotations or output schema, the description is incomplete. It doesn't explain return values, error handling, or behavioral traits, leaving the agent with insufficient context to use the tool effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with clear documentation for both parameters ('limit' and 'query'). The description adds no additional meaning beyond the schema, such as query syntax or result scope, so it meets the baseline for high schema coverage without compensating value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Search knowledge episodes' states the basic action (search) and resource (knowledge episodes), but lacks specificity about what constitutes a 'knowledge episode' or how the search operates. It doesn't differentiate from sibling tools like 'list_recent' or 'get_learned_preferences', leaving the purpose somewhat vague.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to prefer 'search_episodes' over 'list_recent' or other siblings, nor does it specify prerequisites or exclusions, leaving usage entirely implicit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/airmcp-com/mcp-standards'

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