Skip to main content
Glama

Read the code and event binding of R3 Code components

r3_code_read
Read-onlyIdempotent

Read back what a Code component actually contains — its full JavaScript source and the event it runs on. r3_code_write reports what it wrote; this reports what is there.

Use it before replacing a script, so an edit builds on the real source instead of overwriting it blind, and after a write whose reply you did not see, to confirm what landed. Call it with NO entityRefs to get every Code component in the project — that is how you find a script again when you never received the entityRef for it.

Each script comes back with its codeVersion: pass it as r3_code_write's baseVersion. The event comes back as a NAME (RENDER_BEFORE, KEY_DOWN, …), which is the same form r3_code_write takes, so you can hand it straight back. r3_component_read reports the same field as a raw number and omits any source over 2000 characters; this is the tool for reading code.

Name ONE entityRef to read it in pages (offset / length): every script comes back with totalChars, the sha256 of its WHOLE source, and truncated / nextOffset. When truncated is true you have only part of it: read on from nextOffset, join the pages and check the sha256 before writing it back. Reading several, a body longer than one page is left out WHOLE and named with its size — never cut silently, because a partial script written back would delete the rest of it. An entityRef that does not exist is named and the others are still read.

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_code_read"
  }
}

Input Schema

NameRequiredDescriptionDefault
lengthNoHow many characters to read at most (default and maximum 60000; 8000 in an R3 Builder session). A page ends on a whole line when it can.
offsetNoWhere to start reading, in characters (default 0). For the next page pass the nextOffset of the previous answer.
projectIdYesThe project to read from, from r3_project_create or r3_project_load.
entityRefsNoWhich Code components to read, e.g. ["spin"]. Omit for ALL of them. Up to 50 per call.

Output Schema

NameRequiredDescriptionDefault
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.
projectIdYes
componentsYes
unreadableYes
projectNameYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed9 schema fields changed
    • addedInput schema / properties / length
      Added value: +{
      +  "description": "How many characters to read at most (default and maximum 60000; 8000 in an R3 Builder session). A page ends on a whole line when it can.",
      +  "exclusiveMinimum": 0,
      +  "maximum": 60000,
      +  "type": "integer"
      +}
    • addedInput schema / properties / offset
      Added value: +{
      +  "description": "Where to start reading, in characters (default 0). For the next page pass the nextOffset of the previous answer.",
      +  "maximum": 9007199254740991,
      +  "minimum": 0,
      +  "type": "integer"
      +}
    • addedOutput schema / properties / components / items / properties / length
      Added value: +{
      +  "type": "number"
      +}
    • addedOutput schema / properties / components / items / properties / nextOffset
      Added value: +{
      +  "type": [
      +    "number",
      +    "null"
      +  ]
      +}
    • addedOutput schema / properties / components / items / properties / offset
      Added value: +{
      +  "type": "number"
      +}
    • addedOutput schema / properties / components / items / properties / sha256
      Added value: +{
      +  "type": "string"
      +}
    • addedOutput schema / properties / components / items / properties / totalChars
      Added value: +{
      +  "type": "number"
      +}
    • addedOutput schema / properties / components / items / properties / truncated
      Added value: +{
      +  "type": "boolean"
      +}
    • changedOutput schema / properties / components / items / required
      Previous value: -[
      -  "entityRef",
      -  "name",
      -  "id",
      -  "event",
      -  "fileName",
      -  "enabled",
      -  "code",
      -  "codeVersion",
      -  "changedBy",
      -  "changedAt",
      -  "notes",
      -  "imports"
      -]New value: +[
      +  "entityRef",
      +  "name",
      +  "id",
      +  "event",
      +  "fileName",
      +  "enabled",
      +  "code",
      +  "offset",
      +  "length",
      +  "totalChars",
      +  "sha256",
      +  "truncated",
      +  "nextOffset",
      +  "codeVersion",
      +  "changedBy",
      +  "changedAt",
      +  "notes",
      +  "imports"
      +]
  2. Changed2 schema fields changed
    • addedOutput schema / properties / components / items / properties / imports
      Added value: +{
      +  "items": {
      +    "additionalProperties": false,
      +    "properties": {
      +      "error": {
      +        "type": [
      +          "string",
      +          "null"
      +        ]
      +      },
      +      "latestVersion": {
      +        "type": [
      +          "number",
      +          "null"
      +        ]
      +      },
      +      "moduleId": {
      +        "type": [
      +          "string",
      +          "null"
      +        ]
      +      },
      +      "name": {
      +        "type": "string"
      +      },
      +      "pinned": {
      +        "type": "boolean"
      +      },
      +      "version": {
      +        "type": [
      +          "number",
      +          "null"
      +        ]
      +      }
      +    },
      +    "required": [
      +      "name",
      +      "moduleId",
      +      "version",
      +      "latestVersion",
      +      "pinned",
      +      "error"
      +    ],
      +    "type": "object"
      +  },
      +  "type": "array"
      +}
    • changedOutput schema / properties / components / items / required
      Previous value: -[
      -  "entityRef",
      -  "name",
      -  "id",
      -  "event",
      -  "fileName",
      -  "enabled",
      -  "code",
      -  "codeVersion",
      -  "changedBy",
      -  "changedAt",
      -  "notes"
      -]New value: +[
      +  "entityRef",
      +  "name",
      +  "id",
      +  "event",
      +  "fileName",
      +  "enabled",
      +  "code",
      +  "codeVersion",
      +  "changedBy",
      +  "changedAt",
      +  "notes",
      +  "imports"
      +]
  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",
      -  "projectName",
      -  "components",
      -  "unreadable"
      -]New value: +[
      +  "projectId",
      +  "projectName",
      +  "components",
      +  "unreadable",
      +  "answer"
      +]
  4. First observed

TDQS

A4.7/5.0
Behavior4/5

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

Annotations already declare readOnly/idempotent/non-destructive, and the description still adds real behavior: paging with totalChars, whole-source sha256, truncated/nextOffset, and the rule that multi-read omits an over-long body whole rather than silently cutting it. It also discloses that a nonexistent entityRef is named while the rest are still read. It never states rate limits or auth scope, but for a read tool that is minor.

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?

Purpose is front-loaded and the paragraphs are ordered sensibly (what it is, when to use, return shape, paging, error behavior). It is long, and the sha256/join-pages instruction partly overlaps with the offset/length parameter descriptions, but almost every sentence carries non-redundant 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?

Even though an output schema exists, the description explains the fields that matter for correct usage (codeVersion as baseVersion, nextOffset continuation, sha256 verification, whole-body omission on multi-read). Combined with 100% schema coverage and read-only annotations, nothing an agent needs to call this correctly is missing.

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?

Schema coverage is 100%, yet the description adds semantics the schema cannot: omitting entityRefs means every Code component in the project, while naming exactly ONE switches the call into offset/length paging mode. That mode-switch rule is essential and entirely absent from the schema.

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: reading back a Code component's full JavaScript source and its event binding. It explicitly separates itself from r3_code_write (which reports what it wrote, not what exists) and r3_component_read (raw numeric event field, source omitted over 2000 chars), so an agent can choose without opening schemas.

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 states two concrete moments to use it: before replacing a script so an edit builds on real source, and after an unseen write reply to confirm what landed. It also names the pass-through consumer (r3_code_write's baseVersion) and gives the explicit no-entityRefs mode for locating scripts when the entityRef is unknown.

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