Skip to main content
Glama

Run new code LIVE in the user's open R3 editor

r3_editor_code
Destructive

The same tool as r3_code_write (this is its older name): replace a Code component's code, kept at once in the project's live copy: every R3 tab with the project open runs the new code now, no editor needed and nothing to save. Name it with componentId or entityRef and pass baseVersion, the codeVersion r3_code_read answered: code is never merged, so on an older version it is refused with the current code and version (apply your change to that and call again). A long script can be PATCHED instead: replacements + baseSha256, as r3_code_write takes them. The code is a FUNCTION BODY (a top-level return {start, update};); read r3_docs_read("CODE_PATTERNS.md") for the R3 APIs. A syntax error or an R3 API that does not exist is refused before anything is kept.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "projectId": "<projectId>"
    },
    "name": "r3_editor_code"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeNoThe whole new code (a function body). Omit it when you send replacements.
entityRefNoOr its entityRef, e.g. "code_spin".
projectIdYesThe project (r3_project_list).
baseSha256NoWith replacements only: the sha256 r3_code_read answered for the script (of its WHOLE code) at baseVersion.
baseVersionNoREQUIRED: the codeVersion r3_editor_inspect gave for this Code component (the version your code builds on); null for one never saved (codeVersion null).
componentIdNoThe Code component's id.
replacementsNoInstead of code: exact replacements on the script at baseVersion, in order, all or nothing (at most 200, 60000 characters of old + new in all).

Output Schema

