search_polyhaven_assets
Search and filter 3D assets from Polyhaven for use in Blender projects, including HDRI, textures, and models with category filtering.
Instructions
Search for assets on Polyhaven with optional filtering.
Parameters:
- asset_type: Type of assets to search for (hdris, textures, models, all)
- categories: Optional comma-separated list of categories to filter by
Returns a list of matching assets with basic information.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| asset_type | No | all | |
| categories | No |
Implementation Reference
- src/blender_mcp/server.py:367-414 (handler)The handler function for the 'search_polyhaven_assets' MCP tool. It connects to Blender via socket, sends a 'search_polyhaven_assets' command with parameters, receives and parses the JSON response, formats the asset list by popularity, and returns a readable string summary. Includes input validation via type hints and docstring, decorated with @mcp.tool() for automatic registration and schema inference.@mcp.tool() def search_polyhaven_assets( ctx: Context, asset_type: str = "all", categories: str = None ) -> str: """ Search for assets on Polyhaven with optional filtering. Parameters: - asset_type: Type of assets to search for (hdris, textures, models, all) - categories: Optional comma-separated list of categories to filter by Returns a list of matching assets with basic information. """ try: blender = get_blender_connection() result = blender.send_command("search_polyhaven_assets", { "asset_type": asset_type, "categories": categories }) if "error" in result: return f"Error: {result['error']}" # Format the assets in a more readable way assets = result["assets"] total_count = result["total_count"] returned_count = result["returned_count"] formatted_output = f"Found {total_count} assets" if categories: formatted_output += f" in categories: {categories}" formatted_output += f"\nShowing {returned_count} assets:\n\n" # Sort assets by download count (popularity) sorted_assets = sorted(assets.items(), key=lambda x: x[1].get("download_count", 0), reverse=True) for asset_id, asset_data in sorted_assets: formatted_output += f"- {asset_data.get('name', asset_id)} (ID: {asset_id})\n" formatted_output += f" Type: {['HDRI', 'Texture', 'Model'][asset_data.get('type', 0)]}\n" formatted_output += f" Categories: {', '.join(asset_data.get('categories', []))}\n" formatted_output += f" Downloads: {asset_data.get('download_count', 'Unknown')}\n\n" return formatted_output except Exception as e: logger.error(f"Error searching Polyhaven assets: {str(e)}") return f"Error searching Polyhaven assets: {str(e)}"
- src/blender_mcp/server.py:367-367 (registration)The @mcp.tool() decorator registers the search_polyhaven_assets function as an MCP tool, using its signature and docstring to define the tool schema.@mcp.tool()
- src/blender_mcp/server.py:934-943 (helper)The asset_creation_strategy prompt recommends using PolyHaven tools including search_polyhaven_assets indirectly via download_polyhaven_asset, as part of the preferred asset sourcing strategy.- For environment lighting: Use PolyHaven HDRIs - For materials/textures: Use PolyHaven textures Only fall back to scripting when: - PolyHaven, Sketchfab, and Hyper3D are all disabled - A simple primitive is explicitly requested - No suitable asset exists in any of the libraries - Hyper3D Rodin failed to generate the desired asset - The task specifically requires a basic material/color """