
Unified Diff MCP Server
โ 12from gorosun
Beautiful HTML and PNG diff visualization using diff2html, designed for filesystem edit_file dry-run output with high-performance Bun runtime.
Unified Diff MCP Server
Beautiful diff visualization for Claude Desktop. Transform code diffs into stunning visual comparisons with GitHub Gist integration and local file output.
<img src="examples/screenshot.png" alt="Unified Diff Visualization Screenshot" width="800" style="max-width: 100%; height: auto;">โจ Features
- ๐จ Beautiful HTML diff visualization using diff2html
- ๐ GitHub Gist integration for instant sharing
- ๐ Local file output (PNG/HTML)
- ๐ Auto-delete functionality for temporary diffs
- ๐ฅ๏ธ Cross-platform support (Windows, macOS, Linux)
- โก High-performance with Bun runtime
- ๐ก๏ธ Enhanced Security with multi-level protection for shared diffs
- ๐ Multi-level security (Low/Medium/High) for different use cases
๐ ๏ธ Tools Overview
| Tool | Purpose | Output | Best For |
|---|---|---|---|
visualize_diff_html_content | Browser display & sharing | GitHub Gist + HTML preview URL | Quick sharing, instant viewing |
visualize_diff_output_file | Local file storage | PNG/HTML files | Local storage, presentations |
๐ Parameters Reference
Common Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
diff | string | (required) | Unified diff text |
format | string | side-by-side | Display format (line-by-line or side-by-side) |
showFileList | boolean | true | Show file list summary |
highlight | boolean | true | Enable syntax highlighting |
oldPath | string | file.txt | Original file path |
newPath | string | file.txt | Modified file path |
autoOpen | boolean | false | Auto-open in browser |
GitHub Gist Specific
| Parameter | Type | Default | Description |
|---|---|---|---|
expiryMinutes | number | 30 | Auto-delete time (1-1440 minutes) |
public | boolean | false | Public vs secret gist |
Local File Specific
| Parameter | Type | Default | Description |
|---|---|---|---|
outputType | string | html | Output format (html or image) |
๐ Platform Support
| Platform | Auto-Open | Commands |
|---|---|---|
| Windows | โ | start (primary), explorer (fallback) |
| macOS | โ | open (primary), AppleScript (fallback) |
| Linux | โ | xdg-open |
๐ง Development
Development mode (with hot reload):
{
"command": "bun",
"args": ["--watch", "/path/to/unified-diff-mcp/src/index.ts"]
}Production mode:
{
"command": "bun",
"args": ["run", "/path/to/unified-diff-mcp/src/index.ts"]
}๐ค Supported Clients
- Claude Desktop (Primary)
- Claude Code (CLI)
- VS Code + MCP Extension
- Cline and other MCP clients
๐ License
MIT License - see LICENSE file for details.
Dependencies
| Library | License | Purpose |
|---|---|---|
| diff2html | MIT | HTML diff generation |
| playwright-core | Apache 2.0 | Browser automation |
| @modelcontextprotocol/sdk | MIT | MCP integration |
Made with โค๏ธ for the Claude Desktop community
๐ Quick Start
Installing via Smithery
bunx @smithery/cli install @gorosun/unified-diff-mcp --client claude --config '{
"defaultAutoOpen": true,
"defaultOutputMode": "html",
"githubUsername": "your_actual_github_username",
"githubToken": "ghp_your_actual_token_here"
}'Manual Installation
- Install Claude Desktop and Bun
- Clone and build:
git clone https://github.com/gorosun/unified-diff-mcp.git cd unified-diff-mcp bun install - Configure Claude Desktop - see Configuration below
๐ Usage Examples
๐ฏ Optimal Prompts by Purpose
| Purpose | Recommended Prompt | Tool Used | Output |
|---|---|---|---|
| Quick Preview | Please visualize and preview the following diff:<br>ไปฅไธใฎdiffใๅฏ่ฆๅใใฆใใฌใใฅใผใใฆใใ ใใ | visualize_diff_html_content | GitHub Gist + HTML preview URL |
| Local Storage | Please visualize and save the following diff to a file:<br>ไปฅไธใฎdiffใๅฏ่ฆๅใใฆใใกใคใซใซไฟๅญใใฆใใ ใใ | visualize_diff_output_file | Local HTML/PNG file |
| Share with Others | Please visualize the following diff and create a shareable link:<br>ไปฅไธใฎdiffใๅฏ่ฆๅใใฆๅ
ฑๆใชใณใฏใไฝๆใใฆใใ ใใ | visualize_diff_html_content | GitHub Gist with shareable URL |
| Image Export | Please visualize and save the following diff as a PNG image:<br>ไปฅไธใฎdiffใๅฏ่ฆๅใใฆPNG็ปๅใงไฟๅญใใฆใใ ใใ | visualize_diff_output_file | Local PNG image |
| Code Review | Please visualize the following diff in side-by-side format:<br>ไปฅไธใฎdiffใside-by-sideๅฝขๅผใงๅฏ่ฆๅใใฆใใ ใใ | Either tool | Side-by-side comparison |
| Documentation | Please visualize and save the following diff as an HTML file:<br>ไปฅไธใฎdiffใๅฏ่ฆๅใใฆHTMLใใกใคใซใงไฟๅญใใฆใใ ใใ | visualize_diff_output_file | Local HTML file |
| ๐ Secure Sharing | Please visualize this diff with high security:<br>ไปฅไธใฎdiffใ้ซใปใญใฅใชใใฃใงๅฏ่ฆๅใใฆใใ ใใ | visualize_diff_html_content | Secret Gist with auto-delete |
Share diff instantly (GitHub Gist)
visualize_diff_html_content:
- Creates temporary GitHub Gist
- Auto-deletes after 30 minutes
- Instant browser-ready URLs
- Perfect for code reviewsSave diff locally
visualize_diff_output_file:
- Saves PNG or HTML to local disk
- Auto-opens in browser (optional)
- Perfect for documentation๐๏ธ Configuration
Environment Variables
| Variable | Description | Default |
|---|---|---|
GITHUB_TOKEN | GitHub Personal Access Token (for Gist integration) | Required for visualize_diff_html_content |
DEFAULT_AUTO_OPEN | Auto-open generated files | false |
DEFAULT_OUTPUT_MODE | Default output format (html or image) | html |
GitHub Token Setup
- Go to GitHub Settings > Personal Access Tokens
- Generate new token with
gistscope - Add to your environment:
export GITHUB_TOKEN="your_token_here"
Claude Desktop Configuration
macOS:
code ~/Library/Application\ Support/Claude/claude_desktop_config.jsonWindows:
code %APPDATA%\Claude\claude_desktop_config.jsonConfiguration template:
{
"mcpServers": {
"unified-diff-mcp": {
"command": "bun",
"args": ["run", "/path/to/unified-diff-mcp/src/index.ts"],
"env": {
"GITHUB_TOKEN": "your_github_token_here",
"DEFAULT_AUTO_OPEN": "true",
"DEFAULT_OUTPUT_MODE": "html"
}
}
}
}๐ Advanced Usage
๐ Enhanced Security Levels
When GitHub Token isn't available or for secure sharing, you can choose from multiple security levels:
| Security Level | Configuration | Features | Use Cases |
|---|---|---|---|
| ๐ข Low | Secret Gist + 60min auto-delete | URL-only access | Code examples, learning |
| ๐ก Medium | Secret Gist + Password + 30min auto-delete | URL + Access code required | Team reviews |
| ๐ด High | Secret Gist + Password + 15min auto-delete | URL + Access code + Short duration | Sensitive code |
Usage Example
Please visualize this diff with high security:
--- a/config.js
+++ b/config.js
@@ -1,3 +1,4 @@
const config = {
- apiKey: 'old-key'
+ apiKey: 'new-secure-key',
+ timeout: 5000
};Response Example:
๐ **Secure Diff Visualization**
๐ด **Security Level**: High Security - Secret Gist + Password (15min auto-delete)
๐ **Preview Link**: https://htmlpreview.github.io/?...
๐ **Access Code**: `a7x9k2`
โฐ **Auto-delete**: 15 minutes๐ Fallback Functionality
When GitHub Token is unavailable, the system falls back to local files:
- HTML saved as temporary file
- Automatic browser opening
- Security-based file management
For detailed setup and integration guides:
- ๐บ๐ธ English: CLAUDE_CODE_INTEGRATION.md
- ๐ฏ๐ต ๆฅๆฌ่ช: CLAUDE_CODE_INTEGRATION_JP.md
No common issues documented yet. If you hit a problem, the repository's GitHub Issues page is the best place to look.