Godot MCP

repository·main·Indexed 26 days ago

https://github.com/coding-solo/godot-mcp

A Model Context Protocol (MCP) server that enables AI agents to interact with the Godot game engine. It provides tools for launching the editor, running projects, capturing debug output, managing scenes, and manipulating nodes. Compatible with MCP clients such as Claude Code, Cline, and Cursor, it supports operations like creating scenes, adding nodes, loading sprites, and managing resource UIDs for Godot 4.4+.

Tokens
2.8K
Snippets
5
Records
28
Agent score
40%

What's inside godot-mcp

  1. Configure Godot MCP for Cline

    main

    To use Godot MCP with Cline, add the following configuration to your Cline MCP settings file located at ~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json.

    {
      "mcpServers": {
        "godot": {
          "command": "npx",
          "args": ["@coding-solo/godot-mcp"],
          "env": {
            "DEBUG": "true"
          },
          "disabled": false,
          "autoApprove": [
            "launch_editor",
            "run_project",
            "get_debug_output",
            "stop_project",
            "get_godot_version",
            "list_projects",
            "get_project_info",
            "create_scene",
            "add_node",
            "load_sprite",
            "export_mesh_library",
            "save_scene",
            "get_uid",
            "update_project_uids"
          ]
        }
      }
    }
  2. Install Godot MCP with Claude Code

    main

    To add Godot MCP to Claude Code, use the claude mcp add command. You can optionally provide the path to your Godot executable and enable debug logging using environment variables.

    Basic installation:

    claude mcp add godot -- npx @coding-solo/godot-mcp

    Installation with environment variables:

    claude mcp add godot -e GODOT_PATH=/path/to/godot -e DEBUG=true -- npx @coding-solo/godot-mcp
  3. Build Godot MCP from Source

    main

    To build the project from source, clone the repository, install dependencies, and run the build script. After building, point your MCP client to build/index.js instead of using npx.

    git clone https://github.com/Coding-Solo/godot-mcp.git
    cd godot-mcp
    npm install
    npm run build
  4. Configure Godot MCP for other MCP Clients

    main

    For any other MCP-compatible client, use the following JSON configuration. You can specify GODOT_PATH to override automatic detection and DEBUG to enable detailed server-side logging.

    {
      "mcpServers": {
        "godot": {
          "command": "npx",
          "args": ["@coding-solo/godot-mcp"],
          "env": {
            "GODOT_PATH": "/path/to/godot",
            "DEBUG": "true"
          }
        }
      }
    }
  5. Configure Godot MCP for Cursor

    main

    You can configure Godot MCP in Cursor using the UI or a project-specific configuration file.

    Using the Cursor UI

    1. Go to Cursor Settings > Features > MCP.
    2. Click + Add New MCP Server.
    3. Set Name to godot.
    4. Set Type to command.
    5. Set Command to npx @coding-solo/godot-mcp.
    6. Click Add.

    Using Project-Specific Configuration

    Create a .cursor/mcp.json file in your project directory:

    {
      "mcpServers": {
        "godot": {
          "command": "npx",
          "args": ["@coding-solo/godot-mcp"],
          "env": {
            "DEBUG": "true"
          }
        }
      }
    }
  6. Configure Godot MCP Environment Variables

    main

    The following environment variables can be used to configure the Godot MCP server:

    VariableDescription
    GODOT_PATHPath to the Godot executable (overrides automatic detection)
    DEBUGSet to "true" to enable detailed server-side debug logging
  7. Troubleshoot Godot MCP issues

    main

    Common troubleshooting steps:

    • Godot Not Found: Set the GODOT_PATH environment variable to your Godot executable path.
    • Connection Issues: Ensure the server is running and restart your AI assistant.
    • Invalid Project Path: Ensure the path points to a directory containing a project.godot file.
    • Build Issues: Ensure all dependencies are installed by running npm install.

    Cursor-Specific Troubleshooting:

    • Ensure the MCP server is enabled in Settings > MCP.
    • MCP tools require the Agent chat profile (Cursor Pro or Business subscription).
    • Use "Yolo Mode" to automatically run MCP tool requests.
  8. Configure the GodotServer

    main

    Initialize the GodotServer class with an optional GodotServerConfig object to customize the MCP server behavior.

    Configuration Options:

    • godotPath (string): Path to the Godot executable. If not provided, the server attempts auto-detection.
    • debugMode (boolean): Enables debug logging to stderr.
    • godotDebugMode (boolean): Enables --debug-godot flag when executing Godot operations.
    • strictPathValidation (boolean): If true, the server will throw an error if it cannot find a valid Godot executable. If false, it falls back to common default paths (which may fail).
  9. Configure the GODOT_PATH environment variable

    main

    The Godot MCP server requires a valid path to the Godot executable. If the server cannot automatically detect it, you must set the GODOT_PATH environment variable.

    If strictPathValidation is enabled in the server configuration, the server will exit if the provided path is invalid.

  10. Add a node to a scene

    main

    Adds a new node to an existing Godot scene.

    Arguments:

    • projectPath (required): Path to the project.
    • scenePath (required): Path to the target scene file.
    • nodeType (required): Built-in Godot class name (e.g., Sprite2D).
    • nodeName (required): The name of the new node.
    • parentNodePath (optional): Path to the parent node within the scene.
    • properties (optional): An object containing properties to set on the new node.
  11. List available Godot MCP tools

    main

    The Godot MCP server exposes several tools for interacting with Godot projects. Key tools include:

    • launch_editor: Launches the Godot editor for a specific project.
    • run_project: Runs the Godot project (headless or with a specific scene) and captures output.
    • get_debug_output: Retrieves current debug output and errors.
    • stop_project: Stops the currently running Godot process.
    • get_godot_version: Returns the installed Godot version.
    • list_projects: Searches a directory for Godot projects.
    • get_project_info: Retrieves metadata about a project.
    • create_scene: Creates a new .tscn file with a specified root node type.
    • add_node: Adds a node to an existing scene at a specific parent path.
    • load_sprite: Loads a texture into a Sprite2D node.
    • export_mesh_library: Exports a scene as a .res MeshLibrary.
    • save_scene: Saves changes to a scene file.
    • get_uid (Godot 4.4+): Gets the UID for a specific file.
    • update_project_uids (Godot 4.4+): Updates UID references by resaving resources.
  12. Export a MeshLibrary

    main

    Exports a .meshlib file from a Godot scene.

    Arguments:

    • projectPath (required): Path to the project.
    • scenePath (required): Path to the scene containing 3D meshes.
    • outputPath (required): Path where the library should be saved.
    • meshItemNames (optional): An array of specific mesh item names to include.