gdcorrect · godot-correctness-mcp

Catch broken GDScript, scenes, and resource paths before they reach a playtest.

gdcorrect statically checks Godot 4 projects: GDScript lint rules, .tscn and project.godot validation, dangling paths in .tres registries, and API removed between Godot 4.4 and 4.7.

It runs headless and offline. No editor, no Godot binary, no network. The same checks are available to AI coding assistants as an MCP server.

  • Node.js 22 or newer
  • Godot 4.4 to 4.7 API data, GDScript only
  • Version 0.4.0 on npm as @tmhs/godot-correctness-mcp

.github/workflows/godot-correctness.yml

jobs:
  correctness:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: 22 }
      - name: Lint GDScript (fails on error-severity findings)
        run: npx -y -p @tmhs/godot-correctness-mcp@^0.4 gdcorrect lint . --format json
      # Only checks something once registryDirs is set in godot-correctness.config.json.
      - name: Validate registries
        run: npx -y -p @tmhs/godot-correctness-mcp@^0.4 gdcorrect validate-registries . --format json

Add it to CI

The job above fails when any error-severity finding is present. On a project with existing findings, gate only on new ones, and send findings to pull requests as annotations.

Adopt on an existing project

Record today's findings once and commit the file. CI then fails only on findings that are not in it.

gdcorrect report . --write-baseline gdcorrect-baseline.json   # commit this file
gdcorrect report . --baseline gdcorrect-baseline.json         # in CI

Findings match by rule, file, and the text of the flagged line, so edits that only shift lines keep matching. Fixed findings show up as stale entries; rewrite the baseline to drop them.

Lint only what changed

gdcorrect lint . --changed-since origin/main
gdcorrect lint . --files player.gd,enemy.gd

--changed-since includes uncommitted and untracked files, which suits pre-commit hooks.

Annotate pull requests with SARIF

Upload SARIF 2.1.0 to GitHub code scanning. Run from the repository root so paths line up.

    permissions:
      contents: read
      security-events: write
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: 22 }
      - name: gdcorrect (SARIF)
        run: npx -y -p @tmhs/godot-correctness-mcp@^0.4 gdcorrect report . --format sarif > gdcorrect.sarif
        continue-on-error: true   # let the upload step run; code scanning gates the PR
      - uses: github/codeql-action/upload-sarif@v3
        with: { sarif_file: gdcorrect.sarif }

What it checks

Detection is deliberately conservative: in a CI gate a false positive costs more than a miss. Every rule can be disabled or given a different severity in godot-correctness.config.json, and silenced per line with # gdcorrect-ignore[rule-id]. Full lint reference.

GDScript lint rules

RuleDefaultFlags
delta-misuseerrorvelocity = speed * delta in a function that calls move_and_slide(), which already applies frame timing. Also, at info: position or rotation changed in _process with no delta.
get-node-in-processwarning$ or get_node() lookups inside _process / _physics_process, run every frame.
missing-onreadywarningA class-level member initialized from a node path without @onready. Fixable with --fix.
untyped-declarationwarningvar x = ... with neither a type hint nor :=.
await-misusewarningawait applied to a literal value.
removed-api-usagewarningEngine API removed in the Godot version your project.godot declares, calls whose argument count became invalid, and overrides of virtuals that were removed or changed arity.
stringly-nodepathinfoA string-literal node path passed to get_node(), NodePath() and similar, which breaks on rename.
connect-without-disconnectinfoconnect() in _ready() with no disconnect() anywhere and no CONNECT_ONE_SHOT.
float-grid-equalityinfo== / != against a float literal or a Vector2/3/4(...).

Scenes, project settings, and registries

CheckDefaultFlags
registry-dangling-patherrorA string property in a .tres registry that looks like a resource path and points at a missing file. Enabled by listing registryDirs in the config.
registry-script-missingerrorA registry resource whose script resolves to no existing .gd (by uid first, then path).
scene-ext-resource-missingerrorAn ext_resource path that does not resolve to a file.
scene-node-parent-missingerrorA [node parent="..."] that names no node in the scene.
scene-connection-method-missingerrorA [connection] to a method the target node's script does not have.
scene-node-path-missingwarningA literal $A/B or get_node("A/B") that resolves in none of the scenes the script is attached to.
project-main-scene-missingerrorrun/main_scene points at a missing scene.
project-autoload-missingerrorAn [autoload] entry points at a missing file.
project-input-action-undefinedwarningAn action name passed to Input.is_action_* and similar that is not defined in [input].

Also: duplicate and undeclared resource ids, stale or mismatched uid:// references, malformed input actions, and registry parse errors. Every scene, project, and registry check.

CLI

gdcorrect <command> <projectPath> [options]. Commands: lint, validate-scenes, validate-project, validate-registries, report (lint plus every scene, project, and registry check), and rules (every rule id with its default and project severity).

OptionMeaning
--format json|pretty|sarifOutput format, default json. sarif is SARIF 2.1.0 for code scanning.
--fail-on error|warning|info|noneLowest severity that fails the run, default error.
--baseline <file>Report only findings that are not in the baseline.
--write-baseline <file>Record the current findings as the baseline and exit 0.
--fixlint only: apply machine-applicable fixes in place, then report what remains. Add --dry-run to print a diff instead.
--files a.gd,b.tscnCheck just these files. Scene checks also cover scenes that attach a given script.
--changed-since <git-ref>Check files changed since the ref, plus uncommitted and untracked ones (any command).

Exit codes

0
No findings at or above --fail-on.
1
At least one finding at or above --fail-on.
2
A usage, config, or tool error.

gdcorrect --help lists every command and option.

MCP server

Give an AI coding assistant the same checks, plus offline lookups into the Godot 4.4 to 4.7 API. Add this to your client's mcpServers config (Claude Desktop, Cursor, and others):

{
  "mcpServers": {
    "godot-correctness": {
      "command": "npx",
      "args": ["-y", "@tmhs/godot-correctness-mcp"]
    }
  }
}

Lint

  • lint_file
  • lint_project
  • list_rules

Scenes and project

  • validate_scenes
  • validate_project_config
  • validate_registries
  • project_report

Godot API

  • api_symbol_lookup
  • api_class_summary
  • api_diff

Server

  • server_info

lint_project, the validate_* tools, and project_report accept a baseline file written by gdcorrect --write-baseline. The server also exposes short GDScript guides as skill:// resources: data-driven resources, signal hygiene, typed GDScript, and preload vs load.

What it does not do

  • No live bridge. It never connects to a running editor or game. Use a live-session Godot MCP tool for that; this is the one for CI and headless pipelines.
  • No editor plugin. Nothing to install inside Godot.
  • No C#. GDScript only.
  • Nothing older than Godot 4.4. API data is pinned to 4.4 through 4.7.

License

CC-BY-NC-ND-4.0. The bundled tree-sitter-gdscript grammar and Godot API data are MIT-licensed upstream material; see THIRD_PARTY_NOTICES.md.