NameRequiredDescriptionDefault
seqNo
liveYes
nameYes
errorYes
savedYes
answerYesThis answer in words: what was done, what R3 measured, decided or refused, and what to do next. The same text as the result's text block. Read it: the fields beside it are the data, this is the guidance.
editorYes
sha256Yes
compiledYes
warningsYes
entityRefYes
projectIdYes
totalCharsYes
codeVersionYes
componentIdYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed7 schema fields changed
    • addedInput schema / properties / baseSha256
      Added value: +{
      +  "description": "With replacements only: the sha256 r3_code_read answered for the script (of its WHOLE code) at baseVersion.",
      +  "pattern": "^[0-9a-f]{64}$",
      +  "type": "string"
      +}
    • changedInput schema / properties / code / description
      Previous value: -"The whole new code (a function body)."New value: +"The whole new code (a function body). Omit it when you send replacements."
    • addedInput schema / properties / replacements
      Added value: +{
      +  "description": "Instead of code: exact replacements on the script at baseVersion, in order, all or nothing (at most 200, 60000 characters of old + new in all).",
      +  "items": {
      +    "properties": {
      +      "count": {
      +        "description": "How many times old occurs, all replaced (default 1).",
      +        "maximum": 9007199254740991,
      +        "minimum": 1,
      +        "type": "integer"
      +      },
      +      "new": {
      +        "description": "What replaces it (empty deletes it). Taken literally.",
      +        "maxLength": 60000,
      +        "type": "string"
      +      },
      +      "old": {
      +        "description": "Exact text in the script (whitespace and line breaks count).",
      +        "maxLength": 60000,
      +        "minLength": 1,
      +        "type": "string"
      +      }
      +    },
      +    "required": [
      +      "old",
      +      "new"
      +    ],
      +    "type": "object"
      +  },
      +  "maxItems": 200,
      +  "minItems": 1,
      +  "type": "array"
      +}
    • changedInput schema / required
      Previous value: -[
      -  "projectId",
      -  "code"
      -]New value: +[
      +  "projectId"
      +]
    • addedOutput schema / properties / sha256
      Added value: +{
      +  "type": "string"
      +}
    • addedOutput schema / properties / totalChars
      Added value: +{
      +  "maximum": 9007199254740991,
      +  "minimum": -9007199254740991,
      +  "type": "integer"
      +}
    • changedOutput schema / required
      Previous value: -[
      -  "projectId",
      -  "componentId",
      -  "entityRef",
      -  "name",
      -  "compiled",
      -  "error",
      -  "warnings",
      -  "live",
      -  "saved",
      -  "codeVersion",
      -  "editor",
      -  "answer"
      -]New value: +[
      +  "projectId",
      +  "componentId",
      +  "entityRef",
      +  "name",
      +  "compiled",
      +  "error",
      +  "warnings",
      +  "live",
      +  "saved",
      +  "codeVersion",
      +  "editor",
      +  "sha256",
      +  "totalChars",
      +  "answer"
      +]
  2. Changed1 schema field changed
    • changedOutput schema / properties / editor / anyOf
      Previous value: -[
      -  {
      -    "additionalProperties": false,
      -    "properties": {
      -      "lastActiveAgoMs": {
      -        "type": "number"
      -      },
      -      "lastActiveAt": {
      -        "type": "string"
      -      },
      -      "openProjects": {
      -        "anyOf": [
      -          {
      -            "items": {
      -              "additionalProperties": false,
      -              "properties": {
      -                "id": {
      -                  "type": "string"
      -                },
      -                "name": {
      -                  "type": [
      -                    "string",
      -                    "null"
      -                  ]
      -                }
      -              },
      -              "required": [
      -                "id",
      -                "name"
      -              ],
      -              "type": "object"
      -            },
      -            "type": "array"
      -          },
      -          {
      -            "type": "null"
      -          }
      -        ]
      -      },
      -      "openedAt": {
      -        "type": [
      -          "string",
      -          "null"
      -        ]
      -      }
      -    },
      -    "required": [
      -      "openedAt",
      -      "lastActiveAt",
      -      "lastActiveAgoMs",
      -      "openProjects"
      -    ],
      -    "type": "object"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]New value: +[
      +  {
      +    "additionalProperties": false,
      +    "properties": {
      +      "frames": {
      +        "anyOf": [
      +          {
      +            "additionalProperties": false,
      +            "properties": {
      +              "advancing": {
      +                "type": "boolean"
      +              },
      +              "frameSeen": {
      +                "type": "boolean"
      +              },
      +              "sceneShown": {
      +                "type": "boolean"
      +              },
      +              "visible": {
      +                "type": "boolean"
      +              }
      +            },
      +            "required": [
      +              "advancing",
      +              "visible",
      +              "sceneShown",
      +              "frameSeen"
      +            ],
      +            "type": "object"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ]
      +      },
      +      "lastActiveAgoMs": {
      +        "type": "number"
      +      },
      +      "lastActiveAt": {
      +        "type": "string"
      +      },
      +      "openProjects": {
      +        "anyOf": [
      +          {
      +            "items": {
      +              "additionalProperties": false,
      +              "properties": {
      +                "id": {
      +                  "type": "string"
      +                },
      +                "name": {
      +                  "type": [
      +                    "string",
      +                    "null"
      +                  ]
      +                }
      +              },
      +              "required": [
      +                "id",
      +                "name"
      +              ],
      +              "type": "object"
      +            },
      +            "type": "array"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ]
      +      },
      +      "openedAt": {
      +        "type": [
      +          "string",
      +          "null"
      +        ]
      +      }
      +    },
      +    "required": [
      +      "openedAt",
      +      "lastActiveAt",
      +      "lastActiveAgoMs",
      +      "openProjects"
      +    ],
      +    "type": "object"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
  3. Changed2 schema fields changed
    • addedOutput schema / properties / answer
      Added value: +{
      +  "description": "This answer in words: what was done, what R3 measured, decided or refused, and what to do next. The same text as the result's text block. Read it: the fields beside it are the data, this is the guidance.",
      +  "type": "string"
      +}
    • changedOutput schema / required
      Previous value: -[
      -  "projectId",
      -  "componentId",
      -  "entityRef",
      -  "name",
      -  "compiled",
      -  "error",
      -  "warnings",
      -  "live",
      -  "saved",
      -  "codeVersion",
      -  "editor"
      -]New value: +[
      +  "projectId",
      +  "componentId",
      +  "entityRef",
      +  "name",
      +  "compiled",
      +  "error",
      +  "warnings",
      +  "live",
      +  "saved",
      +  "codeVersion",
      +  "editor",
      +  "answer"
      +]
  4. First observed

TDQS

A4.3/5.0
Behavior3/5

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

Annotations already declare destructiveHint=true, readOnlyHint=false, idempotentHint=false and openWorldHint=true, so the mutation risk profile is covered structurally. The description adds real value beyond that: live propagation to all open tabs, no-save persistence, optimistic concurrency with the current code echoed back on refusal, and pre-commit validation of syntax and R3 API existence. It stops short of describing the return payload or what happens to concurrent writers mid-flight, so 3 rather than 4.

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-loaded with the identity/alias statement before mechanics, and nearly every clause carries information (live semantics, version gate, patch mode, function-body shape, validation). It is dense and parenthetical-heavy, with the version-refusal clause running long, so it is efficient but not maximally clean.

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

Completeness4/5

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

For a destructive, 7-param mutation tool with a 100% covered schema and a declared output schema, the description covers the decisions an agent must make: addressing, versioning, patch vs full write, and failure recovery. The only completeness gap is the conflicting source for baseVersion (r3_code_read vs r3_editor_inspect), which could send an agent to the wrong sibling.

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 description genuinely enriches meaning: it explains that code is a function body with a top-level return, that baseVersion is the version the change builds on (null when never saved), and how replacements, baseSha256 and code are mutually exclusive. One flaw: it sources baseVersion from r3_code_read while the schema says r3_editor_inspect, a cross-tool inconsistency that slightly undermines the added semantics.

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 concrete verb+resource ("replace a Code component's code") and immediately scopes it as a live replace that runs in every open R3 tab with no save step. It also explicitly names its alias r3_code_write so the agent can tell the two apart, and indirectly distinguishes itself from the read path r3_code_read.

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?

Gives explicit selection rules: use componentId or entityRef, always pass baseVersion obtained from the read tool, and use replacements+baseSha256 instead of full code for long scripts. It also points to r3_docs_read("CODE_PATTERNS.md") for API knowledge and states the refusal path when the version is stale, which tells the agent exactly how to recover by re-applying to the returned code.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources