Skip to main content
Glama

edit_block

Destructive

Apply surgical edits to files by replacing specific text or updating Excel ranges with precise control over changes.

Instructions

                    Apply surgical edits to files.

                    BEST PRACTICE: Make multiple small, focused edits rather than one large edit.
                    Each edit_block call should change only what needs to be changed - include just enough
                    context to uniquely identify the text being modified.

                    FORMAT HANDLING (by extension):

                    EXCEL FILES (.xlsx, .xls, .xlsm) - Range Update mode:
                    Takes:
                    - file_path: Path to the Excel file
                    - range: ALWAYS use FROM:TO format - "SheetName!A1:C10" or "SheetName!C1:C1"
                    - content: 2D array, e.g., [["H1","H2"],["R1","R2"]]

                    TEXT FILES - Find/Replace mode:
                    Takes:
                    - file_path: Path to the file to edit
                    - old_string: Text to replace
                    - new_string: Replacement text
                    - expected_replacements: Optional number of replacements (default: 1)

                    By default, replaces only ONE occurrence of the search text.
                    To replace multiple occurrences, provide expected_replacements with
                    the exact number of matches expected.

                    UNIQUENESS REQUIREMENT: When expected_replacements=1 (default), include the minimal
                    amount of context necessary (typically 1-3 lines) before and after the change point,
                    with exact whitespace and indentation.

                    When editing multiple sections, make separate edit_block calls for each distinct change
                    rather than one large replacement.

                    When a close but non-exact match is found, a character-level diff is shown in the format:
                    common_prefix{-removed-}{+added+}common_suffix to help you identify what's different.

                    Similar to write_file, there is a configurable line limit (fileWriteLineLimit) that warns
                    if the edited file exceeds this limit. If this happens, consider breaking your edits into
                    smaller, more focused changes.

                    IMPORTANT: Always use absolute paths for reliability. Paths are automatically normalized regardless of slash direction. Relative paths may fail as they depend on the current working directory. Tilde paths (~/...) might not work in all contexts. Unless the user explicitly asks for relative paths, use absolute paths.
                    This command can be referenced as "DC: ..." or "use Desktop Commander to ..." in your instructions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
old_stringNo
new_stringNo
expected_replacementsNo
rangeNo
contentNo
optionsNo
Behavior4/5

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

Annotations indicate destructiveHint=true and readOnlyHint=false, which the description aligns with by describing file modifications. The description adds valuable behavioral context beyond annotations: it explains uniqueness requirements for text edits, character-level diff displays for non-exact matches, configurable line limits (referencing write_file), and path handling rules (absolute vs. relative). However, it doesn't detail error handling or specific rate limits, keeping it from a perfect score.

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 description is well-structured with clear sections (BEST PRACTICE, FORMAT HANDLING, UNIQUENESS REQUIREMENT) and uses bullet points for readability. It is appropriately sized for a complex tool with 7 parameters and multiple modes. However, some redundancy exists (e.g., repeating path advice and edit focus), and the final paragraph about command references is slightly extraneous, preventing a perfect score.

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?

Given the tool's complexity (7 parameters, 0% schema coverage, no output schema, destructive operations), the description is highly complete. It covers all operational modes (Excel vs. text), parameter usage, best practices, error handling (diffs for non-exact matches), constraints (line limits, path requirements), and sibling tool context. No output schema exists, but the description adequately explains expected behaviors without needing to detail return values.

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?

With 0% schema description coverage, the description fully compensates by explaining all key parameters. It details file_path usage for both modes, old_string/new_string for text files, expected_replacements with defaults, and range/content for Excel files. It clarifies parameter dependencies (e.g., range and content for Excel, old_string/new_string for text) and provides examples (e.g., 'SheetName!A1:C10', 2D arrays), adding significant meaning beyond the bare 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?

The description clearly states the tool's purpose: 'Apply surgical edits to files.' It specifies the verb ('apply surgical edits') and resource ('files'), distinguishing it from sibling tools like write_file (which creates/overwrites files) and read_file (which only reads). The description further elaborates on the surgical nature of edits, making the purpose highly specific and differentiated.

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 provides explicit guidance on when and how to use this tool versus alternatives. It states: 'When editing multiple sections, make separate edit_block calls for each distinct change rather than one large replacement,' and references write_file for context on line limits. It also distinguishes between Excel file edits (range update mode) and text file edits (find/replace mode), offering clear alternatives within the tool itself based on file type.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/wonderwhy-er/ClaudeComputerCommander'

If you have feedback or need assistance with the MCP directory API, please join our Discord server