Compare JSON

Created By
unitstack2 days ago
A lightweight, dependency-free MCP for deep comparison of JSON values. Detects additions, deletions, type changes, and value changes between two JSON structures with fine-grained control over comparison behavior.
Overview

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:

ParameterTypeRequiredDescription
baseJSONanyconditionalBase JSON value (already parsed).
baseJSONStringstringconditionalBase JSON as a stringified value (parsed by the server).
baseJSONFilePathstringconditionalPath to a base JSON file (read and parsed by the server).
contrastJSONanyconditionalContrast JSON value (already parsed).
contrastJSONStringstringconditionalContrast JSON as a stringified value.
contrastJSONFilePathstringconditionalPath to a contrast JSON file.
optionsobjectNoComparison 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:

OptionTypeDefaultDescription
arrayCompareMethod'byIndex' | 'lcs' | 'unordered''byIndex'Array comparison strategy.
keyCaseInsensitivebooleanfalseCase-insensitive key comparison.
valueCaseInsensitivebooleanfalseCase-insensitive value comparison.
numericStringEqualsNumberbooleanfalseTreat 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"
      ]
    }
  }
}
Project Info
Created At
2 days ago
Updated At
2 days ago
Author Name
unitstack
Star
-
Language
-
License
-
Category
Tags

Recommend Servers

View All
Conductor Relay

11 hours ago
Hh

10 hours ago
Kairos Signal

6 hours ago
Conductor Relay

10 hours ago
Tavily Mcp
@tavily-ai

JavaScript
a year ago