XML MCP Server

Expose XML comparison to AI assistants through the Model Context Protocol.

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

MCP Client Configuration

Add the following to your MCP client configuration, such as mcp.json:

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

The server uses stdio transport. Your MCP client starts the CLI process and exposes its XML comparison tool to the assistant.

Available Tool

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

Provide at least one Base input and one Contrast input. File paths are resolved in the environment where the MCP server runs.

Options:

OptionTypeDefaultDescription
arrayCompareMethodbyIndex / lcs / unorderedbyIndexRepeated-element comparison method
keyCaseInsensitivebooleanfalseCase-insensitive element and attribute names
valueCaseInsensitivebooleanfalseCase-insensitive text and attribute values

Unordered comparison ignores order while preserving duplicate occurrence counts.

Output:

The tool returns an XMLValueDifference array in its differences result:

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

See the CLI guide for direct terminal usage and @compare-xml/core for the difference object API.