Skip to main content
Glama
SVG Optimizer MCP Server

SVG Optimizer MCP Server

README.md
# SVG Optimizer MCP Server

A Model Context Protocol (MCP) server that provides SVG optimization capabilities using [SVGO](https://github.com/svg/svgo). This server allows AI assistants and other MCP clients to optimize SVG files to reduce their file size while maintaining visual quality.

## Features

- **Simple SVG Optimization**: Optimize SVG files using SVGO's proven default settings
- **File Size Analytics**: Get detailed statistics about optimization results
- **Error Handling**: Clear error messages for invalid SVG content
- **Zero Configuration**: Works out of the box with sensible defaults
- **NPX Compatible**: Can be run directly via npx without installation

## Installation

Add this configuration to your MCP client's `mcp.json`:

```json
{
  "mcpServers": {
    "svg-optimizer": {
      "command": "npx",
      "args": ["svgo-mcp"]
    }
  }
}
```

## Usage

The server provides a single tool: `optimize_svg`

### Tool: optimize_svg

Optimizes an SVG file using SVGO with default settings.

**Parameters:**
- `content` (required): The SVG file content as a string
- `filename` (optional): Filename for context and reporting

**Example Usage:**

```javascript
{
  "name": "optimize_svg",
  "arguments": {
    "content": "<svg ... /></svg>",
    "filename": "icon.svg"
  }
}
```

**Response:**

```json
{
  "success": true,
  "filename": "icon.svg",
  "optimization": {
    "originalSize": 85,
    "optimizedSize": 65,
    "savings": 20,
    "savingsPercent": "23.5%",
    "compressionRatio": "0.765"
  },
  "optimizedContent": "<svg ... /></svg>"
}
```

## Response Format

The server returns a JSON object with the following structure:

- `success`: Boolean indicating if optimization was successful
- `filename`: The provided filename or "untitled.svg" if not specified
- `optimization`: Object containing size statistics
  - `originalSize`: Original file size in bytes
  - `optimizedSize`: Optimized file size in bytes
  - `savings`: Bytes saved through optimization
  - `savingsPercent`: Percentage of size reduction
  - `compressionRatio`: Ratio of optimized size to original size
- `optimizedContent`: The optimized SVG content


## Use Cases

- **Web Development**: Optimize SVG icons and graphics for faster loading
- **Asset Processing**: Batch optimize SVG files in build pipelines
- **Content Management**: Reduce storage requirements for SVG assets
- **Performance Optimization**: Minimize bandwidth usage for SVG delivery

TDQS

B3.4/5.0

Scored across 1 tool

Disambiguation5/5

There is only one tool, so there is no possibility of confusing it with another operation. Its purpose is clearly stated as SVG optimization.

Naming Consistency5/5

The single tool follows a clear verb_noun convention: optimize_svg. There are no mixed styles or naming inconsistencies.

Tool Count2/5

A single tool is too thin for the apparent SVG optimizer domain. Even a narrow server typically benefits from options such as custom configuration, batch processing, or validation.

Completeness2/5

The surface only supports default SVGO optimization and lacks obvious companion operations like custom config support, validation, previewing results, or batch handling. This creates significant gaps for real-world SVG optimization workflows.

Maintenance

ActivityInactive
ResponsivenessNo recent community issues