- Home
- MCP servers
- Patch
Patch
- python
1
GitHub Stars
python
Language
6 months ago
First Indexed
2 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Installation
Add the following to your MCP client configuration file.
Configuration
View docs{
"mcpServers": {
"shenning00-patch_mcp": {
"command": "python",
"args": [
"-m",
"patch_mcp"
]
}
}
}Patch MCP Server enables an AI assistant to safely apply unified diff patches to files with built-in validation, backups, and rollback. It provides atomic multi-hunk patches, dry-run testing, and strong security checks to prevent unsafe modifications, giving you reliable patch management for local projects.
How to use
You interact with Patch MCP Server through an MCP client to apply, validate, inspect, or revert patches. Start by running the server locally and then issue patch operations from your client whenever you need to modify files in a controlled, auditable way. All actions support automatic backups and safety checks so you can test changes before they are committed.
How to install
Prerequisites: Python 3.8+ and a working environment for running Python modules.
-
Clone the project repository to your machine.
-
Create and activate a Python virtual environment.
-
Install the package in editable mode with development dependencies.
-
Run the server in standalone mode so it communicates via the Model Context Protocol.
Configuration and usage notes
Configure your MCP client to connect to the local Patch MCP Server using stdio mode. The server runs as a local process and can be started from the command line.
# Start the server locally
python -m patch_mcp
Security and reliability
All operations include security checks to prevent unsafe changes. The server rejects symlinks, binary files, and path traversals, enforces maximum file sizes, validates available disk space, and ensures atomic file replacements so partial patches cannot leave files in an inconsistent state.
Troubleshooting
If a patch cannot be applied, revert to the most recent backup before trying again. Ensure the patch accurately matches the target file and that the patch is valid for the current file state.
Available tools
apply_patch
Apply a unified diff patch to a file with support for multi-hunk patches, dry-run testing, and automatic validation.
validate_patch
Check if a patch can be applied without modifying files, including context mismatch detection and preview of changes.
revert_patch
Reverse a previously applied patch, supporting multi-hunk patches and requiring the original patch.
generate_patch
Create a patch from two file versions in standard unified diff format with configurable context.
inspect_patch
Analyze patch content without applying changes to files, listing affected files and patch structure.
backup_file
Create timestamped backups of files before applying patches, preserving metadata.
restore_backup
Restore from backups with safety checks to prevent unintended overwrites.