A Model Context Protocol (MCP) server for code diffing with intelligent token optimization
npm install codiff-mcpjson
{
"mcpServers": {
"codiff-mcp": {
"command": "npx",
"args": ["-y", "codiff-mcp@latest"]
}
}
}
`
$3
Smart delegation to LLM for efficiency:
`json
{
"mcpServers": {
"codiff-mcp": {
"command": "npx",
"args": ["-y", "codiff-mcp@latest", "--save-tokens"]
}
}
}
`
$3
⚠️ Includes unchanged text (may increase costs):
`json
{
"mcpServers": {
"codiff-mcp": {
"command": "npx",
"args": ["-y", "codiff-mcp@latest", "--accuracy"]
}
}
}
`
Usage
The codiff tool compares two text inputs:
- original: Baseline text
- modified: Updated text
$3
| Mode | Flags | Behavior |
|------|-------|----------|
| Standard | (default) | Shows only changes, warns about costs |
| Token-Saving | --save-tokens, -s | Delegates small/similar diffs to LLM |
| Accuracy | --accuracy, -a | Includes unchanged text ⚠️ |
| Combined | -s -a | Smart delegation + full context |
Examples
$3
`json
{
"result": "identical",
"message": "The provided texts are identical - no differences found.",
"savings": { "estimatedSavings": 5 }
}
`
$3
`json
{
"diff": [
{"type": "delete", "text": "Hello world\n"},
{"type": "insert", "text": "Hello beautiful world\n"}
],
"mode": "standard",
"savings": { "estimatedSavings": 5 }
}
`
$3
`json
{
"warnings": [
"INCREASED COST: This diff costs 5 more tokens than sending the original texts."
]
}
`
$3
`json
{
"result": "delegate_to_llm",
"message": "For optimal token efficiency, please analyze these texts directly...",
"recommendation": "Compare manually by scanning for differences..."
}
`
Auto-Usage Rule
Add to .cursorrules for automatic diffing:
`json
{
"rules": {
"general_rules": [
{
"description": "When the user requests comparisons, diffs, or change analysis, ALWAYS use the codiff MCP tool first. Use for file comparisons, version analysis, and any request involving 'compare', 'diff', 'changes', or 'differences'.",
"type": "tool_prioritization_codiff"
}
]
}
}
`
Development
`bash
npm run start # Standard mode
npm run start:save-tokens # Token-saving mode
npm run start:accuracy # Accuracy mode
npm run start:full # Combined mode
``