add_variable
Add a top-level variable or property declaration to a GDScript file in Godot 4 projects, supporting type hints, default values, and editor visibility options.
Instructions
Add a top-level variable or property declaration to a GDScript file.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"projectPath": "<projectPath>",
"scriptPath": "<scriptPath>",
"varName": "<varName>"
},
"name": "add_variable"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectPath | Yes | Absolute path to the project directory | |
| scriptPath | Yes | Script path (res:// or relative to project) | |
| varName | Yes | Variable name (valid GDScript identifier) | |
| type | No | Optional type hint, e.g. "float", "String", "Node2D" | |
| defaultVal | No | Optional default value expression, e.g. "300.0" or "Vector2.ZERO" | |
| exported | No | If true, adds @export annotation (makes variable visible in the editor) |