Skip to main content
Glama

search_prestashop_hooks

Find PrestaShop hooks by searching with keywords, filtering by type and origin to locate specific functionality in development projects.

Instructions

Search PrestaShop hooks using full-text search.

Args: queries: List of search terms (maximum 3) hook_type: Filter by hook type (display, action) origin: Filter by origin (core, module, theme)

Returns: Formatted search results with hook details

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queriesYes
hook_typeNo
originNo

Implementation Reference

  • Handler function for the 'search_prestashop_hooks' tool. Includes registration via @mcp.tool(), input schema via type hints and docstring, and execution logic that delegates to search_hooks helper and formats results.
    @mcp.tool()
    def search_prestashop_hooks(
        queries: List[str],
        hook_type: Optional[str] = None,
        origin: Optional[str] = None,
    ) -> str:
        """Search PrestaShop hooks using full-text search.
    
        Args:
            queries: List of search terms (maximum 3)
            hook_type: Filter by hook type (display, action)
            origin: Filter by origin (core, module, theme)
    
        Returns:
            Formatted search results with hook details
        """
        if not queries:
            return "Error: Please provide at least one search query"
    
        # Limit to 3 queries
        queries = queries[:3]
    
        logger.info(f"Searching hooks for: {queries}")
        results = search_hooks(queries, hook_type=hook_type, origin=origin, limit=10)
    
        if not results:
            filters = []
            if hook_type:
                filters.append(f"type={hook_type}")
            if origin:
                filters.append(f"origin={origin}")
            filter_str = f" (filters: {', '.join(filters)})" if filters else ""
            return f"No results found for: {', '.join(queries)}{filter_str}"
    
        # Format results
        output = [f"Found {len(results)} hooks for: {', '.join(queries)}\n"]
    
        for i, hook in enumerate(results, 1):
            output.append(f"{i}. **{hook['name']}** ({hook['type']} hook)")
            output.append(f"   Origin: {hook['origin']}")
            output.append(f"   Locations: {hook['locations']}")
    
            if hook.get("description"):
                desc = hook["description"][:150]
                if len(hook["description"]) > 150:
                    desc += "..."
                output.append(f"   Description: {desc}")
    
            if hook.get("aliases"):
                output.append(f"   Aliases: {', '.join(hook['aliases'])}")
    
            if hook.get("snippet"):
                output.append(f"   {hook['snippet']}")
    
            output.append("")
    
        return "\n".join(output)
  • Core search logic using SQLite FTS5 full-text search on hooks table with optional filters for type and origin.
    def search_hooks(
        queries: List[str],
        hook_type: Optional[str] = None,
        origin: Optional[str] = None,
        limit: int = 10,
    ) -> List[Dict]:
        """Search PrestaShop hooks using FTS5.
    
        Args:
            queries: List of search terms
            hook_type: Filter by hook type (display, action)
            origin: Filter by origin (core, module, theme)
            limit: Maximum number of results
    
        Returns:
            List of matching hooks with metadata
        """
        if not queries:
            return []
    
        conn = sqlite3.connect(DB_PATH)
        conn.row_factory = sqlite3.Row
        cursor = conn.cursor()
    
        # Build search query
        search_query = " OR ".join(queries)
    
        # Build WHERE clause for filters
        where_clauses = ["prestashop_docs_fts MATCH ?"]
        params = [search_query]
    
        if hook_type:
            where_clauses.append("hooks.type = ?")
            params.append(hook_type)
    
        if origin:
            where_clauses.append("hooks.origin = ?")
            params.append(origin)
    
        where_clause = " AND ".join(where_clauses)
        params.append(limit)
    
        sql = f"""
            SELECT
                hooks.name,
                hooks.type,
                hooks.origin,
                hooks.locations,
                hooks.description,
                hooks.aliases,
                hooks.github_refs,
                prestashop_docs.path,
                snippet(prestashop_docs_fts, 6, '<mark>', '</mark>', '...', 32) as snippet
            FROM prestashop_docs_fts
            JOIN prestashop_docs ON prestashop_docs.id = prestashop_docs_fts.rowid
            JOIN hooks ON hooks.doc_id = prestashop_docs.id
            WHERE {where_clause}
            ORDER BY rank
            LIMIT ?
        """
    
        cursor.execute(sql, params)
        results = []
    
        for row in cursor.fetchall():
            results.append(
                {
                    "name": row["name"],
                    "type": row["type"],
                    "origin": row["origin"],
                    "locations": row["locations"],
                    "description": row["description"],
                    "aliases": json.loads(row["aliases"]) if row["aliases"] else [],
                    "github_refs": (
                        json.loads(row["github_refs"]) if row["github_refs"] else []
                    ),
                    "path": row["path"],
                    "snippet": row["snippet"],
                }
            )
    
        conn.close()
        return results

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/florinel-chis/prestashop-mcp'

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