MCP (Model Context Protocol)

@compare-xml/cli provides an MCP (Model Context Protocol) server for AI assistants to compare XML documents programmatically.

MCP Client Configuration

Add the following to your MCP client config (e.g. mcp.json):

{
  "mcpServers": {
    "compare-xml": {
      "command": "npx",
      "args": ["@compare-xml/cli@latest", "--mcp"]
    }
  }
}

Available Tools

compare_xml

Compare two XML documents and return their differences.

Input:

ParameterTypeRequiredDescription
baseXMLStringstringNoBase XML string
baseXMLFilePathstringNoBase XML file path
contrastXMLStringstringNoContrast XML string
contrastXMLFilePathstringNoContrast XML file path
optionsobjectNoComparison options

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

Options:

OptionTypeDefaultDescription
arrayCompareMethodbyIndex / lcs / unorderedbyIndexRepeated-element comparison method
keyCaseInsensitivebooleanfalseCase insensitive tag/attribute name comparison
valueCaseInsensitivebooleanfalseCase insensitive value comparison

Output:

Returns an array of XMLValueDifference objects:

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