Skip to main content
Glama
L-Jovi

Keyhole – Local files for ChatGPT

apply_text_patch

DestructiveIdempotent

Apply precise text replacements to local files with SHA-256 verification, ensuring exact matches and unique request IDs for safe, recoverable edits.

Instructions

Apply 1-64 literal replacements to an existing UTF-8 file <=8 MiB. Each edit has old/new text and exact match count (default 1); ambiguous matches are refused. Requires rw, observed SHA-256 and unique request_id. Preserves untouched content, BOM/newlines and permissions. Returns change_id for recovery.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes
editsYes
workspaceYes
request_idYes
expected_sha256Yes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.3.2-demo.1

TDQS

A4.7/5.0
Behavior5/5

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

The description goes far beyond the annotations, disclosing exact-match counting, ambiguous-match refusal, the SHA-256 and request_id requirements, preservation of BOM/newlines/permissions, and the change_id return for recovery. This aligns with destructiveHint=true and idempotentHint=true without contradicting them.

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?

Three dense sentences front-load the core action and constraints, then cover preconditions, preservation guarantees, and return value. Every sentence adds essential information with no filler.

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?

With no output schema, the description still states the return value (change_id for recovery). It covers limits, safety behavior, concurrency guard, and preservation semantics. For a mutation tool with rich annotations, this is a complete and actionable description.

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 0%, so the description carries the full burden. It explains old/new text and exact match count (mapping to the TextEdit properties), expected_sha256, and unique request_id. It does not explicitly describe workspace or path semantics, but these are reasonably inferable from context.

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 opens with a specific verb and resource: 'Apply 1-64 literal replacements to an existing UTF-8 file <=8 MiB.' It clearly distinguishes this from sibling tools like write_file (whole-file writes) and delete_file, and the replacement semantics are unambiguous.

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 context: the tool is for literal replacements in existing UTF-8 files up to 8 MiB, with exact match counts and refusal of ambiguous matches. It also lists preconditions (rw, observed SHA-256, unique request_id), but it does not explicitly name alternatives or state when write_file would be preferred over this tool.

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