Skip to main content
Glama
EL4CTEO

Roblox Studio MCP

Edit scripts

script_edit
Destructive

Edit Luau scripts in Roblox Studio with batched literal find/replace, line ranges, or full rewrites. Batch applies only if every edit matches current source, preventing partial or stale changes.

Instructions

Edits Luau source through the Studio script editor. This is the tool to use for any change to existing code.

Every edit in one call is all-or-nothing: the whole batch is resolved against current source before anything is written, so if one edit cannot be applied nothing is. Batch related changes together, even across different scripts.

Each edit picks exactly one mode: find/replace — literal text, not a pattern. Preferred: it survives line numbers shifting. Fails if the text is not unique, unless you set replaceAll, so include enough surrounding lines to pin it down. startLine/endLine + replacement — for line ranges from script_read. Numbers refer to the file as you read it; several line edits to one script are applied bottom-up so they do not shift each other. source — replaces the whole script. Only for small files or a rewrite; it discards anything the user changed since you read it.

Pass revision on every edit. script_read prints it as rev beside each file, and sending it back makes the write conditional: if the script changed since you read it the batch is refused with STALE_SCRIPT and nothing is written. Without it the edit is applied blind, which matters most for the two modes that cannot notice: a line range still applies cleanly to source somebody else moved, it just lands on the wrong lines, and source discards their work entirely. Another agent editing the same place, or the user typing in the editor, is enough.

Writes go through ScriptEditorService:UpdateSourceAsync, so an open editor tab updates in place and unsaved work is preserved. Undo for source changes is the script editor's own, per script — Ctrl+Z in a script tab reverts that script, not the whole batch.

target="live" edits the PUBLISHED place instead. It takes ONE edit, it replaces the whole source rather than finding and replacing, and there is no undo of any kind — so read the script with script_read target="live" first and send back the whole thing. Needs confirm: true.

It changes the SAVED place, not running servers: people already playing keep the old code until their server empties. Follow it with universe op="restart" to roll them over.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNolive only: the script, e.g. "ServerScriptService.Main".
editsYesEdits to apply together as one undoable step.
sourceNolive only: the complete new source.
targetNo'studio' edits the open place. 'live' rewrites a script in the published place over Open Cloud — one file, whole source, no undo.studio
confirmNoRequired for target="live".
placeIdNolive only: omit to use `cloud place`.
studioIdNoTarget Studio; omit for the active one.
universeIdNolive only: omit to use `cloud universe`.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed7 schema fields changedv0.6.8
    • addedInput schema / properties / confirm
      Added value: +{
      +  "description": "Required for target=\"live\".",
      +  "type": "boolean"
      +}
    • removedInput schema / properties / edits / minItems
      Removed value: -1
    • addedInput schema / properties / path
      Added value: +{
      +  "description": "live only: the script, e.g. \"ServerScriptService.Main\".",
      +  "type": "string"
      +}
    • addedInput schema / properties / placeId
      Added value: +{
      +  "description": "live only: omit to use `cloud place`.",
      +  "type": "string"
      +}
    • addedInput schema / properties / source
      Added value: +{
      +  "description": "live only: the complete new source.",
      +  "type": "string"
      +}
    • addedInput schema / properties / target
      Added value: +{
      +  "default": "studio",
      +  "description": "'studio' edits the open place. 'live' rewrites a script in the published place over Open Cloud — one file, whole source, no undo.",
      +  "enum": [
      +    "studio",
      +    "live"
      +  ],
      +  "type": "string"
      +}
    • addedInput schema / properties / universeId
      Added value: +{
      +  "description": "live only: omit to use `cloud universe`.",
      +  "type": "string"
      +}
  2. Changed1 schema field changedv0.4.5
    • addedInput schema / properties / edits / items / properties / revision
      Added value: +{
      +  "description": "The `rev` value script_read printed for this file. Pass it and the edit is refused if the script changed since you read it, instead of being applied to source you have not seen.",
      +  "type": "string"
      +}
  3. First observedv0.1.8

TDQS

A4.8/5.0
Behavior5/5

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

The description goes far beyond the annotations. It discloses all-or-nothing batch semantics, the STALE_SCRIPT conditional write behavior, bottom-up line edit application, the fact that source replacement discards user changes, the live target's one-edit whole-source no-undo behavior, the fact that it changes the saved place not running servers, and the undo behavior via ScriptEditorService. This is exemplary behavioral disclosure. The annotations (destructiveHint=true, readOnlyHint=false) are consistent with the description's emphasis on destructive potential.

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?

The description is long but every section earns its place. It is front-loaded with the core purpose, then organized by edit mode, then revision semantics, then live target, then deployment caveats. It is dense but not redundant. It could arguably be tightened, but the complexity of the tool (three edit modes, two targets, revision safety) justifies the length. The structure with clear paragraphs and mode labels helps an agent parse it.

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 tool with 8 parameters, no output schema, and complex semantics, the description covers everything an agent needs to call it correctly: the three edit modes, the revision requirement, the live target's special constraints, the all-or-nothing batch behavior, and the post-edit restart guidance. The only thing not described is the return value, but there is no output schema and the description's focus on behavior is more important for correct invocation. The description is complete for the tool's complexity.

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 100%, so the baseline is 3. The description adds significant meaning beyond the schema: it explains the three edit modes (find/replace, startLine/endLine, source) and how they relate to the parameters, clarifies that find is literal not a pattern, explains the uniqueness requirement and replaceAll, explains the revision parameter's role in conditional writes, and clarifies the live-only parameters. It doesn't document every parameter individually, but the schema already does that. The description adds mode-level semantics that the schema lacks.

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?

The description opens with a specific verb and resource: 'Edits Luau source through the Studio script editor' and immediately states it is the tool for any change to existing code. It distinguishes itself from siblings like script_create (creation) and script_read (reading) by framing itself as the editing tool for existing code.

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

Usage Guidelines5/5

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

The description gives explicit when-to-use guidance: 'This is the tool to use for any change to existing code.' It also provides clear alternatives and exclusions: it mentions script_read for reading, and contrasts with live target behavior. It explains when to use find/replace vs line ranges vs source replacement, and when to use target='live' with confirm:true. It even tells the agent to follow with universe op='restart' for live changes. This is comprehensive usage guidance.

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