HTML MCP Server

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

@compare-html/cli includes an MCP (Model Context Protocol) server that exposes local HTML comparison to AI assistants through the compare_html tool.

Configure an MCP client

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

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

The server uses stdio transport. Your MCP client starts the CLI process and makes the tool available to the assistant.

Call compare_html

The tool accepts either strings or file paths for each side:

ParameterTypeRequiredDescription
baseHTMLstringNoBase HTML string
baseHTMLFilePathstringNoBase HTML file path
contrastHTMLstringNoContrast HTML string
contrastHTMLFilePathstringNoContrast HTML file path

Provide at least one Base input and one Contrast input. File paths are resolved in the environment where the MCP server runs, so the assistant and server must be able to access them.

The current tool has no comparison-options argument. It returns structural HTML differences using added, deleted, and valueChanged change types.

Read the output

The result contains a differences array of HTMLValueDifference objects. For example, a changed class can include:

{
  "differences": [
    {
      "pathSegments": ["0", "@class"],
      "pathString": "0.@class",
      "contrastPathString": "0.@class",
      "displayPath": "div > @class",
      "pathBelongsTo": "both",
      "diffType": "valueChanged"
    }
  ]
}

Use displayPath for a readable location and diffType for the kind of change. The path fields also identify the corresponding positions in the parsed inputs.

For direct file or string comparisons without MCP, see HTML Skills for AI Coding Assistants.