get_polyhaven_categories
Retrieve available categories for Poly Haven assets to filter and organize 3D resources in Blender, supporting HDRI, textures, and models.
Instructions
Get a list of categories for a specific asset type on Polyhaven.
Parameters:
asset_type: The type of asset to get categories for (hdris, textures, models, all)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| asset_type | No | hdris |
Implementation Reference
- src/blender_mcp/server.py:335-365 (handler)The handler function for the 'get_polyhaven_categories' tool. It checks if PolyHaven is enabled, sends the command to the Blender addon via the connection, receives the result, formats the categories by sorting by count, and returns a readable string list.@mcp.tool() def get_polyhaven_categories(ctx: Context, asset_type: str = "hdris") -> str: """ Get a list of categories for a specific asset type on Polyhaven. Parameters: - asset_type: The type of asset to get categories for (hdris, textures, models, all) """ try: blender = get_blender_connection() if not _polyhaven_enabled: return "PolyHaven integration is disabled. Select it in the sidebar in BlenderMCP, then run it again." result = blender.send_command("get_polyhaven_categories", {"asset_type": asset_type}) if "error" in result: return f"Error: {result['error']}" # Format the categories in a more readable way categories = result["categories"] formatted_output = f"Categories for {asset_type}:\n\n" # Sort categories by count (descending) sorted_categories = sorted(categories.items(), key=lambda x: x[1], reverse=True) for category, count in sorted_categories: formatted_output += f"- {category}: {count} assets\n" return formatted_output except Exception as e: logger.error(f"Error getting Polyhaven categories: {str(e)}") return f"Error getting Polyhaven categories: {str(e)}"
- src/blender_mcp/server.py:335-335 (registration)The @mcp.tool() decorator registers the get_polyhaven_categories function as an MCP tool, using its signature and docstring for automatic schema generation.@mcp.tool()
- src/blender_mcp/server.py:336-342 (schema)The function signature and docstring define the input schema (asset_type parameter with default 'hdris') and output as str.def get_polyhaven_categories(ctx: Context, asset_type: str = "hdris") -> str: """ Get a list of categories for a specific asset type on Polyhaven. Parameters: - asset_type: The type of asset to get categories for (hdris, textures, models, all) """
- src/blender_mcp/server.py:217-220 (helper)In get_blender_connection(), it calls get_polyhaven_status to set the global _polyhaven_enabled flag used by the tool.result = _blender_connection.send_command("get_polyhaven_status") # Store the PolyHaven status globally _polyhaven_enabled = result.get("enabled", False) return _blender_connection