io.github.eaisdevelopment/mcp-multi-edit
编码与调试by eaisdevelopment
支持原子化跨多文件查找替换,减少约 80% tool calls,并降低约 50% context 使用。
什么是 io.github.eaisdevelopment/mcp-multi-edit?
支持原子化跨多文件查找替换,减少约 80% tool calls,并降低约 50% context 使用。
README
Multi Edit MCP Server
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
mcpServersas 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.jsonapproach 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 --
.bakfiles created before every edit (disable withbackup: false) - Structured errors -- machine-readable error codes with recovery hints for automatic retry
- Conflict detection -- warns when
old_stringmatches 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
常见问题
io.github.eaisdevelopment/mcp-multi-edit 是什么?
支持原子化跨多文件查找替换,减少约 80% tool calls,并降低约 50% context 使用。
相关 Skills
网页构建器
by anthropics
面向复杂 claude.ai HTML artifact 开发,快速初始化 React + Tailwind CSS + shadcn/ui 项目并打包为单文件 HTML,适合需要状态管理、路由或多组件交互的页面。
✎ 在 claude.ai 里做复杂网页 Artifact 很省心,多组件、状态和路由都能顺手搭起来,React、Tailwind 与 shadcn/ui 组合效率高、成品也更精致。
前端设计
by anthropics
面向组件、页面、海报和 Web 应用开发,按鲜明视觉方向生成可直接落地的前端代码与高质感 UI,适合做 landing page、Dashboard 或美化现有界面,避开千篇一律的 AI 审美。
✎ 想把页面做得既能上线又有设计感,就用前端设计:组件到整站都能产出,难得的是能避开千篇一律的 AI 味。
网页应用测试
by anthropics
用 Playwright 为本地 Web 应用编写自动化测试,支持启动开发服务器、校验前端交互、排查 UI 异常、抓取截图与浏览器日志,适合调试动态页面和回归验证。
✎ 借助 Playwright 一站式验证本地 Web 应用前端功能,调 UI 时还能同步查看日志和截图,定位问题更快。
相关 MCP Server
GitHub
编辑精选by GitHub
GitHub 是 MCP 官方参考服务器,让 Claude 直接读写你的代码仓库和 Issues。
✎ 这个参考服务器解决了开发者想让 AI 安全访问 GitHub 数据的问题,适合需要自动化代码审查或 Issue 管理的团队。但注意它只是参考实现,生产环境得自己加固安全。
Context7 文档查询
编辑精选by Context7
Context7 是实时拉取最新文档和代码示例的智能助手,让你告别过时资料。
✎ 它能解决开发者查找文档时信息滞后的问题,特别适合快速上手新库或跟进更新。不过,依赖外部源可能导致偶尔的数据延迟,建议结合官方文档使用。
by tldraw
tldraw 是让 AI 助手直接在无限画布上绘图和协作的 MCP 服务器。
✎ 这解决了 AI 只能输出文本、无法视觉化协作的痛点——想象让 Claude 帮你画流程图或白板讨论。最适合需要快速原型设计或头脑风暴的开发者。不过,目前它只是个基础连接器,你得自己搭建画布应用才能发挥全部潜力。