Skip to main content
Glama

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?}.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes
fileYes
positionNoend
auto_compileNo
project_pathYes
auto_cjk_fontNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.4.0

TDQS

A4.5/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the burden and does well: it discloses auto-creation of missing files, BOM preservation, that auto_compile triggers a compile after writing, and that auto_cjk_font causes font side effects, plus the return dict shape. It could go further on overwrite/replace semantics being destructive and any permission requirements, but the behavioral disclosure is substantially above baseline.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loads the core purpose, then uses a clean Args/Returns structure with the position modes listed inline. It is somewhat long, but nearly every sentence (auto-create, BOM, side effects) earns its place, so waste is minimal.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with no annotations and no output schema, the description is complete: it covers file creation behavior, encoding handling, the full parameter surface, and explains the return dict keys. Nothing an agent needs to call it correctly is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, so the description must compensate and it does: it defines each parameter and enumerates all seven 'position' modes (end/top/inside/after/before/replace/replace_all) with their exact meaning, plus the defaults and side-effect intent of auto_compile and auto_cjk_font. This adds meaning far beyond the bare schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb+resource ('inject arbitrary Ren'Py code into a project file') and explicitly positions itself as the 'universal escape hatch' tool. An agent can immediately tell this apart from siblings like tool_auto_fix, tool_compile_project, and tool_read_script, which are narrower.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives concrete use cases (define characters, declare images, create screens, add dialogue, write init python blocks) and frames itself as the fallback when other tools don't cover a need. It stops short of naming the specific siblings it supersedes or a when-not-to-use condition, so it is clear but not fully directive.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.