Skip to main content
Glama
mikeysrecipes

BlenderMCP

set_texture

Apply Polyhaven textures to Blender objects by specifying object name and texture ID to enhance 3D models with realistic materials.

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

Implementation Reference

  • The handler function for the set_texture MCP tool. It connects to Blender, sends a 'set_texture' command with object_name and texture_id parameters, and formats the response detailing the applied material and nodes.
    @mcp.tool()
    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)}"
  • The @mcp.tool() decorator registers the set_texture function as an MCP tool.
    @mcp.tool()
  • The docstring defines the input schema (object_name: str, texture_id: str) and output (str message). Type hints reinforce the schema.
    """
    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.
    """
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions that the texture must be downloaded first, adding some context about prerequisites, but doesn't cover other critical aspects like whether this operation is reversible, what permissions are needed, how failures are handled beyond a generic message, or any rate limits. For a mutation tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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

Conciseness4/5

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

The description is appropriately sized with three sentences: a clear purpose statement, parameter details, and return information. It's front-loaded with the main action and avoids unnecessary fluff, though the parameter section could be slightly more integrated into the flow rather than listed separately.

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

Completeness3/5

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

Given the tool's complexity (a mutation operation with 2 parameters), no annotations, and no output schema, the description is moderately complete. It covers the purpose and parameters adequately but lacks details on behavioral traits like error handling, side effects, or output specifics beyond a generic success/failure message. For a tool in this context, it should provide more operational guidance to be fully helpful.

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

Parameters4/5

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

The description explicitly lists and describes both parameters ('object_name' and 'texture_id'), adding meaning beyond the input schema which has 0% description coverage. It clarifies that 'texture_id' refers to a Polyhaven texture and must be downloaded first, providing essential context not present in the schema. With 2 parameters and low schema coverage, this compensates well, though it could detail format or constraints more.

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

Purpose4/5

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

The description clearly states the action ('Apply') and target ('a previously downloaded Polyhaven texture to an object'), specifying both the resource (texture) and the object it affects. It distinguishes from siblings like 'download_polyhaven_asset' by focusing on application rather than acquisition, though it doesn't explicitly contrast with all texture-related tools.

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

Usage Guidelines3/5

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

The description implies usage by noting the texture 'must be downloaded first', which suggests a prerequisite but doesn't explicitly state when to use this tool versus alternatives like 'import_generated_asset' or other texture-handling tools. It provides some context but lacks clear when/when-not guidance or named alternatives.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mikeysrecipes/blender-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server