set_material
Apply or create materials for 3D objects in Blender by specifying object names, material names, and RGB color values.
Instructions
Set or create a material for an object.
Parameters:
- object_name: Name of the object to apply the material to
- material_name: Optional name of the material to use or create
- color: Optional [R, G, B] color values (0.0-1.0)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| object_name | Yes | ||
| material_name | No | ||
| color | No |
Implementation Reference
- src/server.py:418-446 (handler)MCP tool handler for 'set_material'. Forwards parameters to Blender backend via send_command and handles response/error.@mcp.tool() def set_material( ctx: Context, object_name: str, material_name: str = None, color: List[float] = None ) -> str: """ Set or create a material for an object. Parameters: - object_name: Name of the object to apply the material to - material_name: Optional name of the material to use or create - color: Optional [R, G, B] color values (0.0-1.0) """ try: # Get the global connection blender = get_blender_connection() params = {"object_name": object_name} if material_name: params["material_name"] = material_name if color: params["color"] = color result = blender.send_command("set_material", params) return f"Applied material to {object_name}: {result.get('material_name', 'unknown')}" except Exception as e: logger.error(f"Error setting material: {str(e)}") return f"Error setting material: {str(e)}"
- src/server.py:419-429 (schema)Input schema defined by function parameters and docstring: required object_name (str), optional material_name (str), color (List[float]), returns str.def set_material( ctx: Context, object_name: str, material_name: str = None, color: List[float] = None ) -> str: """ Set or create a material for an object. Parameters: - object_name: Name of the object to apply the material to - material_name: Optional name of the material to use or create - color: Optional [R, G, B] color values (0.0-1.0) """
- src/server.py:418-418 (registration)The tool is registered using the @mcp.tool() decorator.@mcp.tool()
- src/server.py:708-709 (helper)Mentioned in asset_creation_strategy prompt as fallback tool for basic materials.- set_material() for basic colors and materials