Skip to main content
Glama

godot_add_primitive_mesh

Add primitive 3D mesh shapes like boxes, spheres, and cylinders to Godot scenes using MeshInstance3D nodes with customizable parameters and transforms.

Instructions

Add a MeshInstance3D with a built-in PrimitiveMesh resource such as BoxMesh, CylinderMesh, SphereMesh, CapsuleMesh, PlaneMesh, PrismMesh, QuadMesh, or TorusMesh.

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.
mesh_typeYesPrimitive mesh class to instantiate, such as BoxMesh, CylinderMesh, SphereMesh, CapsuleMesh, PlaneMesh, PrismMesh, QuadMesh, or TorusMesh.
parent_pathNoScene-relative node path where the new mesh node should be attached. Use '.' for the root..
node_nameNoOptional explicit MeshInstance3D node name. Defaults to a PascalCase form of the mesh type without a trailing Mesh suffix.
mesh_parametersNoOptional primitive mesh property overrides such as size, radius, height, or segment counts.
transformNoOptional Node3D transform fields to apply to the new MeshInstance3D. Vector values can be passed as objects like {x, y, z}.
godot_executableNoOptional explicit path to the Godot executable or .app bundle.

Implementation Reference

  • The handler method `add_primitive_mesh` in `GodotController` which executes the logic for adding a primitive mesh.
    def add_primitive_mesh(
        self,
        project_path: str,
        scene_path: str,
        mesh_type: str,
        parent_path: str = ".",
        node_name: str | None = None,
        mesh_parameters: dict[str, Any] | None = None,
        transform: 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}")
    
        final_mesh_type = mesh_type.strip()
        if not final_mesh_type:
            raise GodotError("`mesh_type` is required.")
    
        normalized_parent_path = normalize_scene_node_path(parent_path)
        final_node_name = (node_name or "").strip()
        if not final_node_name:
            base_name = final_mesh_type[:-4] if final_mesh_type.lower().endswith("mesh") else final_mesh_type
            final_node_name = pascal_case_name(base_name, default="Mesh")
    
        final_mesh_parameters = mesh_parameters or {}
        if not isinstance(final_mesh_parameters, dict):
            raise GodotError("`mesh_parameters` must be an object when provided.")
        final_transform = transform or {}
        if not isinstance(final_transform, dict):
            raise GodotError("`transform` must be an object when provided.")
    
        payload = {
            "mesh_parameters": final_mesh_parameters,
            "transform": final_transform,
        }
        try:
            with tempfile.NamedTemporaryFile(
                mode="w",
                encoding="utf-8",
                suffix="-godot-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` or `transform` 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="add_primitive_mesh.gd",
                user_args=[
                    "--scene-path",
                    resource_scene_path,
                    "--parent-path",
                    normalized_parent_path,
                    "--node-name",
                    final_node_name,
                    "--mesh-type",
                    final_mesh_type,
                    "--config-path",
                    config_path,
                ],
            )
        finally:
            Path(config_path).unlink(missing_ok=True)
    
        parsed = _parse_script_json_output(output, "add_primitive_mesh.gd")
        supported_mesh_parameters = parsed.get("supported_mesh_parameters", [])
        if not isinstance(supported_mesh_parameters, list):
            raise GodotError("Primitive mesh creation 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,
            "parent_path": parsed.get("parent_path", normalized_parent_path),
            "node_path": parsed.get("node_path"),
            "node_name": parsed.get("node_name", final_node_name),
            "node_type": parsed.get("node_type", "MeshInstance3D"),
            "mesh_type": parsed.get("mesh_type", final_mesh_type),
            "mesh_parameters": parsed.get("mesh_parameters", {}),
            "supported_mesh_parameters": supported_mesh_parameters,
            "updated_mesh_parameters": parsed.get("updated_mesh_parameters", []),
            "transform": parsed.get("transform", {}),
            "godot_executable": str(executable),
            "godot_version": version,
        }
  • Tool registration for `godot_add_primitive_mesh` in `server.py`.
        name="godot_add_primitive_mesh",
        description="Add a MeshInstance3D with a built-in PrimitiveMesh resource such as BoxMesh, CylinderMesh, SphereMesh, CapsuleMesh, PlaneMesh, PrismMesh, QuadMesh, or TorusMesh.",
        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.",
                },
                "mesh_type": {
                    "type": "string",
                    "description": "Primitive mesh class to instantiate, such as BoxMesh, CylinderMesh, SphereMesh, CapsuleMesh, PlaneMesh, PrismMesh, QuadMesh, or TorusMesh.",
                },
                "parent_path": {
                    "type": "string",
                    "description": "Scene-relative node path where the new mesh node should be attached. Use '.' for the root.",
                    "default": ".",
                },
                "node_name": {
                    "type": "string",
                    "description": "Optional explicit MeshInstance3D node name. Defaults to a PascalCase form of the mesh type without a trailing Mesh suffix.",
                },
                "mesh_parameters": {
                    "type": "object",
                    "description": "Optional primitive mesh property overrides such as size, radius, height, or segment counts.",
                },
                "transform": {
                    "type": "object",
                    "description": "Optional Node3D transform fields to apply to the new MeshInstance3D. Vector values can be passed as objects like {x, y, z}.",
                },
                "godot_executable": {
                    "type": "string",
                    "description": "Optional explicit path to the Godot executable or .app bundle.",
                },
            },
            "required": ["project_path", "scene_path", "mesh_type"],
            "additionalProperties": False,
        },
        handler=lambda args: self.controller.add_primitive_mesh(
            project_path=args["project_path"],
            scene_path=args["scene_path"],
            mesh_type=args["mesh_type"],
            parent_path=args.get("parent_path", "."),
            node_name=args.get("node_name"),
            mesh_parameters=args.get("mesh_parameters"),
            transform=args.get("transform"),
            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 'Adds' a MeshInstance3D, implying a write operation that modifies a scene file, but doesn't cover critical aspects like whether it requires specific permissions, if changes are reversible, potential side effects (e.g., scene corruption), or error handling. For a mutation tool with zero annotation coverage, this is a significant gap in transparency.

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 ('Add a MeshInstance3D') and lists mesh types without unnecessary elaboration. It avoids redundancy but could be slightly more structured (e.g., separating purpose from mesh examples).

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 (8 parameters, mutation operation, no output schema, and no annotations), the description is incomplete. It lacks information on behavioral traits, error conditions, return values, or how it integrates with the Godot workflow. For a tool that modifies scene files, this leaves too many unknowns for reliable agent 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 8 parameters thoroughly. The description adds minimal value beyond the schema—it mentions 'built-in PrimitiveMesh resource' and lists mesh types, which the schema also covers for 'mesh_type'. No additional syntax, format details, or usage examples are provided. Baseline 3 is appropriate when the schema does the heavy lifting.

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 tool adds a MeshInstance3D with a built-in PrimitiveMesh resource, specifying the verb ('Add') and resource ('MeshInstance3D with a built-in PrimitiveMesh'). It lists specific mesh types, making the purpose concrete. However, it doesn't explicitly differentiate from sibling tools like 'godot_add_node' or 'godot_edit_primitive_mesh', which could handle similar operations.

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?

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention prerequisites, when not to use it, or how it compares to siblings like 'godot_add_node' (for generic nodes) or 'godot_edit_primitive_mesh' (for modifying existing meshes). This leaves the agent to infer usage from context alone.

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