Skip to main content
Glama

list_prestashop_hooks

Discover available PrestaShop hooks for development by filtering by type and origin to integrate custom functionality.

Instructions

List all available PrestaShop hooks.

Args: hook_type: Filter by type (display, action) origin: Filter by origin (core, module, theme)

Returns: List of all hooks organized by type and origin

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hook_typeNo
originNo

Implementation Reference

  • The main handler function for the 'list_prestashop_hooks' tool. Decorated with @mcp.tool(), it fetches hooks using the list_hooks helper, categorizes them by type, limits results per category, and formats a markdown list with summaries.
    @mcp.tool()
    def list_prestashop_hooks(
        hook_type: Optional[str] = None, origin: Optional[str] = None
    ) -> str:
        """List all available PrestaShop hooks.
    
        Args:
            hook_type: Filter by type (display, action)
            origin: Filter by origin (core, module, theme)
    
        Returns:
            List of all hooks organized by type and origin
        """
        logger.info(f"Listing hooks (type={hook_type}, origin={origin})")
        hooks = list_hooks(hook_type=hook_type, origin=origin)
    
        if not hooks:
            return "No hooks found matching the filters"
    
        # Organize hooks by type
        display_hooks = [h for h in hooks if h["type"] == "display"]
        action_hooks = [h for h in hooks if h["type"] == "action"]
        other_hooks = [h for h in hooks if h["type"] not in ["display", "action"]]
    
        output = [f"Available PrestaShop Hooks ({len(hooks)} total)\n"]
    
        if display_hooks:
            output.append(f"## Display Hooks ({len(display_hooks)})\n")
            for hook in display_hooks[:20]:  # Limit to first 20
                desc = hook.get("description", "")
                if desc:
                    desc = desc[:80] + "..." if len(desc) > 80 else desc
                    output.append(f"- **{hook['name']}** ({hook['origin']}) - {desc}")
                else:
                    output.append(f"- **{hook['name']}** ({hook['origin']})")
    
            if len(display_hooks) > 20:
                output.append(f"\n  ... and {len(display_hooks) - 20} more display hooks")
            output.append("")
    
        if action_hooks:
            output.append(f"## Action Hooks ({len(action_hooks)})\n")
            for hook in action_hooks[:20]:  # Limit to first 20
                desc = hook.get("description", "")
                if desc:
                    desc = desc[:80] + "..." if len(desc) > 80 else desc
                    output.append(f"- **{hook['name']}** ({hook['origin']}) - {desc}")
                else:
                    output.append(f"- **{hook['name']}** ({hook['origin']})")
    
            if len(action_hooks) > 20:
                output.append(f"\n  ... and {len(action_hooks) - 20} more action hooks")
            output.append("")
    
        if other_hooks:
            output.append(f"## Other Hooks ({len(other_hooks)})\n")
            for hook in other_hooks:
                output.append(f"- **{hook['name']}** ({hook['origin']}, {hook['type']})")
            output.append("")
    
        output.append(
            "\nUse get_prestashop_hook('hook_name') to get detailed documentation for a specific hook."
        )
    
        return "\n".join(output)
  • Supporting helper function that queries the SQLite 'hooks' table for hooks matching the optional type and origin filters, returning a list of dictionaries containing basic hook information.
    def list_hooks(
        hook_type: Optional[str] = None, origin: Optional[str] = None
    ) -> List[Dict]:
        """List all hooks with optional filters.
    
        Args:
            hook_type: Filter by type (display, action)
            origin: Filter by origin (core, module, theme)
    
        Returns:
            List of hooks
        """
        conn = sqlite3.connect(DB_PATH)
        conn.row_factory = sqlite3.Row
        cursor = conn.cursor()
    
        where_clauses = []
        params = []
    
        if hook_type:
            where_clauses.append("type = ?")
            params.append(hook_type)
    
        if origin:
            where_clauses.append("origin = ?")
            params.append(origin)
    
        where_clause = f"WHERE {' AND '.join(where_clauses)}" if where_clauses else ""
    
        cursor.execute(
            f"""
            SELECT name, type, origin, locations, description
            FROM hooks
            {where_clause}
            ORDER BY name
        """,
            params,
        )
    
        results = [dict(row) for row in cursor.fetchall()]
        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