add_script_function
Append a new function to a GDScript file in Godot projects. Specify parameters, return type, and body to add functionality while preventing duplicates.
Instructions
Append a new function to a GDScript file. Fails if the function already exists.
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>",
"funcName": "<funcName>",
"body": "<body>"
},
"name": "add_script_function"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectPath | Yes | Absolute path to the project directory | |
| scriptPath | Yes | Script path (res:// or relative to project) | |
| funcName | Yes | Function name (valid GDScript identifier) | |
| params | No | Parameter list string, e.g. "delta: float, speed := 5.0" (empty string for none) | |
| body | Yes | Function body (unindented — tabs will be added automatically). Use newlines between statements. | |
| returnType | No | Optional return type annotation, e.g. "void" or "bool" | |
| isStatic | No | Whether to declare the function as static (default: false) |