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:
| 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 |
Provide at least one Base input and one Contrast input. File paths are resolved in the environment where the MCP server runs.
Options:
| Option | Type | Default | Description |
|---|---|---|---|
arrayCompareMethod | byIndex / lcs / unordered | byIndex | Repeated-element comparison method |
keyCaseInsensitive | boolean | false | Case-insensitive element and attribute names |
valueCaseInsensitive | boolean | false | Case-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.