imagetosvg-mcp

imagetosvg-mcp

Enables AI agents to vectorize raster images and import vector files (PDF/AI/EPS), then inspect, edit, render, and optimize SVGs locally.

Category
访问服务器

README

imagetosvg-mcp

CI License: MIT Node

A local Model Context Protocol server that gives AI agents full control over images — vectorize a raster image, import a vector file (PDF/AI/EPS), then inspect, edit, render, and optimize the SVG. No API keys, no cloud; everything runs locally.

The idea: an SVG is just text, and the agent is already the intelligence. So this server only does what an agent can't do on its own — turn pixels into editable paths and render SVG back to a picture for visual verification — plus a set of structured edit operations for the parts of SVG editing that are tedious by hand. The agent does the rest with its own file tools.

Why

Agents normally treat an image as opaque pixels they can't change. Convert it to SVG and the agent can recolor a logo, delete a layer, resize, restyle, or simplify it — then render the result and see whether the edit worked, all deterministically.

Tools

Tool Purpose
convert_image_to_svg Raster → SVG (hybrid: clean trace for simple graphics, layered color trace for complex ones)
import_vector PDF / AI / EPS → SVG (paths preserved, no tracing)
inspect_svg List addressable layers (id, tag, fill, stroke, bbox) without parsing path strings
edit_svg Structured edits by layer id (recolor, remove, isolate, transform, resize, set attribute)
render_svg Rasterize SVG → PNG so the agent can verify visually
optimize_svg Clean up with svgo while preserving layer ids and viewBox

Supported raster inputs: PNG, JPG, WebP, GIF, BMP, TIFF, AVIF. Supported vector inputs: PDF, PDF-compatible AI, and EPS (EPS requires Ghostscript).

Install

git clone https://github.com/ujo78/imagetosvg-mcp.git
cd imagetosvg-mcp
npm install        # builds automatically (prepare hook)

Requires Node.js >= 20. All native dependencies ship prebuilt binaries — no system toolchain required.

Connect it to an agent

Claude Code

User scope (available in every project):

claude mcp add -s user imagetosvg -- node "/absolute/path/to/imagetosvg-mcp/dist/index.js"

Or per-project, commit a .mcp.json at the repo root:

{
  "mcpServers": {
    "imagetosvg": {
      "command": "node",
      "args": ["/absolute/path/to/imagetosvg-mcp/dist/index.js"]
    }
  }
}

Claude Desktop / Cursor / Windsurf

Add the same block to the client's MCP config (claude_desktop_config.json for Claude Desktop; the MCP settings panel for Cursor/Windsurf). Use an absolute path to dist/index.js.

On Windows, use forward slashes in the path, e.g. C:/Users/you/imagetosvg-mcp/dist/index.js.

The workflow

The bundled Claude skill teaches agents this loop:

  1. Look at the source image.
  2. Convert (convert_image_to_svg) or import (import_vector); check the returned PNG preview.
  3. Compare preview to the original; re-convert with a different mode/max_colors if needed.
  4. Inspect (inspect_svg) to learn the layers.
  5. Edit with edit_svg (structured) or the agent's own file tools (freeform).
  6. Verify with render_svg and look. Iterate.
  7. Finalize with optimize_svg and use the .svg in place of the image.

edit_svg operations

setFill{id,color}, setStroke{id,color}, removeNode{id}, isolateNode{id}, transform{id,translate?,scale?,rotate?}, setDimensions{width?,height?}, setAttribute{id,name,value}. Layer ids (layer-N) are assigned in document order and survive optimize_svg.

Optional: EPS support

EPS import requires Ghostscript on PATH (gswin64c on Windows). PDF and AI work without it; if Ghostscript is missing, import_vector returns a clear error for EPS only.

Development

npm run dev        # run the server from source via tsx
npm run typecheck  # tsc --noEmit
npm test           # vitest
npm run build      # tsc -> dist/

See CONTRIBUTING.md for the full guide.

How it works

  • Hybrid conversion: a unique-color heuristic classifies an image as simple (vtracer binary trace → clean paths) or layered (vtracer color trace → stacked, individually addressable color layers). Override with mode / max_colors.
  • Vector import: PDF/AI go through mupdf (WASM, no system deps) with paths preserved; EPS is converted via Ghostscript when available.
  • Stack: TypeScript (ESM) · @modelcontextprotocol/sdk · @neplex/vectorizer (vtracer) · sharp · @resvg/resvg-js · svgo · svgson.

License

MIT © Rakshit Raj

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选