Format GDScript and C#, safely
godot_formatFormats GDScript and C# files to the official style guide without changing behavior, and skips any file whose tokens or build change, reporting the reason.
Instructions
Formats GDScript to the official style guide without changing what it means: tabs for indentation, no trailing spaces, one space around operators and after commas, none inside brackets, two blank lines around functions, one newline at the end. It keeps the lines as they are (nothing is wrapped, joined or reordered) and leaves strings, comments and node paths byte for byte. A guard compares the tokens before and after; when they differ, or the file is not valid GDScript (mixed indentation, conflict markers, an unclosed bracket), the file is skipped with the reason and never written. Default: list the files that would change; write: true writes them (godot_undo takes it back); diff: true shows the changes. C# files (.cs) are formatted by dotnet format with the project's .editorconfig, restricted to the requested files; it needs the .NET SDK (without it the C# files are skipped with that reason). The same promise holds: after formatting, the outline of each C# file (classes, members, signals, methods, calls, every string literal) must be the same as before and, when the project has a .csproj, it must still build; a file that fails either is put back and reported as skipped. A dry run of C# lists the files and how many lines would change (dotnet format --verify-no-changes); the checks and the diff come with write: true.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "godot_format"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| diff | No | show the changes as a unified diff | |
| path | No | project folder, or a file or folder inside it (relative to the server's folder; default: the current project) | |
| files | No | only these res:// files or folders (default: every .gd and .cs script, without addons) | |
| write | No | write the formatted files (default false: list what would change) | |
| include_addons | No | also format res://addons/ |