Skip to main content
Glama

set_texture

Apply downloaded Polyhaven textures to 3D objects in Blender using texture IDs and object names for visual customization.

Instructions

Apply a previously downloaded Polyhaven texture to an object.

Parameters:
- object_name: Name of the object to apply the texture to
- texture_id: ID of the Polyhaven texture to apply (must be downloaded first)

Returns a message indicating success or failure.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
object_nameYes
texture_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the 'set_texture' MCP tool. It is decorated with @mcp.tool() for automatic registration. The function connects to Blender, sends the 'set_texture' command with object_name and texture_id parameters, processes the result, and returns a detailed success message including material information and node details, or an error message.
    def set_texture(ctx: Context, object_name: str, texture_id: str) -> str:
        """
        Apply a previously downloaded Polyhaven texture to an object.
    
        Parameters:
        - object_name: Name of the object to apply the texture to
        - texture_id: ID of the Polyhaven texture to apply (must be downloaded first)
    
        Returns a message indicating success or failure.
        """
        try:
            # Get the global connection
            blender = get_blender_connection()
    
            result = blender.send_command(
                "set_texture", {"object_name": object_name, "texture_id": texture_id}
            )
    
            if "error" in result:
                return f"Error: {result['error']}"
    
            if result.get("success"):
                material_name = result.get("material", "")
                maps = ", ".join(result.get("maps", []))
    
                # Add detailed material info
                material_info = result.get("material_info", {})
                node_count = material_info.get("node_count", 0)
                has_nodes = material_info.get("has_nodes", False)
                texture_nodes = material_info.get("texture_nodes", [])
    
                output = f"Successfully applied texture '{texture_id}' to {object_name}.\n"
                output += f"Using material '{material_name}' with maps: {maps}.\n\n"
                output += f"Material has nodes: {has_nodes}\n"
                output += f"Total node count: {node_count}\n\n"
    
                if texture_nodes:
                    output += "Texture nodes:\n"
                    for node in texture_nodes:
                        output += f"- {node['name']} using image: {node['image']}\n"
                        if node["connections"]:
                            output += "  Connections:\n"
                            for conn in node["connections"]:
                                output += f"    {conn}\n"
                else:
                    output += "No texture nodes found in the material.\n"
    
                return output
            else:
                return f"Failed to apply texture: {result.get('message', 'Unknown error')}"
        except Exception as e:
            logger.error(f"Error applying texture: {str(e)}")
            return f"Error applying texture: {str(e)}"

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description must handle all behavioral disclosure. It explains the prerequisite (texture must be downloaded) and the return type (success/failure message), but it does not disclose potential side effects (e.g., overwriting existing materials) or detail failure conditions. This is adequate but not comprehensive.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured: a one-sentence purpose, a concise parameter list, and a return-value note. Every line earns its place with no redundant text, making it easy for an agent to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple two-parameter tool, the description covers all necessary context: the action, prerequisites, parameter semantics, and return type. The presence of an output schema further reduces the need to detail return values. It is complete for the tool's complexity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has no parameter descriptions (0% coverage), so the description fully compensates by defining both parameters: object_name as 'Name of the object' and texture_id as 'ID of the Polyhaven texture to apply (must be downloaded first)'. This provides clear, actionable meaning beyond the raw schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's function with a specific verb ('Apply') and resource ('previously downloaded Polyhaven texture to an object'), which distinguishes it from sibling tools like search or download. It directly addresses the action and target, leaving no ambiguity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The phrase 'previously downloaded' implicitly establishes a prerequisite workflow (use after download_polyhaven_asset), providing clear context for when this tool is appropriate. However, it does not explicitly name alternatives or state exclusions, so it falls short of a full 5.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.