Skip to main content
Glama

MCP Claude Code

by SDGLBL

multi_edit

Perform multiple find-and-replace edits on a single file in one operation, ensuring atomicity and sequential application of changes for efficient file modifications.

Instructions

This is a tool for making multiple edits to a single file in one operation. It is built on top of the Edit tool and allows you to perform multiple find-and-replace operations efficiently. Prefer this tool over the Edit tool when you need to make multiple edits to the same file.

Before using this tool:

  1. Use the Read tool to understand the file's contents and context
  2. Verify the directory path is correct

To make multiple file edits, provide the following:

  1. file_path: The absolute path to the file to modify (must be absolute, not relative)
  2. edits: An array of edit operations to perform, where each edit contains:
    • old_string: The text to replace (must match the file contents exactly, including all whitespace and indentation)
    • new_string: The edited text to replace the old_string
    • expected_replacements: The number of replacements you expect to make. Defaults to 1 if not specified.

IMPORTANT:

  • All edits are applied in sequence, in the order they are provided
  • Each edit operates on the result of the previous edit
  • All edits must be valid for the operation to succeed - if any edit fails, none will be applied
  • This tool is ideal when you need to make several changes to different parts of the same file
  • For Jupyter notebooks (.ipynb files), use the NotebookEdit instead

CRITICAL REQUIREMENTS:

  1. All edits follow the same requirements as the single Edit tool
  2. The edits are atomic - either all succeed or none are applied
  3. Plan your edits carefully to avoid conflicts between sequential operations

WARNING:

  • The tool will fail if edits.old_string matches multiple locations and edits.expected_replacements isn't specified
  • The tool will fail if the number of matches doesn't equal edits.expected_replacements when it's specified
  • The tool will fail if edits.old_string doesn't match the file contents exactly (including whitespace)
  • The tool will fail if edits.old_string and edits.new_string are the same
  • Since edits are applied in sequence, ensure that earlier edits don't affect the text that later edits are trying to find

When making edits:

  • Ensure all edits result in idiomatic, correct code
  • Do not leave the code in a broken state
  • Always use absolute file paths (starting with /)

If you want to create a new file, use:

  • A new file path, including dir name if needed
  • First edit: empty old_string and the new file's contents as new_string
  • Subsequent edits: normal edit operations on the created content

Input Schema

NameRequiredDescriptionDefault
editsYesArray of edit operations to perform sequentially on the file
file_pathYesThe absolute path to the file to modify (must be absolute, not relative)

Input Schema (JSON Schema)

{ "$defs": { "EditItem": { "description": "A single edit operation.", "properties": { "expected_replacements": { "default": 1, "description": "The expected number of replacements to perform. Defaults to 1 if not specified.", "title": "Expected Replacements", "type": "integer" }, "new_string": { "description": "The edited text to replace the old_string", "title": "New String", "type": "string" }, "old_string": { "description": "The text to replace (must match the file contents exactly, including all whitespace and indentation)", "title": "Old String", "type": "string" } }, "required": [ "old_string", "new_string" ], "title": "EditItem", "type": "object" } }, "properties": { "edits": { "description": "Array of edit operations to perform sequentially on the file", "items": { "$ref": "#/$defs/EditItem" }, "minItems": 1, "title": "Edits", "type": "array" }, "file_path": { "description": "The absolute path to the file to modify (must be absolute, not relative)", "title": "File Path", "type": "string" } }, "required": [ "file_path", "edits" ], "type": "object" }

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/SDGLBL/mcp-claude-code'

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