Skip to main content
Glama

files.update

Rewrite a file's full content or replace only a specific section's body by heading, preserving the heading and siblings. Updates disk and search index, returning new token counts.

Instructions

Rewrite a file. Default = full-body replacement: content becomes the entire file, triggering disk write + FTS5 re-index. Pass section to instead rewrite ONLY that heading's body (case-insensitive exact-string after trim; the heading line itself is preserved, siblings untouched) — saves context budget vs resending the whole file. Throws if section is set but the heading doesn't exist (this mode will NOT create a new section — append the section text via a full-body update first). Operates locally with no external auth or rate limits. Returns the updated file metadata including new estimated token counts.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesFile ID
contentYesNew content. With `section` set, this replaces just that heading's body; otherwise it becomes the entire file body.
sectionNoCase-insensitive exact-string heading. When set, only this heading's body is rewritten instead of the whole file.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv5.0.0
    • changedInput schema / properties / content / description
      Previous value: -"New content"New value: +"New content. With `section` set, this replaces just that heading's body; otherwise it becomes the entire file body."
    • addedInput schema / properties / section
      Added value: +{
      +  "description": "Case-insensitive exact-string heading. When set, only this heading's body is rewritten instead of the whole file.",
      +  "type": "string"
      +}
  2. Addedv4.7.2

TDQS

A5/5.0
Behavior5/5

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

With no annotations provided, the description carries the full burden, and it delivers: it discloses disk write and FTS5 re-index side effects, case-insensitive exact-string matching after trim, preservation of the heading line and siblings, error behavior for missing headings, local operation with no auth or rate limits, and the return value. This is comprehensive behavioral disclosure.

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

Conciseness5/5

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

The description is dense but every sentence earns its place: main behavior, default mode, section mode, error condition, operational context, and return value are all covered without fluff. The key behavior is front-loaded, and the alternative-mode guidance appears immediately after the default behavior.

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?

The description is complete for a file-update tool: it specifies inputs, modes, error cases, side effects, operational constraints, and the return shape (updated metadata with token counts). There is no output schema, so the description's explicit mention of the return value fills that gap. Nothing essential 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?

Although schema coverage is 100%, the description adds substantial meaning beyond the schema. It explains that `content` becomes the entire file by default but only the heading's body when `section` is set, and it details matching semantics and preservation behavior for `section`. This goes well beyond the baseline already covered by parameter descriptions.

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 starts with 'Rewrite a file,' a specific verb and resource that clearly indicates modification of an existing file. It distinguishes two modes — full-body replacement versus partial section rewrite — and explicitly notes that the section mode does not create new sections, which differentiates it from files.create and other file operations.

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?

The description gives explicit guidance on when to use section mode ('saves context budget vs resending the whole file') and when not to use it ('Throws if section is set but the heading doesn't exist... will NOT create a new section'). It also directs the agent to append via a full-body update first, which is a clear alternative path. This is strong usage direction.

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