svg2png_mcp
1
The SVG to PNG MCP Server is a tool server based on the Model Context Protocol (MCP) designed to convert SVG code to PNG images. It supports integration with other MCP clients and offers two methods for conversion: CairoSVG for simplicity and speed, and Inkscape for full SVG feature support.
SVG to PNG MCP Server
Features
- Converts SVG code to PNG images
- Supports specifying working directory
- Based on the MCP protocol, compatible with other MCP clients
SVG to PNG Conversion Methods
-
CairoSVG Method (currently in use)
- Fast conversion speed
- Minimal dependencies, easy to install
- Suitable for simple SVG graphics
- Limitations: special handling for Chinese fonts, limited complex SVG feature support
-
Inkscape Method (alternative)
- Full SVG feature support
- Better font rendering
- More accurate conversion
- Limitations: requires Inkscape installation, slower conversion speed
Installation
- Create and activate a virtual environment.
- Install dependencies from
requirements.txt
.
Configuration
- Copy example configuration file and edit it using absolute paths for both the command and arguments.
Usage
Run the test client to generate a PNG image. Ensure the virtual environment is activated and correct absolute paths are used in servers_config.json
.
Technical Implementation
Server Architecture
- Implemented using FastMCP framework
- Provides
svg_to_png
tool interface - Supports asynchronous operations and error handling
Core Features
- SVG to PNG conversion with cairosvg
- Custom working directory support
- Comprehensive error handling and logging
Client Integration
- Supports standard MCP client access
- Provides a test client example
- Facilitates tool discovery and asynchronous calling
Dependencies
- mcp: MCP protocol implementation
- cairosvg: Core library for SVG conversion
- Pillow: Image processing support