Skip to main content
Glama

Edit Preview

edit_preview

Preview where an anchor string matches in a file before editing, returning match count, line numbers, and snippets to confirm uniqueness. Read-only and low-cost, it helps avoid failed edits.

Instructions

Show where old_string would match in a file, without editing it.

Returns the match count, 1-based line numbers, and short snippets so you can confirm an anchor is unique before calling edit. Read-only and cheap (kept under ~200 tokens), so use it freely as a probe. Raises an error on a binary file or an empty old_string.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesFile path to search (absolute, or relative to root).
old_stringYesAnchor text to locate. Must match exactly, including whitespace and indentation. Cannot be empty.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.6.0
    • changedOutput schema / (root)
      Previous value: -{
      -  "properties": {
      -    "context": {
      -      "anyOf": [
      -        {
      -          "items": {
      -            "properties": {
      -              "line": {
      -                "anyOf": [
      -                  {
      -                    "type": "integer"
      -                  },
      -                  {
      -                    "type": "null"
      -                  }
      -                ],
      -                "default": null,
      -                "title": "Line"
      -              },
      -              "snippet": {
      -                "anyOf": [
      -                  {
      -                    "type": "string"
      -                  },
      -                  {
      -                    "type": "null"
      -                  }
      -                ],
      -                "default": null,
      -                "title": "Snippet"
      -              },
      -              "truncated": {
      -                "anyOf": [
      -                  {
      -                    "type": "boolean"
      -                  },
      -                  {
      -                    "type": "null"
      -                  }
      -                ],
      -                "default": null,
      -                "title": "Truncated"
      -              }
      -            },
      -            "title": "EditPreviewMatch",
      -            "type": "object"
      -          },
      -          "type": "array"
      -        },
      -        {
      -          "type": "null"
      -        }
      -      ],
      -      "default": null,
      -      "title": "Context"
      -    },
      -    "found": {
      -      "anyOf": [
      -        {
      -          "type": "boolean"
      -        },
      -        {
      -          "type": "null"
      -        }
      -      ],
      -      "default": null,
      -      "title": "Found"
      -    },
      -    "line_numbers": {
      -      "anyOf": [
      -        {
      -          "items": {
      -            "type": "integer"
      -          },
      -          "type": "array"
      -        },
      -        {
      -          "type": "null"
      -        }
      -      ],
      -      "default": null,
      -      "title": "Line Numbers"
      -    },
      -    "match_count": {
      -      "anyOf": [
      -        {
      -          "type": "integer"
      -        },
      -        {
      -          "type": "null"
      -        }
      -      ],
      -      "default": null,
      -      "title": "Match Count"
      -    },
      -    "path": {
      -      "anyOf": [
      -        {
      -          "type": "string"
      -        },
      -        {
      -          "type": "null"
      -        }
      -      ],
      -      "default": null,
      -      "title": "Path"
      -    },
      -    "truncated": {
      -      "anyOf": [
      -        {
      -          "type": "boolean"
      -        },
      -        {
      -          "type": "null"
      -        }
      -      ],
      -      "default": null,
      -      "title": "Truncated"
      -    }
      -  },
      -  "title": "EditPreviewResponse",
      -  "type": "object"
      -}New value: +null
  2. Changed2 schema fields changedv0.5.1
    • addedInput schema / properties / old_string / description
      Added value: +"Anchor text to locate. Must match exactly, including\nwhitespace and indentation. Cannot be empty."
    • addedInput schema / properties / path / description
      Added value: +"File path to search (absolute, or relative to root)."
  3. Addedv0.4.8

TDQS

A4.7/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 of behavioral transparency. It clearly states that the tool is read-only, returns match count, line numbers, and snippets, and raises errors on binary files or empty `old_string`.

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 concise and well-structured, covering purpose, behavior, usage guidance, and error conditions in just a few sentences. Every sentence adds useful information without redundancy or fluff.

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?

Although there is no output schema, the description adequately explains the return content (match count, 1-based line numbers, snippets). It also covers error cases and usage context, making the tool's behavior sufficiently complete for an agent to use it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema already describes both parameters with 100% coverage, including path absoluteness and exact matching rules for `old_string`. The tool description adds no additional parameter-level detail beyond what the schema provides, so a baseline score of 3 is appropriate.

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 clearly states the tool's purpose: showing where `old_string` would match in a file without editing it. It also distinguishes itself from the sibling `edit` tool by explicitly noting it is a preview step before calling `edit`.

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?

It explains when to use the tool: to confirm an anchor is unique before calling `edit`. It also provides practical guidance by noting the operation is read-only, cheap, and kept under ~200 tokens, and it specifies error conditions for binary files and empty `old_string`.

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