Skip to main content
Glama

get_prestashop_hook

Retrieve complete documentation for PrestaShop hooks to understand their functionality, parameters, and usage examples for development.

Instructions

Get complete documentation for a specific PrestaShop hook.

Args: hook_name: Name of the hook (e.g., 'displayHeader', 'actionProductAdd')

Returns: Complete hook documentation including description, parameters, examples

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hook_nameYes

Implementation Reference

  • The handler function for the 'get_prestashop_hook' tool, decorated with @mcp.tool(). It retrieves hook data via get_hook() and formats it into comprehensive markdown documentation including type, origin, description, aliases, source files, code examples, and full content.
    @mcp.tool()
    def get_prestashop_hook(hook_name: str) -> str:
        """Get complete documentation for a specific PrestaShop hook.
    
        Args:
            hook_name: Name of the hook (e.g., 'displayHeader', 'actionProductAdd')
    
        Returns:
            Complete hook documentation including description, parameters, examples
        """
        logger.info(f"Getting hook: {hook_name}")
        hook = get_hook(hook_name)
    
        if not hook:
            return f"Hook '{hook_name}' not found. Use list_prestashop_hooks() to see available hooks."
    
        # Format hook documentation
        output = [f"# {hook['name']}\n"]
        output.append(f"**Type:** {hook['type']}")
        output.append(f"**Origin:** {hook['origin']}")
        output.append(f"**Locations:** {hook['locations']}\n")
    
        if hook.get("description"):
            output.append(f"## Description\n")
            output.append(f"{hook['description']}\n")
    
        if hook.get("aliases"):
            output.append(f"## Aliases\n")
            for alias in hook["aliases"]:
                output.append(f"- {alias}")
            output.append("")
    
        if hook.get("github_refs"):
            output.append(f"## Source Files\n")
            for ref in hook["github_refs"]:
                output.append(f"- {ref}")
            output.append("")
    
        if hook.get("code_examples"):
            output.append(f"## Code Examples\n")
            for i, example in enumerate(hook["code_examples"], 1):
                output.append(f"### Example {i}\n")
                output.append(f"```php\n{example}\n```\n")
    
        # Add full markdown content
        if hook.get("content"):
            output.append("## Full Documentation\n")
            output.append(hook["content"])
    
        return "\n".join(output)
  • Helper function that queries the SQLite database for detailed information on a specific hook by name, joining hooks and prestashop_docs tables, and returning a structured dictionary with all hook data.
    def get_hook(hook_name: str) -> Optional[Dict]:
        """Get complete documentation for a specific hook.
    
        Args:
            hook_name: Name of the hook
    
        Returns:
            Hook documentation dict or None if not found
        """
        conn = sqlite3.connect(DB_PATH)
        conn.row_factory = sqlite3.Row
        cursor = conn.cursor()
    
        cursor.execute(
            """
            SELECT
                hooks.*,
                prestashop_docs.content,
                prestashop_docs.path
            FROM hooks
            JOIN prestashop_docs ON hooks.doc_id = prestashop_docs.id
            WHERE hooks.name = ?
        """,
            (hook_name,),
        )
    
        row = cursor.fetchone()
        conn.close()
    
        if not row:
            return None
    
        return {
            "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 [],
            "code_examples": (
                json.loads(row["code_examples"]) if row["code_examples"] else []
            ),
            "content": row["content"],
            "path": row["path"],
        }

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