- Compare JSON
Compare JSON
MCP Server
@compare-json/cli also ships an MCP (Model Context Protocol) server that exposes the comparison engine as a tool for AI assistants.
Online Playground
Try it out at https://comparejson.com
Start the MCP Server
# from a global install
compare-json --mcp
# or via npx
npx @compare-json/cli --mcp
The server communicates over stdio.
Available Tools
compare_json
Compare two JSON values and return their differences.
Input parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
baseJSON | any | conditional | Base JSON value (already parsed). |
baseJSONString | string | conditional | Base JSON as a stringified value (parsed by the server). |
baseJSONFilePath | string | conditional | Path to a base JSON file (read and parsed by the server). |
contrastJSON | any | conditional | Contrast JSON value (already parsed). |
contrastJSONString | string | conditional | Contrast JSON as a stringified value. |
contrastJSONFilePath | string | conditional | Path to a contrast JSON file. |
options | object | No | Comparison options (see below). |
At least one of baseJSON / baseJSONString / baseJSONFilePath must be provided, and at least one of contrastJSON / contrastJSONString / contrastJSONFilePath. When more than one is set for a side, file path takes precedence, then string, then raw value.
Options:
| Option | Type | Default | Description |
|---|---|---|---|
arrayCompareMethod | 'byIndex' | 'lcs' | 'unordered' | 'byIndex' | Array comparison strategy. |
keyCaseInsensitive | boolean | false | Case-insensitive key comparison. |
valueCaseInsensitive | boolean | false | Case-insensitive value comparison. |
numericStringEqualsNumber | boolean | false | Treat numeric strings as equal to numbers. |
Output:
Returns structuredContent.differences — an array of JSONValueDifference objects — and a content[0].text mirror of the same data as JSON text.
{
"differences": [
{
"pathSegments": ["name"],
"pathString": "name",
"pathBelongsTo": "both",
"diffType": "valueChanged"
}
]
}
MCP Client Configuration
Add the following to your MCP client config (e.g. mcp.json):
{
"mcpServers": {
"compare-json": {
"command": "npx",
"args": ["@compare-json/cli@latest", "--mcp"]
}
}
}
Server Config
{
"mcpServers": {
"compare-json": {
"command": "npx",
"args": [
"@compare-json/cli@latest",
"--mcp"
]
}
}
}Recommend Servers
View Alltest
A Serper MCP Server
Playwright MCP server