SVG Converter MCP server

Converts SVG files to PNG and JPG formats with customizable parameters like scale factor, quality, and background color using TypeScript and the Sharp library for high-quality image processing.
Back to servers
Setup instructions
Provider
surferdot
Release date
Mar 23, 2025
Language
TypeScript
Package
Stats
618 downloads
2 stars

The MCP SVG Converter server offers tools for transforming SVG code into high-quality PNG and JPG images with extensive customization options. It supports transparency, scaling, and background color options while ensuring secure file operations.

Installation

Quick Install with npx

npx mcp-svg-converter /path/to/allowed/directory

Global Installation

npm install -g mcp-svg-converter
mcp-svg-converter /path/to/allowed/directory

From Source

First ensure you have Node.js 16+ and npm installed, then:

git clone https://github.com/surferdot/mcp-svg-converter.git
cd mcp-svg-converter
npm install
npm run build

Usage

Running as Standalone Server

Specify one or more allowed directories where converted images can be saved:

node build/index.js /path/to/allowed/directory1 /path/to/allowed/directory2

Integration with Claude Desktop

  1. Download and install Claude Desktop

  2. Create an output directory:

    # macOS/Linux
    mkdir -p ~/Desktop/svg-output
    
    # Windows
    mkdir "%USERPROFILE%\Desktop\svg-output"
    
  3. Configure Claude Desktop:

    • Open the Claude app
    • Click on the Claude menu in your system menu bar
    • Select "Settings..."
    • Click "Developer" in the left sidebar
    • Click "Edit Config"
  4. Add this server configuration to the opened file:

{
  "mcpServers": {
    "svg-converter": {
      "command": "npx",
      "args": [
        "mcp-svg-converter",
        "/absolute/path/to/output/directory"
      ]
    }
  }
}
  1. Save the file and restart Claude Desktop

Available Tools

svg-to-png

Converts SVG code to high-quality PNG with transparency support.

Parameters:

  • svgCode (string, required): The SVG code to convert
  • outputPath (string, required): Where to save the PNG file
  • backgroundColor (string, optional): Background color (default: transparent)
  • scale (number, optional): Resolution scale factor (default: 1)

svg-to-jpg

Converts SVG code to high-quality JPG.

Parameters:

  • svgCode (string, required): The SVG code to convert
  • outputPath (string, required): Where to save the JPG file
  • backgroundColor (string, optional): Background color (default: white)
  • quality (number, optional): JPEG quality from 1-100 (default: 90)
  • scale (number, optional): Resolution scale factor (default: 1)

Example Usage in Claude Desktop

Converting SVG to PNG

Please convert this SVG to PNG and save it to my output directory:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 100" width="200" height="100">
  <rect x="10" y="10" width="80" height="80" fill="#4285f4" />
  <circle cx="140" cy="50" r="40" fill="#ea4335" />
  <path d="M10 50 L90 50 L50 90 Z" fill="#fbbc05" />
  <text x="100" y="20" font-family="Arial" font-size="12" text-anchor="middle" fill="#34a853">SVG Example</text>
</svg>

Converting SVG to JPG with Options

Please convert this SVG to a JPG with 95% quality and 2x scaling:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200">
  <rect width="200" height="200" fill="#f0f0f0" />
  <circle cx="100" cy="100" r="80" fill="#ff6b6b" />
  <path d="M100 50 L130 150 L70 150 Z" fill="white" />
</svg>

Advanced Tips

Specifying Multiple Output Directories

You can configure multiple allowed directories for more flexibility:

{
  "mcpServers": {
    "svg-converter": {
      "command": "npx",
      "args": [
        "mcp-svg-converter",
        "/Users/yourusername/Desktop/svg-output",
        "/Users/yourusername/Documents/svg-images",
        "/Users/yourusername/Downloads"
      ]
    }
  }
}

Using Custom Filenames

Specify detailed file paths in your request:

Please convert this SVG to PNG, and save it as "colorful_shapes.png" in my output directory.

<svg>...</svg>

Troubleshooting

MCP Tools Icon Not Showing

  • Verify the configuration file has correct JSON syntax
  • Ensure all paths are absolute paths
  • Confirm output directories exist and are writable
  • Completely exit and restart Claude Desktop
  • Check Claude logs for errors

Tool Execution Fails

  • Ensure mcp-svg-converter is correctly installed
  • Check output directory permissions
  • Verify the SVG code is valid
  • Review Claude logs for detailed error messages

Debugging

Use the MCP Inspector to test the server directly:

npx @modelcontextprotocol/inspector npx mcp-svg-converter /path/to/allowed/directory

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "svg-converter" '{"command":"npx","args":["mcp-svg-converter","/absolute/path/to/output/directory"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "svg-converter": {
            "command": "npx",
            "args": [
                "mcp-svg-converter",
                "/absolute/path/to/output/directory"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "svg-converter": {
            "command": "npx",
            "args": [
                "mcp-svg-converter",
                "/absolute/path/to/output/directory"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later