Skip to main content
Glama

edit_document

Change a document by committing an edit on base_version, which makes a new version. Give edits, exact replacements in the JSX get_document returned for base_version: each old_text must occur exactly once, spaces and line breaks included (copy it from that JSX, and include the node's id="..." to make it unique), and they apply in order. Or give jsx, the whole edited document: do that to add the first nodes to an empty document, whose <timeline ... /> closes itself. A document's JSX is laid out its own way, not as it was sent: each attribute on its own line and object keys sorted. So after every commit, call get_document before writing old_text. Long strings and arrays the JSX cut (Doc.cut, ...Doc.more) stay as they are when left in place. If another commit landed after base_version, this fails with version.conflict: read the document again and redo the edit.

How to write what most videos need (https://rendermate.com/docs/documents has the rest):

  • Every node has an id="...", unique and without /, and common={{start: 0, duration: 3, order: "a1"}}: its window in seconds, which may not reach past the canvas's duration, and its paint order among its siblings ("a0" is under "a1"). An order key's first letter sets how many digits follow it: a one, b two, c three, and so on, each digit 0-9, A-Z or a-z. So count "a0" to "az", then "b00" to "bzz"; "n001" is refused because n needs 14 digits. To put a node between "a1" and "a2", add a digit: "a1V".

  • Files are declared before export default, each with an id that nodes use and a workspace asset, uploaded with upload_asset or imported with import_asset first: export const assets = {fonts: [{id: "inter", family: "Inter", weight: 700, style: "normal", source: {type: "uri", uri: "asset://brand/Inter-Bold.ttf"}}], images: [{id: "logo", source: {type: "uri", uri: "asset://brand/logo.png"}}], media: [{id: "intro", source: {type: "uri", uri: "asset://launch/intro.mp4"}}]};

  • Text needs a font: a .ttf or .otf asset declared in fonts, which import_asset can fetch, such as https://github.com/google/fonts/raw/main/ofl/poppins/Poppins-Bold.ttf. <text id="title" common={{start: 0, duration: 3, order: "a3"}} content={{type: "paragraph", text: "Hello world", position: {x: 120, y: 860}, width: 1680, align: "left", style: {fontId: "inter", fontSize: 96, color: "#ffffff"}}} />. Fonts that share a family (such as Poppins Bold and Poppins Italic) are told apart by the style's fontWeight and fontStyle, which default to 400 and "normal": give each style the weight and style of its font. position is the top-left corner of the text's box, width wide, that align (left, center, right) places each line in; the first line's baseline sits about one font size below position.y. To centre text vertically, give the box a height and verticalAlign: "center" (or "bottom"): position: {x: 0, y: 0}, width: 1920, height: 1080 centres it on the whole canvas. To reveal it word by word, add animators: [{unit: "word", stagger: 400, opacity: Doc.keys([0, 0], [0.3, 1])}] to content: each word fades in over 0.3 seconds, one every 400 ticks (0.4 seconds at 1000 ticks a second), in place, the first at the node's start (an animator's fillColor is channels, {r: 1, g: 0.85, b: 0.3, a: 1}, each 0 to 1 and each a number or keyframes); delays, one per word in ticks, times them to speech instead (https://rendermate.com/docs/documents#how-do-i-add-captions-timed-to-speech).

  • A background colour: <fill id="bg" common={{order: "a0"}} paint={{style: "fill", source: {type: "solid", color: "#10233f"}}} />

  • A shape: <shape id="dot" common={{start: 0, duration: 3, order: "a2"}} geometry={{type: "circle", center: {x: 960, y: 540}, radius: 100}} paint={{style: "fill", source: {type: "solid", color: "#ffd84d"}}} />. geometry can also be {type: "rect", rect: {x, y, width, height}}, {type: "oval", rect: {...}}, or a rectangle with rounded corners, such as a button: {type: "roundedRect", rect: {rect: {x: 760, y: 480, width: 400, height: 120}, topLeft: {x: 60, y: 60}, topRight: {x: 60, y: 60}, bottomRight: {x: 60, y: 60}, bottomLeft: {x: 60, y: 60}}}, each corner's radii in pixels.

  • A line or any outline: a path in SVG path syntax, painted as a stroke: <shape id="tick" common={{start: 0, duration: 3, order: "a5"}} geometry={{type: "path", fillType: "winding", path: "M 100 100 L 300 300 L 500 100"}} paint={{style: "stroke", strokeWidth: 12, strokeCap: "round", source: {type: "solid", color: "#ffffff"}}} />. style is fill, stroke or strokeAndFill; strokeWidth is in pixels; strokeCap is butt (the default), round or square, and strokeJoin miter (the default), round or bevel. fillType says what's inside a path that crosses itself: winding fills every region it loops around, evenOdd leaves every second one empty, and inverseWinding and inverseEvenOdd fill the outside instead. One path's data may be up to 1 MiB.

  • Moving, scaling and turning any node, media and text included: transform in common, about origin, which is the canvas's top-left corner (0, 0) unless set, so set it to the node's centre to scale or turn it in place: <shape id="card" common={{start: 0, duration: 3, order: "a6", origin: {x: 960, y: 540}, transform: {translateX: Doc.keys([0, -200, "easeOutCubic"], [1, 0]), translateY: 0, scaleX: 1.2, scaleY: 1.2, rotate: {value: 15, unit: "degrees"}}}} geometry={{type: "rect", rect: {x: 760, y: 440, width: 400, height: 200}}} paint={{style: "fill", source: {type: "solid", color: "#ff3366"}}} />. translateX and translateY are pixels, scaleX and scaleY factors (1 is the node's size), and rotate an angle in degrees or radians. skewX and skewY are angles too. Any of them can be keyframes, such as rotate: {value: Doc.keys([0, 0], [1, 90]), unit: "degrees"}.

  • A gradient, in any paint's source: <fill id="sky" common={{order: "a4"}} paint={{style: "fill", source: {type: "gradient", gradient: {type: "linear", start: {x: 0, y: 0}, end: {x: 1920, y: 1080}, stops: [{offset: 0, color: "#10233f"}, {offset: 1, color: "#6a2c91"}], tileMode: "clamp"}}}} />. A radial gradient takes center and radius in place of start and end; tileMode is clamp, repeat, mirror or decal.

  • A group holds nodes: <group id="cards" common={{start: 1, duration: 3, order: "a7", opacity: 0.9}}><shape id="pip" common={{start: 1, duration: 2, order: "a0"}} geometry={{type: "circle", center: {x: 200, y: 200}, radius: 40}} paint={{style: "fill", source: {type: "solid", color: "#ffffff"}}} /></group>. Its opacity and transform apply to all of its children, which show only inside its window. A child's start is on the same clock as the group's, not counted from it, so this circle shows from 1 s to 3 s.

  • A flat node tilted in depth, like CSS 3D, with no camera or lights: perspective (the viewer's distance in pixels), rotateX, rotateY and translateZ (pixels toward the viewer) in transform, about origin: <shape id="flip" common={{start: 0, duration: 3, order: "a8", origin: {x: 960, y: 540}, transform: {perspective: 1200, rotateY: {value: Doc.keys([0, 0, "easeInOutCubic"], [2, 70]), unit: "degrees"}}}} geometry={{type: "rect", rect: {x: 760, y: 440, width: 400, height: 200}}} paint={{style: "fill", source: {type: "solid", color: "#ff3366"}}} />.

  • A real 3D scene, with depth, extrusion, lights, shadows and a camera: layer3d in a node's common puts it in the scene. A scene node is placed with z (pixels away from the viewer), xRotation (positive brings the top toward the viewer), yRotation (positive brings the right edge toward the viewer) and rotate, and refuses perspective, rotateX, rotateY and translateZ (validation.layer3d_css_transform). Solid 3D text: <text id="solid" common={{start: 0, duration: 3, order: "a9", origin: {x: 960, y: 540}, layer3d: {castsShadows: "on", extrusion: {depth: 30, bevel: {style: "convex", depth: 4}}}, transform: {xRotation: {value: Doc.keys([0, 70, "easeOutCubic"], [1.5, 0]), unit: "degrees"}}}} content={{type: "paragraph", text: "Hello world", position: {x: 360, y: 480}, width: 1200, align: "center", style: {fontId: "inter", fontSize: 140, color: "#111111"}}} />. Lights: <light id="key" common={{start: 0, duration: 3, order: "b00", transform: {translateX: 400, translateY: 0, z: -1000}}} lightType="point" intensity={1} castsShadows={true} />; lightType is parallel, spot, point, ambient, environment, hemisphere or rectArea. Without a light, scene nodes show their own colours, unshaded. A camera: <camera id="cam" common={{start: 0, duration: 3, order: "b01", transform: {z: -1500}}} zoom={1500} pointOfInterest={{x: 960, y: 540, z: 0}} depthOfField={{focusDistance: 1500, aperture: 40, blurLevel: 1}} />; without one the scene is filmed from the canvas's centre by a 50 mm lens. layer3d: {acceptsShadows: "only"} makes a node a shadow catcher, which shows only the shadows that fall on it. More at https://rendermate.com/docs/documents#how-do-i-make-3d.

  • A video, or an image from images: <media id="clip" common={{start: 0, duration: 4, order: "a1"}} assetId="intro" destination={{x: 0, y: 0, width: 1920, height: 1080}} fit="cover" sampling={{filter: "linear", mipmap: "linear"}} sourceIn={1} />. fit="contain" fits it inside destination; sourceIn is where in the file it starts, in seconds.

  • Sound: <audio id="music" common={{start: 0, duration: 6}} assetId="intro" sourceIn={2} gain={Doc.keys([0, 0], [1, 0.8], [4, 0.8], [6, 0])} /> plays the file from 2 seconds in, fading in over 1 second and out over the last 2; gain is a plain number, such as 0.3, to keep it level; it multiplies the sound's amplitude (1 leaves it as it is, 0.5 is about -6 dB). Sound files (mp3, wav, m4a) are declared in media, as video is. Audio takes no order. It plays only from the node's start for its duration, so a longer file is cut off at the node's end.

  • A crossfade: overlap two nodes by the fade's length and fade the later one in, opacity: Doc.keys([0, 0], [0.6, 1]). A slow zoom on a photo (Ken Burns): keyframe scaleX and scaleY from 1 to about 1.15 over the media node's whole window, with origin at its centre.

  • Animation: a number becomes keyframes, Doc.keys([seconds, value], ...) timed from the node's start, such as opacity: Doc.keys([0, 0], [0.5, 1]) in common or radius: Doc.keys([0, 20], [3, 120]). A keyframe's third item eases the way to the next one: "linear" (the default), "hold", or one of "easeIn", "easeOut" and "easeInOut" followed by Sine, Quad, Cubic, Expo or Back, such as "easeOutCubic"; Back overshoots by about a tenth and settles, for a bounce. Times are 0 or more and strictly increasing: two keyframes at one time are refused (validation.unsorted_keyframes), so to jump at once give the earlier one "hold", which keeps its value until the next one's time. Before the first keyframe the value holds the first one's, and after the last it holds the last one's. A keyframe past the node's duration is allowed, but the node stops drawing when its window ends, so it shows the value the curve has reached by then. A curve may have any number of keyframes, within the document's 64 MiB.

  • A long or repetitive video: never cut what it shows to make it smaller. Write what repeats once. A named curve, declared before export default: const fadeIn = Doc.keys([0, 0, "easeOutCubic"], [0.6, 1]);, read by its name, as in opacity: fadeIn; its times count from the start of each node that reads it. A component, also before export default: function Label({text = "Label", y = 0}) { return (<Composition id="label" duration={3} width={1920} height={1080}><text id="t" common={{start: 0, duration: 3, order: "a0", opacity: Doc.keys([0, 0], [0.6, 1]), transform: {translateY: y}}} content={{type: "paragraph", text: text, position: {x: 120, y: 100}, width: 1680, align: "left", style: {fontId: "inter", fontSize: 96, color: "#ffffff"}}} /></Composition>); }. Each use is a node with its own id, window and props: <Label id="first" common={{start: 0, duration: 3, order: "b02"}} text="First" y={200} />; its nodes' times count from that node's start. Then send a big document in several edits: create it, add the first nodes with jsx, and add each further batch with the edit {old_text: " </timeline>", new_text: " <Label ... />\n </timeline>"} on the version the last commit returned, with no need to read the document in between.

  • A field the format doesn't have is refused with jsx.unreadable, whose message says what that place takes.

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": {
      "document_id": "<document_id>",
      "base_version": "<base_version>",
      "message": "<message>"
    },
    "name": "edit_document"
  }
}

Input Schema

NameRequiredDescriptionDefault
jsxNoThe whole document as edited JSX, in place of `edits`. Every node it keeps keeps its `id`.
editsNoReplacements in the JSX of `base_version`, made in order. Give these or `jsx`.
messageYesWhy the document changes, in one line, like a git commit message: "Shorten the intro to 4 seconds", not "update document".
commit_idNoA UUID that makes the commit safe to send again: sent again with the same one, it answers with the version it made instead of making another. The `Idempotency-Key` header does the same.
document_idYesThe document to edit, `doc_…`.
base_versionYesThe version the edit was made on, as get_document returned it: the edit is committed only if that's still the newest version.

Output Schema

NameRequiredDescriptionDefault
idYesThe document, `doc_…`.
jsxNoThe [Rendermate document](https://rendermate.com/docs/documents) at this version, written as JSX; only when it's read, not when it's created or committed. Edit it with edit_document, giving this version as `base_version`.
authorNoThe API key, or the member, that made it.
sha256YesSHA-256 of the document as canonical JSON.
messageNoWhat the commit changes and why.
versionYesThe version's number: 1 for the document as created, one more for each commit.
commit_idYesThe commit that made the version.
committed_atNoRFC 3339.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.2/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=false, destructiveHint=false, and openWorldHint=false. The description adds valuable behavior beyond that: it explains that commits create new versions, that stale `base_version` causes `version.conflict`, and that JSX is normalized after each commit, though it omits auth or rate-limit context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness2/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The purpose is front-loaded in the first sentence, but the body is an extremely long JSX format manual with many examples and repetitions. It is not appropriately sized for a tool description and would be better split into linked documentation.

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 complex, versioned JSX-editing mutation with an output schema, the description covers the editing workflow, conflict recovery, format constraints, and many examples. Nothing critical for correct invocation appears to be 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 description coverage is 100%, so the baseline is 3. The description still adds meaning by explaining `old_text` uniqueness, inclusion of node IDs, ordered application, and when to use `jsx` instead of `edits`, while `message` and `commit_id` remain covered by 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 opening sentence states a specific verb and resource: 'Change a document by committing an edit on base_version, which makes a new version.' It makes the versioned-commit model clear and distinguishes the operation from the read-only get_document flow it references.

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

Usage Guidelines4/5

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

The description gives clear operational guidance: use `edits` or `jsx`, call get_document before writing `old_text`, and recover from `version.conflict` by reading and redoing the edit. It does not explicitly compare this tool with create_document or other editing alternatives, so it falls short of full when-to-use coverage.

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