@compare-json/cli provides an MCP (Model Context Protocol) server for AI assistants to compare JSON values programmatically.
Add the following to your MCP client config (e.g. mcp.json):
{
"mcpServers": {
"compare-json": {
"command": "npx",
"args": ["@compare-json/cli@latest", "--mcp"]
}
}
}
compare_jsonCompare two JSON values and return their differences.
Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
baseJSON | any | No | Base JSON value |
baseJSONString | string | No | Base stringified JSON value |
baseJSONFilePath | string | No | Base JSON file path |
contrastJSON | any | No | Contrast JSON value |
contrastJSONString | string | No | Contrast stringified JSON value |
contrastJSONFilePath | string | No | Contrast JSON file path |
options | object | No | Comparison options |
At least one base and one contrast input must be provided.
Options:
| Option | Type | Default | Description |
|---|---|---|---|
arrayCompareMethod | byIndex / lcs / unordered | byIndex | Array comparison method |
keyCaseInsensitive | boolean | false | Case insensitive key comparison |
valueCaseInsensitive | boolean | false | Case insensitive value comparison |
numericStringEqualsNumber | boolean | false | Treat numeric strings as numbers |
Output:
Returns an array of JSONValueDifference objects:
{
"differences": [
{
"pathSegments": ["name"],
"pathString": "name",
"pathBelongsTo": "both",
"diffType": "valueChanged"
}
]
}