editDocument
Edit a document: the PREFERRED tool for small targeted changes. Two patch dialects — do NOT mix them in one call. (1) ANCHOR patches {oldText, newText, before?, after?} — RECOMMENDED: replace an exact snippet of existing text with new text. oldText must match the document byte-for-byte AND be uni...
This record as markdown: /tools/io-stablebaseline-sb/editdocument.md
What editDocument does on Stable Baseline
AI agents use editDocument to create or update resources in Stable Baseline, usually the action step of a workflow, after the agent has gathered context. Every call changes real data in your Stable Baseline environment.
| Parameter | Type | Required | Description |
|---|---|---|---|
title | string | — | New title. |
dryRun | boolean | — | If true, apply the patches and RETURN the resulting document text without saving — no version bump, no lock required. Use to preview/verify a patch before commi |
patches | array | — | Patches to apply. Use EITHER anchor patches OR line patches, not both in the same call. May be empty if only updating title, folderId, or position. |
folderId | string | null | — | MOVE the document into this folder (null moves it to the project root). Send it with patches:[] to file the document without touching its content — a folder-onl |
position | number | — | Sort position within the parent folder. Use to reposition a single document; like folderId, a position-only change creates no version. For batch sibling reorder |
projectId | string | — | Optional. Narrows a friendly-id lookup to one project. Only needed when a friendly id is ambiguous — TAS-/IMP-/PLN- ids are numbered per PROJECT, so the same id |
documentId | string | Yes | |
changeSummary | string | — | Version history summary. |
expectedVersion | number | — | Legacy integer version guard, checked in addition to versionTimestamp. Prefer versionTimestamp — this exists for older clients and is optional. |
versionTimestamp | number | — | Optimistic-lock token from getDocument() or any mutating tool's response. Required unless dryRun:true. (Alias accepted: documentVersionTimestamp.) |
Parameters from the server's own tool schema.
Why editDocument is rated Medium
An AI agent can call editDocument faster than any human can review: one bad instruction and it creates or modifies resources in Stable Baseline by the hundred, each call as confident as the last.
Risk signalsHigh parameter count (10 properties)
Attacks that exploit this kind of access
The rule that runs editDocument safely
PolicyLayer is an MCP gateway: it sits between your AI agents and Stable Baseline, and checks every tool call against a rule you set before the call runs. Nothing changes on the server itself. For editDocument, this is the rule to start with:
editDocument stays usable, but capped: an agent stuck in a loop can't make hundreds of changes a minute. Everything else on the server is denied unless you say otherwise.
The button opens the PolicyLayer dashboard: create your workspace, connect Stable Baseline, apply this rule, and every editDocument call is checked against it from then on.
Questions about editDocument
Edit a document: the PREFERRED tool for small targeted changes. Two patch dialects — do NOT mix them in one call. (1) ANCHOR patches {oldText, newText, before?, after?} — RECOMMENDED: replace an exact snippet of existing text with new text. oldText must match the document byte-for-byte AND be unique; if it occurs more than once, either expand oldText until it is unique, or add before/after (the EXACT text immediately before/after the match) to disambiguate. A no-match returns nearby context; an ambiguous match returns the occurrence count. Anchors do NOT drift, so you don't need fresh line numbers and they survive concurrent edits. Use newText:"" to delete. (2) LINE patches {startLine, endLine, replacement} — 1-based and INCLUSIVE: call getDocument first for line numbers; replace line 5 with {startLine:5,endLine:5}; INSERT before line N (deleting nothing) with {startLine:N,endLine:N-1}; append to an L-line document with {startLine:L+1,endLine:L}. Line numbers are ABSOLUTE and GO STALE after ANY edit — re-call getDocument before further line patches; out-of-range patches are rejected with the current line count. versionTimestamp from getDocument (or from any mutating tool's response — they all return the fresh token) is required for optimistic locking, EXCEPT when dryRun:true. If your token is stale, the error tells you who changed the document, when, and the currentVersionTimestamp — anchor patches survive concurrent edits, so retrying with that token is usually safe. Set dryRun:true to apply the patches and get the resulting text back WITHOUT saving (verify before committing — kills retry loops). IMPORTANT: getDocument displays lines as NNNNN<TAB>content; that prefix is display-only — oldText/before/after must contain only the content AFTER the tab. Do not edit or delete DIAGRAM/IMAGE marker lines (rejected with guidance) — use dedicated diagram/image tools. To @-mention a person, insert <!-- REFERENCE: {"type":"user","id":"<user_uuid>","label":"Name"} -->; look up the user_id via listAssignablePrincipals. Mentioned users are notified automatically. It is categorised as a Write tool in the Stable Baseline MCP Server, which means it can create or modify data. Consider rate limits to prevent runaway writes.
editDocument accepts 10 parameters: title, dryRun, patches, folderId, position, projectId, documentId, changeSummary, expectedVersion, versionTimestamp. Required: documentId. The full parameter table on this page comes from the server's own tool schema.
Register the Stable Baseline MCP server in PolicyLayer and add a rule for editDocument: allow, deny, rate-limit, or require approval. Point your MCP client at the PolicyLayer proxy URL and the rule is enforced on every call, before it reaches Stable Baseline. Nothing to install.
editDocument is a Write tool with medium risk. Write tools should be rate-limited to prevent accidental bulk modifications.
Yes. Add a rate_limit block to the editDocument rule in your PolicyLayer policy. For example, setting max: 10 and window: 60 limits the tool to 10 calls per minute. Rate limits are tracked per agent session and reset automatically.
Set action: deny in the PolicyLayer policy for editDocument. The AI agent will receive a policy violation error and cannot call the tool. You can also include a reason field to explain why the tool is blocked.
editDocument is provided by the Stable Baseline MCP server (https://api.stablebaseline.io/functions/v1/cloud-serve/mcp). PolicyLayer sits as a proxy in front of this server to enforce policies before tool calls reach the server.
More on Stable Baseline, and thousands of servers like it.
This server
Across the catalogue