Skip to main content
Glama

godot_create_shader

Create shader files in Godot projects using starter templates or custom code to implement visual effects for game development.

Instructions

Create a .gdshader file inside the Godot project, either from a starter template or explicit shader code.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_pathYesPath to the Godot project directory or its project.godot file.
shader_nameYesHuman-friendly shader name or filename, for example 'Water Ripple' or 'water_ripple.gdshader'.
folderNoProject-relative folder where the shader should be saved.shaders
shader_typeNoShader type for the generated template, such as canvas_item, spatial, particles, sky, or fog.canvas_item
shader_codeNoOptional explicit shader source. When omitted, a starter template is generated.
overwriteNoWhether to replace an existing shader file with the same normalized name.

Implementation Reference

  • The handler function `create_shader` inside `GodotController` class responsible for creating the .gdshader file.
    def create_shader(
        self,
        project_path: str,
        shader_name: str,
        folder: str = "shaders",
        shader_type: str = "canvas_item",
        shader_code: str | None = None,
        overwrite: bool = False,
    ) -> dict[str, Any]:
        project_dir = ensure_project_path(project_path)
    
        final_shader_name = shader_name.strip()
        if not final_shader_name:
            raise GodotError("`shader_name` is required.")
    
        final_shader_type = shader_type.strip().lower()
        if not re.fullmatch(r"[a-z_][a-z0-9_]*", final_shader_type):
            raise GodotError("`shader_type` must be a valid Godot shader type name.")
    
        normalized_folder = normalize_project_subdir(folder)
        shader_dir = project_dir / normalized_folder if normalized_folder else project_dir
        shader_dir.mkdir(parents=True, exist_ok=True)
    
        filename_base = final_shader_name[:-9] if final_shader_name.lower().endswith(".gdshader") else final_shader_name
        filename = f"{snake_case_name(filename_base, default='shader')}.gdshader"
        shader_path = (shader_dir / filename).resolve()
        existed_before = shader_path.exists()
        if existed_before and not overwrite:
            raise GodotError(
                f"Shader already exists at {shader_path}. Pass `overwrite=true` to replace it."
            )
    
        shader_source = shader_code if shader_code is not None else _default_shader_source(final_shader_type)
        if not shader_source.endswith("\n"):
            shader_source += "\n"
        shader_path.write_text(shader_source, encoding="utf-8")
    
        relative_shader_path = shader_path.relative_to(project_dir)
        return {
            "project_path": str(project_dir),
            "shader_name": shader_name,
            "shader_path": str(shader_path),
            "shader_resource_path": f"res://{relative_shader_path.as_posix()}",
            "shader_type": final_shader_type,
            "created_from_template": shader_code is None,
            "known_shader_type": final_shader_type in KNOWN_SHADER_TYPES,
            "created": not existed_before,
        }
  • Registration of the `godot_create_shader` tool in the MCP server.
        name="godot_create_shader",
        description="Create a `.gdshader` file inside the Godot project, either from a starter template or explicit shader code.",
        input_schema={
            "type": "object",
            "properties": {
                "project_path": {
                    "type": "string",
                    "description": "Path to the Godot project directory or its project.godot file.",
                },
                "shader_name": {
                    "type": "string",
                    "description": "Human-friendly shader name or filename, for example 'Water Ripple' or 'water_ripple.gdshader'.",
                },
                "folder": {
                    "type": "string",
                    "description": "Project-relative folder where the shader should be saved.",
                    "default": "shaders",
                },
                "shader_type": {
                    "type": "string",
                    "description": "Shader type for the generated template, such as canvas_item, spatial, particles, sky, or fog.",
                    "default": "canvas_item",
                },
                "shader_code": {
                    "type": "string",
                    "description": "Optional explicit shader source. When omitted, a starter template is generated.",
                },
                "overwrite": {
                    "type": "boolean",
                    "description": "Whether to replace an existing shader file with the same normalized name.",
                    "default": False,
                },
            },
            "required": ["project_path", "shader_name"],
            "additionalProperties": False,
        },
        handler=lambda args: self.controller.create_shader(
            project_path=args["project_path"],
            shader_name=args["shader_name"],
            folder=args.get("folder", "shaders"),
            shader_type=args.get("shader_type", "canvas_item"),
            shader_code=args.get("shader_code"),
            overwrite=bool(args.get("overwrite", False)),
        ),
    ),
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions creation behavior but doesn't disclose permissions needed, whether it modifies project files, error handling, or what happens on failure. The 'overwrite' parameter hints at file replacement, but the description doesn't elaborate on consequences like data loss or validation. For a file creation tool with zero annotation coverage, this leaves significant behavioral gaps.

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 a single, efficient sentence that front-loads the core action and includes key details (file type, project context, creation methods). Every word earns its place with no redundancy or unnecessary elaboration.

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 (6 parameters, file creation operation) and lack of annotations/output schema, the description is minimally adequate. It covers the what and how but misses behavioral aspects like error conditions, permissions, or output details. For a creation tool without structured safety hints, more completeness would be beneficial.

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 6 parameters thoroughly. The description adds marginal value by mentioning 'starter template or explicit shader code', which relates to the 'shader_code' parameter, but doesn't provide additional syntax, format details, or examples beyond what the schema provides. Baseline 3 is appropriate when schema does the heavy lifting.

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 action ('Create'), the resource ('.gdshader' file), and the context (inside Godot project). It distinguishes from siblings by specifying shader creation rather than nodes, meshes, scripts, or other project operations. The mention of 'starter template or explicit shader code' adds specificity.

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 when a shader file needs to be created, but doesn't explicitly state when to use this tool versus alternatives like 'godot_attach_script' or 'godot_add_node'. It mentions the two creation methods (template vs. explicit code), which provides some context, but lacks explicit guidance on prerequisites or comparisons to sibling tools.

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