Skip to main content
Glama
EL4CTEO

Roblox Studio MCP

Edit scripts

script_edit
Destructive

Edit existing Luau code in Roblox Studio's script editor. Apply batched, all-or-nothing changes with revision checks so stale or conflicting writes are refused.

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. Line-range and source edits REQUIRE it (NEEDS_REVISION otherwise), because they cannot notice a change: a line range lands on whatever moved into those lines, and source discards the other side's work. Another agent editing the same place, or the user typing in the editor, is enough. find/replace works without it.

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, with its rev as revision so the write is refused if someone published in between. 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

NameRequiredDescriptionDefault
pathNolive only: the script, e.g. "ServerScriptService.Main".
editsNoEdits to apply together as one undoable step. Required unless target is "live". The result carries each script's new `rev`, so a follow-up edit needs no re-read.
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`.
revisionNolive only, required: the `rev` `script_read target="live"` printed. The write is refused if the published script changed since.
studioIdNoTarget Studio; omit for the active one.
universeIdNolive only: omit to use `cloud universe`.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv0.9.5
    • changedInput schema / properties / edits / items / properties / revision / description
      Previous value: -"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."New value: +"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. Required for line-range and `source` edits."
    • changedInput schema / properties / revision / description
      Previous value: -"live only: the `rev` `script_read target=\"live\"` printed. The write is refused if the published script changed since. Always pass it."New value: +"live only, required: the `rev` `script_read target=\"live\"` printed. The write is refused if the published script changed since."
  2. Changed1 schema field changedv0.9.1
    • addedInput schema / properties / revision
      Added value: +{
      +  "description": "live only: the `rev` `script_read target=\"live\"` printed. The write is refused if the published script changed since. Always pass it.",
      +  "type": "string"
      +}
  3. Changed2 schema fields changedv0.7.0
    • changedInput schema / properties / edits / description
      Previous value: -"Edits to apply together as one undoable step."New value: +"Edits to apply together as one undoable step. Required unless target is \"live\". The result carries each script's new `rev`, so a follow-up edit needs no re-read."
    • removedInput schema / required
      Removed value: -[
      -  "edits"
      -]
  4. 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"
      +}
  5. 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"
      +}
  6. First observedv0.1.8

TDQS

A4.8/5.0
Behavior5/5

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

Goes well beyond the annotations (destructiveHint=true, non-idempotent): discloses all-or-nothing batch semantics, the STALE_SCRIPT refusal and why line-range/source edits require revision, that undo is per-script via the editor's own Ctrl+Z, that live mode has no undo and needs confirm, and that the write affects the saved place not running servers. This is exactly the extra context the annotations cannot carry.

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 statement and organizes the rest into scannable mode/revision/live sections; nearly every sentence carries unique information. It is nonetheless long, with the revision contract restated in prose and again in the schema, which costs a point.

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 9-parameter, multi-mode mutation tool with no output schema, the description covers the mutation contract, error conditions (STALE_SCRIPT, NEEDS_REVISION), undo behavior, the live sub-path, and even the return of a new `rev` for follow-up edits. 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.

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, but the prose adds genuine meaning: the one-mode-per-edit exclusivity rule, that line-range edits to one script apply bottom-up, that replaceAll overrides the uniqueness check, and what revision does when sent. It stops short of being a full substitute for the schema's per-field detail, so not a 5.

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 and resource ('Edits Luau source through the Studio script editor') and immediately scopes it ('the tool to use for any change to existing code'), which cleanly separates it from script_create, script_read, and script_grep among the siblings.

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?

Explicitly routes among three edit modes (find/replace, line-range, whole-source), names the conditions that select each ('Preferred: it survives line numbers shifting', 'Only for small files or a rewrite'), and explains when to use target="live" versus the default studio path plus the required follow-up with universe op="restart".

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