list_prestashop_hooks
Discover available PrestaShop hooks by type and origin to identify integration points for custom modules and themes.
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
| Name | Required | Description | Default |
|---|---|---|---|
| hook_type | No | ||
| origin | No |
Implementation Reference
- prestashop_mcp/server.py:130-194 (handler)The main handler function for the 'list_prestashop_hooks' MCP tool. It is registered via @mcp.tool() decorator and implements the tool logic by calling the helper function and formatting the output.@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)
- prestashop_mcp/ingest.py:348-390 (helper)Helper function that queries the SQLite database for PrestaShop hooks matching the given type and origin filters, returning a list of hook dictionaries used by the tool handler.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