svg-compare-mcp
v1.0.36
Published
SVG comparison tool for comparing two SVGs for equality
Readme
svg-compare-mcp
A MCP tool for comparing SVG files in a project.
Features
- Compare SVG files by providing either a file path or SVG content
- Scan the entire project directory by default, or a specific directory
- Return a list of identical SVG files with their names and paths if found
- Save the new SVG file to the target directory with a unique name if no identical files are found
Installation
npm installUsage
Parameters
| Parameter | Type | Description | Required | Default | |-----------|------|-------------|----------|---------| | svgSource | string | SVG source, can be a file path or SVG content | Yes | - | | targetDir | string | Target directory to scan, default is project root | No | Project root | | isContent | boolean | Whether the svgSource is SVG content, default is false | No | false |
Examples
- Compare an SVG file with all SVG files in the project:
node index.js --svgSource path/to/your/svg/file.svg- Compare an SVG file with all SVG files in a specific directory:
node index.js --svgSource path/to/your/svg/file.svg --targetDir src/icons- Compare SVG content with all SVG files in the project:
node index.js --svgSource "<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'><path d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z'/></svg>" --isContent true- Compare SVG content with all SVG files in a specific directory:
node index.js --svgSource "<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'><path d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z'/></svg>" --isContent true --targetDir src/iconsOutput
If identical SVG files are found:
{
"success": true,
"message": "Same SVG files found",
"sameSvgList": [
{
"name": "icon1.svg",
"path": "src/icons/icon1.svg"
},
{
"name": "icon2.svg",
"path": "src/icons/icon2.svg"
}
]
}If no identical SVG files are found:
{
"success": true,
"message": "SVG file saved successfully",
"savedPath": "src/icons/new_svg.svg"
}How It Works
- The tool reads the SVG source (either from a file or provided content)
- It scans the specified directory (or the entire project) for all SVG files
- It compares the content of each SVG file with the source SVG
- If identical files are found, it returns a list of those files
- If no identical files are found, it saves the source SVG to the target directory with a unique name
Dependencies
This MCP has no external dependencies. It uses only Node.js built-in modules:
- fs: For file system operations
- path: For path handling
License
MIT
