Skip to main content
Glama

Write batch (commits changes)

write_batch
Destructive

Applies multiple typed wiki edits (create, overwrite, replace, delete, rename) in one validated git commit, ensuring planned changes either fully succeed or leave the wiki unchanged.

Instructions

Transactionally apply typed edit operations in one git commit.

Call it only after the user agreed to the plan (target wiki, every operation, any split into several batches). Keep each call under about 30 kB of arguments: split up front, with index and log in the last batch.

Each edit is one {op, ...}, applied in order (chained on the same path):

  • create: {op, path, content}; fails if the path exists.

  • overwrite: {op, path, content, expected_version}; full rewrite.

  • replace: {op, path, old, new, expected_version, replace_all?}; surgical edit, 'old' must be unique unless replace_all=true. Read the page with raw=True first so 'old' matches the bytes on disk.

  • delete: {op, path, expected_version}.

  • rename: {op, path, new_path, expected_version}; wikilinks to the old name are not rewritten, fix them with replace ops in the same batch.

expected_version is the token from read_page; required to modify, delete or rename an existing file, ignored for a path created earlier in this batch. Writes stay under the wiki and raw zones or the index/log/schema files; raw/ is create-only; the log, index and schema cannot be deleted or renamed. Everything is validated first: on any failure nothing is written or committed. Returns {commit, applied}.

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": {
      "wiki": "<wiki>",
      "edits": "<edits>",
      "message": "<message>"
    },
    "name": "write_batch"
  }
}

Input Schema

NameRequiredDescriptionDefault
wikiYesWiki id, as returned by list_wikis.
editsYesEdit operations, applied in order; see the tool description.
messageYesCommit message describing the change.

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv0.1.3
    • addedInput schema / properties / edits / description
      Added value: +"Edit operations, applied in order; see the tool description."
    • addedInput schema / properties / message / description
      Added value: +"Commit message describing the change."
    • addedInput schema / properties / wiki / description
      Added value: +"Wiki id, as returned by list_wikis."
  2. Changed1 schema field changedv0.1.2
    • changedInput schema / properties / edits / items / description
      Previous value: -"A single edit operation in a ``write_batch``.\n\n``op`` selects the verb; the other fields are validated per op (manual\n``NotRequired`` checks, like the old ``_validate_edits``, rather than a\ndiscriminated union, a flatter JSON schema is more predictable for clients):\n\n- ``create``    : ``path``, ``content``\n- ``overwrite`` : ``path``, ``content``, ``expected_version``\n- ``replace``   : ``path``, ``old``, ``new``, ``expected_version`` (``replace_all``)\n- ``delete``    : ``path``\n- ``rename``    : ``path``, ``new_path``\n\n``expected_version`` is the optimistic-concurrency token from ``read_page``;\nit is required on ``replace``/``overwrite`` of an existing file and ignored\nwhen the target was created earlier in the same batch."New value: +"A single edit operation in a ``write_batch``.\n\n``op`` selects the verb; the other fields are validated per op (manual\n``NotRequired`` checks, like the old ``_validate_edits``, rather than a\ndiscriminated union, a flatter JSON schema is more predictable for clients):\n\n- ``create``    : ``path``, ``content``\n- ``overwrite`` : ``path``, ``content``, ``expected_version``\n- ``replace``   : ``path``, ``old``, ``new``, ``expected_version`` (``replace_all``)\n- ``delete``    : ``path``, ``expected_version``\n- ``rename``    : ``path``, ``new_path``, ``expected_version``\n\n``expected_version`` is the optimistic-concurrency token from ``read_page``;\nit is required to modify, delete or rename an existing file and ignored\nwhen the target was created earlier in the same batch."
  3. First observedv0.1.1

TDQS

A4.9/5.0
Behavior5/5

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

Annotations already flag destructiveHint=true and no idempotency, but the description adds far more: full validation before any write with nothing committed on failure, ordered/chained application on the same path, create-only raw/ zone, and non-deletable log/index/schema files. It also discloses the rename side-effect that wikilinks are not rewritten and must be fixed with replace ops.

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 core semantics, then organized as a scannable per-op list followed by invariants. It is long, but nearly every line carries a constraint an agent would otherwise get wrong; the op field enumerations partially duplicate the nested schema description.

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 destructive multi-op transactional write, the description covers atomicity, ordering, size limits, path constraints, concurrency tokens and the rename caveat, and the return shape is covered by the existing output schema. Nothing material is left for the agent to guess.

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%, so the baseline is 3, but the description adds cross-parameter meaning the schema cannot express: expected_version is required for modifying existing files yet ignored for paths created earlier in the same batch, 'old' must be unique unless replace_all=true, and the page must first be read with raw=True so 'old' matches on-disk bytes.

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?

Opens with a specific verb, resource and mechanism: 'Transactionally apply typed edit operations in one git commit.' That single clause separates it from every sibling listed (read_page, list_pages, search_wiki), which are all read-side tools.

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 an explicit precondition ('Call it only after the user agreed to the plan' with target wiki, every operation, and any split spelled out) plus an operational rule to split batches up front and put index/log last. Both when-to-use and how-to-sequence are stated rather than inferred.

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