What is Patch File MCP?
Patch File MCP is an MCP server that enables AI agents (like Claude) to make precise changes to files in projects using a block-based patch format. It provides a single tool for applying targeted edits without rewriting entire files, with built-in safety through exact text matching and uniqueness verification.
How to use Patch File MCP?
Install with uvx or from source, then configure your MCP client (e.g., Claude Desktop) by adding a "patch-file" entry in the mcpServers JSON config with the command and --allowed-dir arguments. The server starts automatically when the client uses it; no manual launch is needed. Use the patch_file tool with a file path and patch content formatted in SEARCH/REPLACE blocks.
Key features of Patch File MCP
- Applies multiple search-replace blocks in a single request.
- Verifies each search text appears exactly once in the file.
- Restricts file operations to allowed directories only.
- Provides clear error messages when a patch cannot be applied.
- Designed as a safer alternative to
edit_block from desktop-commander.
Use cases of Patch File MCP
- An AI agent refactoring a function inside a source code file without touching other parts.
- Applying a series of configuration changes to a project file in one chat turn.
- Fixing a bug by replacing specific lines inside a large log or data file.
- Updating documentation snippets across multiple files in a codebase.
コメント