Skip to main content
Glama
EL4CTEO

Roblox Studio MCP

Edit scripts

script_edit
Destructive

Apply batched find/replace, line-range, or full-source edits to Luau scripts in Roblox Studio, with revision checks and atomic all-or-nothing writes so stale changes are rejected.

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".
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`.
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.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"
      -]
  2. 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"
      +}
  3. 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"
      +}
  4. First observedv0.1.8

TDQS

A5/5.0
Behavior5/5

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

The description goes far beyond annotations, detailing all-or-nothing batch semantics, mode-specific failure conditions (non-unique find, STALE_SCRIPT), revision-based concurrency control, writes through ScriptEditorService with undo behavior, live vs studio differences, and effects on running servers. It even explains that `source` discards user changes. No contradiction with annotations; instead it enriches them.

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?

The description is long but every sentence earns its place—no filler. It is front-loaded with the core purpose, then systematically covers batch behavior, modes, revision, live target, and server effects. The structure is logical and scannable, with clear section breaks.

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?

Given the tool's complexity (multiple modes, live vs studio, concurrency), the description is remarkably complete. It covers failure modes, undo scope, server rollout, prerequisites, and even notes the returned `rev` for follow-up edits. There is no obvious gap an agent would need to fill.

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?

Even though schema coverage is 100%, the description adds critical meaning: it explains how modes correspond to parameter combinations (find/replace vs startLine/endLine vs source), clarifies `revision` as a concurrency guard, warns about `replaceAll` behavior, and describes `target="live"` constraints. It turns raw parameter descriptions into actionable guidance.

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 states a specific verb and resource ('Edits Luau source through the Studio script editor') and explicitly frames it as the tool for any change to existing code, which clearly distinguishes it from script_create (new scripts) and script_read (reading). The purpose is unambiguous and context-aware.

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?

It gives explicit when-to-use guidance ('any change to existing code'), explains the three edit modes with conditions for each, advises to batch related changes, and names the alternative tool (script_read) for reading. It also specifies when to use `target="live"` and prerequisites like `confirm: true`. Nothing is left to inference.

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