tool_exec_rpy
Inject any Ren'Py script code into a project file—define characters, images, screens, or labels—with optional positioning and automatic compilation.
Instructions
Inject arbitrary Ren'Py code into a project file.
This is the universal "escape hatch" tool. Use it to write any Ren'Py script code: define characters, declare images, create screens, add dialogue to labels, write init python blocks, etc.
If the target file doesn't exist, it will be auto-created. BOM is preserved when overwriting an existing file that has one.
Args: project_path: Absolute path to the Ren'Py project root directory. file: Target .rpy file, relative to project_path (e.g. "game/script.rpy"). code: Raw Ren'Py script code to inject. position: Where to place the code: - "end": Append at end of file (default) - "top": Prepend at start of file - "inside:": Insert at end of a label block - "after:": Insert right after a label block ends - "before:": Insert right before a label definition - "replace:<old_text>": Replace first occurrence of old_text with code - "replace_all:<old_text>": Replace ALL occurrences of old_text with code auto_compile: Whether to run compile_project after writing (default True). auto_cjk_font: If True and code contains CJK text, auto-configure a CJK font in gui.rpy. Defaults to False to avoid surprising side effects.
Returns: dict with {ok, message, compile_result, font_setup?, cjk_warning?}.
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": {
"project_path": "<project_path>",
"file": "<file>",
"code": "<code>"
},
"name": "tool_exec_rpy"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | ||
| file | Yes | ||
| position | No | end | |
| auto_compile | No | ||
| project_path | Yes | ||
| auto_cjk_font | No |