set_material
Apply or create materials for 3D objects using specified colors and names, integrating with Tripo AI's Model Context Protocol for Blender workflows.
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 |
|---|---|---|---|
| color | No | ||
| material_name | No | ||
| object_name | Yes |
Implementation Reference
- src/server.py:418-446 (handler)The MCP tool handler and registration for 'set_material'. Decorated with @mcp.tool(), it constructs parameters from inputs and sends a 'set_material' command to the Blender socket connection, returning success or error message. The docstring provides the input schema description.@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)}"