Skip to main content
Glama

Update C# Script

unity_update_script
Idempotent

Replaces an exact text block in a Unity script with new content, failing unless the old text occurs the specified number of times. Read the script first, then apply a focused diff.

Instructions

Replace an exact text block in a script (like a focused diff hunk). Fails unless old_text occurs exactly expected_occurrences times.

Workflow: unity_read_script first, copy old_text verbatim (whitespace matters), then call with new_text. Returns { path, replaced, total_lines }. Unity recompiles after the change — check console for errors.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesProject-relative script path, e.g. 'Assets/Scripts/PlayerController.cs'
new_textYesReplacement text (can be empty string to delete)
old_textYesExact text block to replace (copy from unity_read_script)
expected_occurrencesNoHow many occurrences of old_text must exist (default 1; fails otherwise)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.5/5.0
Behavior4/5

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

Goes beyond the annotations by disclosing the exact failure condition ('Fails unless old_text occurs exactly expected_occurrences times'), the return shape ({ path, replaced, total_lines }), and the side effect that Unity recompiles after the change with a nudge to check the console. Annotations already cover the safety profile (readOnlyHint=false, destructiveHint=false, idempotentHint=true), so this added failure/side-effect context is the valuable increment. It does not mention permission or concurrency considerations.

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

Conciseness5/5

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

Three tight sentences, front-loaded with the core behavior, then a labeled Workflow line, then the return/side-effect note. No filler; every sentence carries actionable information.

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 annotations present and no output schema, the description covers purpose, sequencing, failure mode, return shape, and post-call side effects. Nothing an agent needs to invoke it correctly is missing.

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

Parameters4/5

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

Schema coverage is already 100%, so the baseline is 3. The description adds meaning beyond the schema by stressing that old_text must match exactly ('copy old_text verbatim (whitespace matters)') and by explaining that expected_occurrences acts as a match-count guard that causes failure, reinforcing the per-parameter contract.

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 ('Replace an exact text block in a script') and clarifies the mechanism with a memorable analogy ('like a focused diff hunk'). This clearly distinguishes it from siblings like unity_read_script, unity_create_script, and unity_execute_code, which could otherwise seem like overlapping ways to modify code.

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?

The 'Workflow' line gives concrete when-to-use guidance: call unity_read_script first, copy old_text verbatim (whitespace matters), then call this tool. This sequences the tool against a named sibling. It stops short of explicit exclusions (e.g. when to prefer unity_execute_code or unity_create_script instead), so it is strong but not exhaustive.

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