Skip to main content
Glama

godot_edit_primitive_mesh

Modify PrimitiveMesh resources in Godot 4.5+ by changing mesh types and parameters for existing MeshInstance3D nodes to customize 3D geometry in game scenes.

Instructions

Modify the PrimitiveMesh resource attached to an existing MeshInstance3D by changing its mesh type and/or one or more mesh parameters.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_pathYesPath to the Godot project directory or its project.godot file.
scene_pathYesPath to the target .tscn file. Absolute, relative, and res:// paths are supported.
node_pathYesScene-relative node path to the MeshInstance3D node that should be edited.
mesh_typeNoOptional new PrimitiveMesh class such as BoxMesh, CylinderMesh, SphereMesh, CapsuleMesh, PlaneMesh, PrismMesh, QuadMesh, or TorusMesh.
mesh_parametersNoPrimitive mesh property overrides such as size, radius, height, or segment counts.
godot_executableNoOptional explicit path to the Godot executable or .app bundle.

Implementation Reference

  • The implementation of `edit_primitive_mesh` method within `GodotController` which modifies the PrimitiveMesh resource of a MeshInstance3D.
    def edit_primitive_mesh(
        self,
        project_path: str,
        scene_path: str,
        node_path: str,
        mesh_type: str | None = None,
        mesh_parameters: dict[str, Any] | None = None,
        godot_executable: str | None = None,
    ) -> dict[str, Any]:
        project_dir = ensure_project_path(project_path)
        executable, version = resolve_godot_executable(godot_executable)
        absolute_scene_path, resource_scene_path = resolve_scene_path(project_dir, scene_path)
    
        if not absolute_scene_path.exists():
            raise GodotError(f"Scene not found: {absolute_scene_path}")
    
        normalized_node_path = normalize_scene_node_path(node_path)
        final_mesh_type = (mesh_type or "").strip()
        final_mesh_parameters = mesh_parameters or {}
        if not isinstance(final_mesh_parameters, dict):
            raise GodotError("`mesh_parameters` must be an object when provided.")
        if not final_mesh_type and not final_mesh_parameters:
            raise GodotError("Provide at least one of `mesh_type` or `mesh_parameters`.")
    
        payload: dict[str, Any] = {
            "mesh_parameters": final_mesh_parameters,
        }
        if final_mesh_type:
            payload["mesh_type"] = final_mesh_type
    
        try:
            with tempfile.NamedTemporaryFile(
                mode="w",
                encoding="utf-8",
                suffix="-godot-edit-primitive-mesh.json",
                delete=False,
            ) as handle:
                json.dump(payload, handle, ensure_ascii=False)
                config_path = handle.name
        except TypeError as exc:
            raise GodotError("`mesh_parameters` contains a value that could not be serialized to JSON.") from exc
    
        try:
            output = _run_godot_script(
                executable=executable,
                project_dir=project_dir,
                script_name="edit_primitive_mesh.gd",
                user_args=[
                    "--scene-path",
                    resource_scene_path,
                    "--node-path",
                    normalized_node_path,
                    "--config-path",
                    config_path,
                ],
            )
        finally:
            Path(config_path).unlink(missing_ok=True)
    
        parsed = _parse_script_json_output(output, "edit_primitive_mesh.gd")
        supported_mesh_parameters = parsed.get("supported_mesh_parameters", [])
        if not isinstance(supported_mesh_parameters, list):
            raise GodotError("Primitive mesh edit did not return a supported parameter list.")
    
        return {
            "project_path": str(project_dir),
            "scene_path": str(absolute_scene_path),
            "scene_resource_path": resource_scene_path,
            "node_path": parsed.get("node_path", normalized_node_path),
            "node_name": parsed.get("node_name"),
            "node_type": parsed.get("node_type", "MeshInstance3D"),
            "mesh_type_before": parsed.get("mesh_type_before"),
            "mesh_type_after": parsed.get("mesh_type_after"),
            "mesh_parameters": parsed.get("mesh_parameters", {}),
            "supported_mesh_parameters": supported_mesh_parameters,
            "updated_mesh_parameters": parsed.get("updated_mesh_parameters", []),
            "godot_executable": str(executable),
            "godot_version": version,
        }
  • The definition and registration of the `godot_edit_primitive_mesh` tool within the MCP server.
        name="godot_edit_primitive_mesh",
        description="Modify the PrimitiveMesh resource attached to an existing MeshInstance3D by changing its mesh type and/or one or more mesh parameters.",
        input_schema={
            "type": "object",
            "properties": {
                "project_path": {
                    "type": "string",
                    "description": "Path to the Godot project directory or its project.godot file.",
                },
                "scene_path": {
                    "type": "string",
                    "description": "Path to the target .tscn file. Absolute, relative, and res:// paths are supported.",
                },
                "node_path": {
                    "type": "string",
                    "description": "Scene-relative node path to the MeshInstance3D node that should be edited.",
                },
                "mesh_type": {
                    "type": "string",
                    "description": "Optional new PrimitiveMesh class such as BoxMesh, CylinderMesh, SphereMesh, CapsuleMesh, PlaneMesh, PrismMesh, QuadMesh, or TorusMesh.",
                },
                "mesh_parameters": {
                    "type": "object",
                    "description": "Primitive mesh property overrides such as size, radius, height, or segment counts.",
                },
                "godot_executable": {
                    "type": "string",
                    "description": "Optional explicit path to the Godot executable or .app bundle.",
                },
            },
            "required": ["project_path", "scene_path", "node_path"],
            "additionalProperties": False,
        },
        handler=lambda args: self.controller.edit_primitive_mesh(
            project_path=args["project_path"],
            scene_path=args["scene_path"],
            node_path=args["node_path"],
            mesh_type=args.get("mesh_type"),
            mesh_parameters=args.get("mesh_parameters"),
            godot_executable=args.get("godot_executable"),
        ),
    ),
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 states the tool modifies an existing resource, implying mutation, but does not address critical aspects like whether changes are destructive, require specific permissions, have side effects on the scene, or provide error handling. For a mutation tool with zero annotation coverage, this leaves significant gaps in understanding its behavior and safety.

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 a single, efficient sentence that front-loads the core action and target. It avoids redundancy and wastes no words, though it could be slightly more structured by separating usage context from parameter hints. Overall, it is appropriately concise for the tool's complexity.

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

