Multi Edit MCP Server

Multi Edit MCP Server

Enables atomic batch find-and-replace edits across single or multiple files, reducing tool calls and token usage for efficient code refactoring.

Category
访问服务器

README

Multi Edit MCP Server

npm version license tests coverage

An MCP server that gives Claude the ability to perform multiple find-and-replace operations in a single tool call with guaranteed atomicity -- all edits succeed or none apply.

Built by Essential AI Solutions for Claude Code and Claude Desktop.

Why Multi Edit?

Claude's built-in Edit tool handles one find-and-replace per call. When renaming a variable across a file or refactoring multiple files, that means dozens of individual tool calls -- each consuming context tokens and adding latency.

Multi Edit batches them into a single call:

Without multi_edit:      105 tool calls   |   15,750 tokens
With multi_edit:          21 tool calls   |    7,850 tokens   (-80% calls, -50% tokens)
With multi_edit_files:     6 tool calls   |    4,550 tokens   (-94% calls, -71% tokens)

Benchmarks run on realistic scenarios (bulk rename, logging migration, cross-file refactor). See benchmarks/results/BENCHMARK-REPORT.md for full details.

Quick Start

Claude Code

Add .mcp.json to your project root:

{
  "mcpServers": {
    "Multi Edit from Essential AI Solutions (essentialai.uk)": {
      "command": "npx",
      "args": ["-y", "@essentialai/mcp-multi-edit"]
    }
  }
}

Restart Claude Code. Then add the included CLAUDE.md to your project root so Claude automatically prefers multi_edit over the built-in Edit tool:

## Editing Files

When making multiple edits to the same file or across multiple files,
prefer using the `multi_edit` and `multi_edit_files` MCP tools over
the built-in Edit tool. These batch edits atomically in a single call.

That's it -- Claude will now use multi_edit whenever it's the right tool for the job.

Display name: Claude Code uses the key name in mcpServers as the server's display name. You can change the key to any name you prefer.

Alternative: One-liner via CLI:

claude mcp add --transport stdio multi-edit -- npx -y @essentialai/mcp-multi-edit

Note: The CLI only accepts simple names (letters, numbers, hyphens, underscores). For the full branded display name, use the .mcp.json approach above.

Claude Desktop

Add to your config file (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):

{
  "mcpServers": {
    "Multi Edit from Essential AI Solutions (essentialai.uk)": {
      "command": "npx",
      "args": ["-y", "@essentialai/mcp-multi-edit"]
    }
  }
}

Restart Claude Desktop.

Full installation guide: docs/installation.md

Tools

multi_edit -- Single file, multiple edits

Batch multiple find-and-replace operations on one file. Edits apply sequentially and atomically.

{
  "file_path": "/project/src/app.ts",
  "edits": [
    { "old_string": "const oldName = getValue()", "new_string": "const newName = getValue()" },
    { "old_string": "console.log", "new_string": "logger.info", "replace_all": true }
  ]
}
Parameter Type Default Description
file_path string required Absolute path to the file
edits array required Find-and-replace operations (applied in order)
edits[].old_string string required Text to find (exact match)
edits[].new_string string required Replacement text
edits[].replace_all boolean false Replace all occurrences
dry_run boolean false Preview changes without applying
backup boolean true Create .bak backup before editing

multi_edit_files -- Multiple files, one atomic operation

Coordinate edits across multiple files. If any file fails, all files are rolled back automatically.

{
  "files": [
    {
      "file_path": "/project/src/types.ts",
      "edits": [
        { "old_string": "interface UserData {", "new_string": "interface UserProfile {" }
      ]
    },
    {
      "file_path": "/project/src/api.ts",
      "edits": [
        { "old_string": "UserData", "new_string": "UserProfile", "replace_all": true }
      ]
    }
  ]
}
Parameter Type Default Description
files array required Array of file edit operations
files[].file_path string required Absolute path to the file
files[].edits array required Edits for this file (same format as above)
dry_run boolean false Preview changes without applying

Full usage guide with examples: docs/usage.md

Features

  • Atomic operations -- all edits succeed or none apply, no partial state
  • Multi-file rollback -- if any file fails, all previously changed files are restored
  • Dry-run preview -- see exactly what would change before committing
  • Automatic backups -- .bak files created before every edit (disable with backup: false)
  • Structured errors -- machine-readable error codes with recovery hints for automatic retry
  • Conflict detection -- warns when old_string matches multiple locations
  • Path validation -- absolute path enforcement, symlink resolution, existence checks

Error Codes

Code Retryable Description
MATCH_NOT_FOUND Yes old_string not found in file
AMBIGUOUS_MATCH Yes old_string matches multiple locations
VALIDATION_FAILED Yes Invalid input schema
FILE_NOT_FOUND No File does not exist
PERMISSION_DENIED No Insufficient file permissions
BACKUP_FAILED No Could not create backup file

When retryable is true, Claude reads the recovery_hints in the response, adjusts the input, and retries automatically.

Troubleshooting guide: docs/troubleshooting.md

Requirements

  • Node.js 20 or later
  • Claude Code or Claude Desktop

Development

npm install           # Install dependencies
npm run build         # Compile TypeScript
npm test              # Run 264 tests
npm run test:coverage # Coverage report (90%+)
npm run benchmark     # Run benchmark suite
npm run dev           # Watch mode

Project Structure

src/
  index.ts              # MCP server entry (stdio transport)
  server.ts             # Server factory and tool registration
  tools/
    multi-edit.ts       # multi_edit tool handler
    multi-edit-files.ts # multi_edit_files tool handler
  core/
    editor.ts           # File editing engine (atomic read-modify-write)
    validator.ts        # Zod input validation schemas
    reporter.ts         # Result formatting and diff generation
    errors.ts           # Error classification and envelope creation
  types/
    index.ts            # TypeScript type definitions

Documentation

Document Description
Installation Guide All setup options for Claude Code and Claude Desktop
Usage Guide Detailed tool reference with examples
Troubleshooting Common issues and solutions
Changelog Version history
Benchmark Report Performance measurements

License

PolyForm Noncommercial License 1.0.0

Free for personal and non-commercial use. For commercial licensing, contact support@essentialai.uk.


Built by Essential AI Solutions

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选