Skip to main content
Glama

kb_documents_edit_apply

Apply an ordered batch of edits to an open edit session, all-or-nothing — if any edit cannot be applied (no match / ambiguous / overlapping / out of range) the whole batch is rejected and the buffer is left unchanged. Edit types: "replace" (old_string unique unless replace_all=true, new_string), "line_range" (start_line/end_line/content), "section" (heading + mode replace_body|insert_after_heading|delete_section, with level/parent to disambiguate). Returns the cumulative base→working unified diff; pass an empty edits array to just re-fetch the diff without mutating.

Input Schema

NameRequiredDescriptionDefault
diffNoWhich diff to return: full (default) cumulative base→working; none to skip the diff body for long sessions; delta = only this batch change.
editsYesOrdered edits applied atomically against the current buffer. Empty array = diff refresh only.
session_idYesOpen edit session id (required)
tenant_slugNoTenant slug to target. Required when your token grants several workspaces; omit when it grants one. If you omit it with several, the refusal names your default workspace; call kb_tenants_list to see every workspace the token grants.

Output Schema

NameRequiredDescriptionDefault
diffYes
expires_atYes
session_idYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.3/5.0
Behavior4/5

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

Goes well beyond the annotations by disclosing the atomic rejection contract and its four failure causes (no match / ambiguous / overlapping / out of range) plus the guarantee that the buffer is unchanged on failure. It also documents the return value (cumulative base→working unified diff). Minor gap: it never states that acceptance means staged-only, with commit as the persistence step — the key non-idempotent, non-destructive behavior an agent must know.

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?

The atomicity guarantee is correctly front-loaded and every clause is substantive. The edit-type enumeration partially duplicates the 100%-covered oneOf schema; trimming it to the non-obvious constraints (uniqueness, disambiguation, content ignored on delete_section) would tighten it without losing information.

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?

An output schema exists so return format needn't be re-explained, and annotations cover the safety profile; the description fills the remaining gap with the failure/rejection model. What's absent is the surrounding session lifecycle — that nothing is persisted until edit_commit and that edit_discard throws the buffer away — which matters for a non-idempotent, non-read-only mutation tool.

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 baseline is 3, but the description earns more by explaining how the edit variants behave in combination (ordering, uniqueness of old_string, disambiguation via level/parent, empty array semantics). It does not mention the `diff` enum (full/none/delta) or tenant_slug at all, leaving those entirely to 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?

Opens with a specific verb + resource ("Apply an ordered batch of edits to an open edit session") and immediately names the defining property (all-or-nothing). An agent can distinguish it from kb_documents_edit_commit / edit_discard / edit_begin without opening a schema, since it's clearly the staging-mutation step of a session workflow.

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?

States the prerequisite implicitly ("an open edit session") and gives a non-obvious usage mode (empty edits array = diff refresh only). It does not explicitly say the changes are not persisted until kb_documents_edit_commit is called, which is the single most important routing decision among the edit_* siblings.

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.