Skip to main content
Glama
PuemMTH
by PuemMTH

search_commands_tool

Search command history by keyword across names, categories, and contexts to find relevant AI commands from usage logs.

Instructions

Search command history by keyword. Searches across command name, category, and context fields. Args: query: Search keyword limit: Max results (default 20)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
limitNo

Implementation Reference

  • The search_commands_tool handler function that executes the search logic. Takes a query string and optional limit, calls the storage layer search_commands function, and returns JSON-formatted results.
    @mcp.tool() def search_commands_tool(query: str, limit: int = 20) -> str: """ Search command history by keyword. Searches across command name, category, and context fields. Args: query: Search keyword limit: Max results (default 20) """ rows = search_commands(query=query, limit=limit) if not rows: return f"No records matching '{query}'." return json.dumps(rows, ensure_ascii=False, indent=2)
  • The @mcp.tool() decorator that registers search_commands_tool as an MCP tool with the FastMCP server.
    @mcp.tool()
  • The underlying search_commands function that performs the database query. Uses PostgreSQL ILIKE to search across command, category, and context fields. Returns a list of dictionaries representing matching records.
    def search_commands( query: str, limit: int = 20, ) -> list[dict]: """Full-text search across command, category, and context fields.""" conn = get_connection() with conn.cursor(cursor_factory=psycopg2.extras.RealDictCursor) as cur: cur.execute( """ SELECT * FROM command_log WHERE command ILIKE %s OR category ILIKE %s OR context ILIKE %s ORDER BY used_at DESC LIMIT %s """, (f"%{query}%", f"%{query}%", f"%{query}%", limit), ) rows = cur.fetchall() conn.close() return [_row_to_dict(r) for r in rows]

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/PuemMTH/mcp-commands'

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