IntelliDiff MCP Server
Enables intelligent file and folder comparison with advanced text normalization, duplicate detection, and line-level diff analysis. Provides secure workspace-constrained file operations with CRC32-based exact matching and smart text comparison capabilities.
README
IntelliDiff MCP Server
An intelligent file and folder comparison MCP server with advanced text normalization and duplicate detection capabilities.
Features
- File Comparison: CRC32-based exact comparison and smart text comparison with normalization
- Folder Comparison: Recursive directory comparison with orphan detection
- Duplicate Detection: Find identical files within directories
- Text Normalization: Handle case, whitespace, tabs, line endings, and Unicode differences
- Line-Level Analysis: Detailed diff output with line ranges and targeted file reading
- Clean Output: Markdown-formatted text responses instead of JSON bloat
- Security: Workspace root validation prevents path traversal attacks
- Performance: Streaming for large files, configurable limits, symlink loop prevention
Installation
# Clone or download the project
cd intellidiff-mcp
# Install with uv
uv init --python 3.12
uv add "fastmcp>=2.11"
# Run the server
uv run python intellidiff_server.py /path/to/workspace/root
Project Structure
The server is built with a clean modular architecture:
intellidiff_server.py(52 lines) - Main server entry point and tool registrationworkspace_security.py- Path validation and workspace boundary enforcementfile_operations.py- Core file utilities (CRC32, text detection, normalization)tools.py- Individual MCP tool implementationsfolder_operations.py- Folder comparison and duplicate detection logic
MCP Configuration
Local/stdio Configuration
{
"mcpServers": {
"intellidiff": {
"type": "stdio",
"command": "uv",
"args": ["run", "--directory", "/path/to/intellidiff-mcp", "python", "intellidiff_server.py", "/workspace/root"]
}
}
}
Local/stdio Configuration with Environment Variables
{
"mcpServers": {
"intellidiff": {
"type": "stdio",
"command": "uv",
"args": ["run", "--directory", "/path/to/intellidiff-mcp", "python", "intellidiff_server.py", "/workspace/root"],
"env": {
"INTELLIDIFF_MAX_TEXT_SIZE": "5242880",
"INTELLIDIFF_MAX_BINARY_SIZE": "1073741824",
"INTELLIDIFF_MAX_DEPTH": "15",
"INTELLIDIFF_CHUNK_SIZE": "32768"
}
}
}
}
Remote/HTTP Configuration
{
"mcpServers": {
"intellidiff": {
"type": "http",
"url": "http://localhost:8000/mcp/"
}
}
}
Place this configuration in:
- VS Code:
.vscode/mcp.json(project) or user settings - Claude Desktop:
claude_desktop_config.json - Cursor:
.cursor/mcp.json(project) or~/.cursor/mcp.json(user) - LM Studio:
~/.lmstudio/mcp.json
Environment Variables
| Variable | Default | Description |
|---|---|---|
INTELLIDIFF_MAX_TEXT_SIZE |
10485760 (10MB) | Maximum size for text file comparison |
INTELLIDIFF_MAX_BINARY_SIZE |
1073741824 (1GB) | Maximum size for binary file CRC32 |
INTELLIDIFF_MAX_DEPTH |
10 | Maximum directory recursion depth |
INTELLIDIFF_CHUNK_SIZE |
65536 (64KB) | File reading chunk size |
Tools
validate_workspace_path
Validate that a path is within the workspace root.
Parameters:
path(string): Path to validate
get_file_hash
Get CRC32 hash and basic information about a file.
Parameters:
file_path(string): Path to the file
compare_files
Compare two files with various modes and options.
Parameters:
left_path(string): Path to first fileright_path(string): Path to second filemode(string): Comparison mode - "exact", "smart_text", or "binary"ignore_blank_lines(boolean): Skip empty lines during comparisonignore_newline_differences(boolean): Normalize line endingsignore_whitespace(boolean): Ignore leading/trailing whitespaceignore_case(boolean): Case-insensitive comparisonnormalize_tabs(boolean): Convert tabs to spacesunicode_normalize(boolean): Apply Unicode NFKC normalization
compare_folders
Compare two folder structures recursively.
Parameters:
left_path(string): Path to first folderright_path(string): Path to second foldermax_depth(integer): Maximum recursion depth (default: from env var)include_binary(boolean): Include binary files in comparisoncomparison_mode(string): "exact" or "smart_text"
find_identical_files
Find files with identical content within a folder.
Parameters:
folder_path(string): Path to folder to scanmax_depth(integer): Maximum recursion depth (default: from env var)
read_file_lines
Read specific line ranges from a text file with optional context.
Parameters:
file_path(string): Path to the text filestart_line(integer): Starting line number (1-based, default: 1)end_line(integer): Ending line number (1-based, default: end of file)context_lines(integer): Additional context lines before/after range (default: 0)
Usage Examples
Compare Two Files
# Exact comparison - clean markdown output
result = await client.call_tool("compare_files", {
"left_path": "file1.txt",
"right_path": "file2.txt",
"mode": "exact"
})
print(result.content[0].text)
# Output: ✅ **Exact Comparison**
# 📁 Left: file1.txt (CRC32: abc123)
# 📁 Right: file2.txt (CRC32: abc123)
# 🔍 Result: Identical
# Smart text comparison with normalization
result = await client.call_tool("compare_files", {
"left_path": "file1.txt",
"right_path": "file2.txt",
"mode": "smart_text",
"ignore_case": True,
"ignore_whitespace": True,
"normalize_tabs": True
})
print(result.content[0].text)
# Output: ✅ **Smart Text Comparison - Identical**
# 📁 Left: file1.txt (1.2KB)
# 📁 Right: file2.txt (1.3KB)
# 🔍 Result: Identical (normalized: case, whitespace, tabs)
Compare Folders
result = await client.call_tool("compare_folders", {
"left_path": "folder_a",
"right_path": "folder_b",
"max_depth": 5
})
# Folder comparison returns structured data for programmatic access
summary = result.data["summary"]
orphans = result.data["orphans"]
identical_files = result.data["identical_files"]
Find Duplicates
result = await client.call_tool("find_identical_files", {
"folder_path": "my_folder",
"max_depth": 10
})
# Duplicate detection returns structured data for analysis
duplicates = result.data["duplicates"]
wasted_bytes = result.data["summary"]["total_wasted_bytes"]
Read Specific Lines
# Read lines 10-20 with 2 lines of context
result = await client.call_tool("read_file_lines", {
"file_path": "my_file.txt",
"start_line": 10,
"end_line": 20,
"context_lines": 2
})
# Clean line-numbered output with >>> markers for requested range
print(result.content[0].text)
# Output: 8| function setup() {
# 9| console.log("Starting...");
# >>> 10| const data = loadData();
# >>> 11| if (!data) {
# >>> 12| throw new Error("No data");
# >>> 13| }
# 14| }
Working with Diff Results
# Compare files and get detailed diff information
result = await client.call_tool("compare_files", {
"left_path": "file1.txt",
"right_path": "file2.txt",
"mode": "smart_text"
})
# Access structured diff data
if not result.structured_content["identical"]:
change_summary = result.structured_content["change_summary"]
# Get affected line ranges
left_ranges = change_summary["line_ranges"]["left_affected"]
right_ranges = change_summary["line_ranges"]["right_affected"]
# Read specific sections that changed
for range_info in left_ranges:
lines_result = await client.call_tool("read_file_lines", {
"file_path": "file1.txt",
"start_line": range_info["start"],
"end_line": range_info["end"],
"context_lines": 3
})
print(f"Changed section: {lines_result.content[0].text}")
Security
- All file paths are validated against the workspace root
- Path traversal attacks are prevented through path resolution
- Symlink loops are detected and avoided
- File size limits prevent memory exhaustion
- Read-only operations only
Performance
- Streaming I/O for large files
- Early exit on size mismatches
- CRC32 caching for repeated operations
- Configurable chunk sizes and limits
- Progress reporting for large operations
License
MIT License - see LICENSE file for details.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。