Completeness2/5

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

Given the tool's complexity (mutation with 6 parameters, nested objects, no output schema, and no annotations), the description is inadequate. It lacks information on behavioral traits, error handling, return values, and how it fits among siblings. While the schema covers parameters well, the description does not compensate for the missing annotations and output schema, leaving the agent under-informed for safe and effective use.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds marginal value by implying that 'mesh_type' and 'mesh_parameters' are the primary editable fields, but does not provide additional syntax, format details, or examples beyond what the schema specifies. This meets the baseline for high schema coverage without enhancing parameter understanding.

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 ('Modify'), the target resource ('PrimitiveMesh resource attached to an existing MeshInstance3D'), and the specific changes ('changing its mesh type and/or one or more mesh parameters'). It distinguishes from siblings like 'godot_add_primitive_mesh' (adds new) and 'godot_edit_scene' (broader edits), though not explicitly named. The purpose is specific but could be more explicit about sibling differentiation.

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

Usage Guidelines2/5

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

The description provides minimal guidance on when to use this tool. It implies usage for editing existing PrimitiveMesh resources, but does not specify when to choose this over alternatives like 'godot_edit_scene' for broader edits or 'godot_add_primitive_mesh' for adding new ones. No prerequisites, exclusions, or explicit alternatives are mentioned, leaving the agent with little contextual direction.

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/MhrnMhrn/godot-mcp'

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