@compare-xml/cli provides an MCP (Model Context Protocol) server for AI assistants to compare XML documents programmatically.
Add the following to your MCP client config (e.g. mcp.json):
{
"mcpServers": {
"compare-xml": {
"command": "npx",
"args": ["@compare-xml/cli@latest", "--mcp"]
}
}
}
compare_xmlCompare two XML documents and return their differences.
Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
baseXMLString | string | No | Base XML string |
baseXMLFilePath | string | No | Base XML file path |
contrastXMLString | string | No | Contrast XML string |
contrastXMLFilePath | string | No | Contrast XML file path |
options | object | No | Comparison options |
At least one base and one contrast input must be provided.
Options:
| Option | Type | Default | Description |
|---|---|---|---|
arrayCompareMethod | byIndex / lcs / unordered | byIndex | Repeated-element comparison method |
keyCaseInsensitive | boolean | false | Case insensitive tag/attribute name comparison |
valueCaseInsensitive | boolean | false | Case insensitive value comparison |
Output:
Returns an array of XMLValueDifference objects:
{
"differences": [
{
"pathSegments": ["root", "name"],
"pathString": "root.name",
"pathBelongsTo": "both",
"diffType": "valueChanged"
}
]
}