abnerjacobsen/deepdiff-mcp
If you are the rightful owner of deepdiff-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The DeepDiff MCP Server allows users to leverage the DeepDiff library's functionality through the Model Context Protocol, facilitating seamless interaction with DeepDiff from any MCP client.
compare
Compare two objects and return their differences.
get_deep_distance
Calculate the deep distance between two objects.
search
Search for an item within an object.
grep
Search for an item within an object using grep-like behavior.
hash_object
Hash an object based on its contents.
create_delta
Create a delta that can transform one object into another.
apply_delta
Apply a delta to transform an object.
extract_path
Extract a value from an object using a path.
compare_files
Compare two CSV, Excel, or JSON files directly.
DeepDiff MCP Server
An MCP (Model Context Protocol) server for the DeepDiff library. This server allows you to use DeepDiff functionality through the Model Context Protocol, enabling interaction with DeepDiff from any MCP client.
Installation
Using pip
pip install deepdiff-mcp
Using uv (recommended)
uv pip install deepdiff-mcp
Usage
Running the server
You can run the DeepDiff MCP server in several ways:
As a command-line tool
# Using stdio transport (default)
deepdiff-mcp
# Using HTTP transport
deepdiff-mcp --transport http --host 127.0.0.1 --port 8000
# Using SSE transport
deepdiff-mcp --transport sse --host 127.0.0.1 --port 8000
As a Python module
from deepdiff_mcp import create_server
# Create a DeepDiff MCP server
server = create_server("My DeepDiff Server")
# Run the server with stdio transport (default)
server.run()
# Or with HTTP transport
server.run(transport="http", host="127.0.0.1", port=8000, path="/mcp")
# Or with SSE transport
server.run(transport="sse", host="127.0.0.1", port=8000)
Connecting to the server
You can connect to the server using any MCP client. Here's an example using FastMCP:
import asyncio
from fastmcp import Client
async def main():
# Connect to a DeepDiff MCP server running as a subprocess
async with Client("deepdiff-mcp") as client:
# List available tools
tools = await client.list_tools()
print(f"Available tools: {[tool.name for tool in tools]}")
# Compare two dictionaries
t1 = {"a": 1, "b": 2}
t2 = {"a": 1, "b": 3, "c": 4}
result = await client.call_tool("compare", {"t1": t1, "t2": t2})
print(f"Differences: {result.text}")
if __name__ == "__main__":
asyncio.run(main())
Available Tools
compare_files
- Compare two CSV, Excel, or JSON files directly
The DeepDiff MCP server provides the following tools:
compare
- Compare two objects and return their differencesget_deep_distance
- Calculate the deep distance between two objectssearch
- Search for an item within an objectgrep
- Search for an item within an object using grep-like behaviorhash_object
- Hash an object based on its contentscreate_delta
- Create a delta that can transform one object into anotherapply_delta
- Apply a delta to transform an objectextract_path
- Extract a value from an object using a path
Documentation
For more information about DeepDiff, see the DeepDiff documentation.
For more information about MCP and FastMCP, see the Model Context Protocol and FastMCP documentation.
Comparando Arquivos CSV e Excel
O DeepDiff MCP suporta comparação direta de arquivos CSV, Excel e JSON:
import asyncio
from fastmcp import Client
async def main():
async with Client("deepdiff-mcp") as client:
# Compare dois arquivos CSV
result = await client.call_tool(
"compare_files",
{
"file1_path": "caminho/para/arquivo1.csv",
"file2_path": "caminho/para/arquivo2.csv",
"ignore_order": True # Ignorar a ordem das linhas
}
)
print(f"Diferenças: {result.text}")
# Compare arquivos Excel
excel_result = await client.call_tool(
"compare_files",
{
"file1_path": "caminho/para/arquivo1.xlsx",
"file2_path": "caminho/para/arquivo2.xlsx"
}
)
print(f"Diferenças: {excel_result.text}")
if __name__ == "__main__":
asyncio.run(main())
Esta funcionalidade é especialmente útil para análise de dados e verificação de integridade de dados em pipelines.