MCP (Model Context Protocol)

@compare-json/cli provides an MCP (Model Context Protocol) server for AI assistants to compare JSON values programmatically.

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"]
    }
  }
}

Available Tools

compare_json

Compare two JSON values and return their differences.

Input:

ParameterTypeRequiredDescription
baseJSONanyNoBase JSON value
baseJSONStringstringNoBase stringified JSON value
baseJSONFilePathstringNoBase JSON file path
contrastJSONanyNoContrast JSON value
contrastJSONStringstringNoContrast stringified JSON value
contrastJSONFilePathstringNoContrast JSON file path
optionsobjectNoComparison options

At least one base and one contrast input must be provided.

Options:

OptionTypeDefaultDescription
arrayCompareMethodbyIndex / lcs / unorderedbyIndexArray comparison method
keyCaseInsensitivebooleanfalseCase insensitive key comparison
valueCaseInsensitivebooleanfalseCase insensitive value comparison
numericStringEqualsNumberbooleanfalseTreat numeric strings as numbers

Output:

Returns an array of JSONValueDifference objects:

{
  "differences": [
    {
      "pathSegments": ["name"],
      "pathString": "name",
      "pathBelongsTo": "both",
      "diffType": "valueChanged"
    }
  ]
}