
An MCP Server to patch existing files using block format
An MCP Server to patch existing files using block format
An MCP Server to patch existing files using block format. This allows AI agents (like Claude) to make precise changes to files in your projects.
Patch File MCP provides a simple way to modify files by applying patches in block format. The key benefits include:
edit_block tool from desktop-commander for most file editing tasksThis method uses uvx (from the uv Python package manager) to run the server without permanent installation:
Install uvx from uv if you don't have it already.
Merge the following config with your existing config file (e.g. claude_desktop_config.json):
{
"mcpServers": {
"patch-file": {
"command": "uvx",
"args": [
"patch-file-mcp",
"--allowed-dir", "/Users/your-username/projects",
"--allowed-dir", "/Users/your-username/Documents/code"
]
}
}
}Note: Replace
/Users/your-usernamewith the actual path to your own projects and code directories.
git clone https://github.com/your-username/patch-file-mcp.git
cd patch-file-mcp
python -m venv venv
source venv/bin/activate
pip install -e .Merge the following config with your existing config file (e.g. claude_desktop_config.json):
{
"mcpServers": {
"patch-file": {
"command": "path/to/your/venv/bin/patch-file-mcp",
"args": [
"--allowed-dir", "/Users/your-username/projects",
"--allowed-dir", "/Users/your-username/Documents/code"
]
}
}
}Note: Replace
/Users/your-usernamewith the actual path to your own projects and code directories.
The --allowed-dir argument is used to specify the directories that the server has access to. You can use it multiple times to allow access to multiple directories. All directories inside the allowed directories are also allowed.
It is optional. If not provided, the server will only have access to the home directory of the user running the server.
The MCP server is started by the client (e.g., Claude Desktop) based on the configuration you provide. You don't need to start the server manually.
Patch File MCP provides one main tool:
Update the file by applying a patch/edit to it using block format.
patch_file(file_path: str, patch_content: str)The patch content must have the following format:
<<<<<<< SEARCH
Text to find in the file
=======
Text to replace it with
>>>>>>> REPLACEYou can include multiple search-replace blocks in a single request:
<<<<<<< SEARCH
First text to find
=======
First replacement
>>>>>>> REPLACE
<<<<<<< SEARCH
Second text to find
=======
Second replacement
>>>>>>> REPLACEThis tool verifies that each search text appears exactly once in the file to ensure the correct section is modified. If a search text appears multiple times or isn't found, it will report an error.
patch_file to apply these changes to your fileMIT
Pick your client and paste the snippet. Each one is the same server, written the way that client expects it.
claude mcp add patch-file -- uvx patch-file-mcp --allowed-dir /Users/your-username/projects --allowed-dir /Users/your-username/Documents/code{
"mcpServers": {
"patch-file": {
"args": [
"patch-file-mcp",
"--allowed-dir",
"/Users/your-username/projects",
"--allowed-dir",
"/Users/your-username/Documents/code"
],
"command": "uvx"
}
}
}code --add-mcp '{"name":"patch-file","args":["patch-file-mcp","--allowed-dir","/Users/your-username/projects","--allowed-dir","/Users/your-username/Documents/code"],"command":"uvx"}'[mcp_servers.patch-file]
command = "uvx"
args = ["patch-file-mcp", "--allowed-dir", "/Users/your-username/projects", "--allowed-dir", "/Users/your-username/Documents/code"]Runs locally on your device. Your client starts the server itself, so nothing has to be hosted.
Paste this prompt into your agent. It reads this page and does the setup for you.
Read https://aiagentslisting.com/mcp/patch-file-mcp to learn what the "Patch File MCP" MCP server does and how to install it. Add it to my coding agent's MCP configuration as documented on that page, then confirm the server connects and list the tools it exposes.Agents can also browse this directory over MCP at https://aiagentslisting.com/api/mcp
This server runs locally, so we can't read its tool list over the web yet.
Maintain this server? Claiming proves you own the listing and earns the last 4 points.
Claim this listingPaste this line near the top of your repository's README. The badge always renders the current score.
[](https://aiagentslisting.com/mcp/patch-file-mcp)Nothing comparable is listed yet.
v0.1.0Release notesConnect to the AI Agents Listing MCP server at https://aiagentslisting.com/api/mcp using the HTTP transport and complete the sign-in when it asks. Then call the submit_review tool for the listing "patch-file-mcp" with a rating from 1 to 5 and a short note on what worked and what did not.No reviews yet
Be the first to share your experience with this tool.
One email a week. New agents, MCP servers and skills, and what is actually getting traction.