B0

buck-0x/eraser-io-mcp-server

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

23 stars 5 forks 质量 73 趋势 10MIT

一个 Python MCP(模型上下文协议)服务器和 CLI 工具,用于使用 Eraser API 渲染图表。

概览

一个 Python MCP(模型上下文协议)服务器和 CLI 工具,用于使用 Eraser API 渲染图表。 - 📊 :序列、流程图、ER、云架构等 - 🎨 :主题、背景和缩放选项 - 📦 :获取图片 URL 或 base64 编码的文件内容 - 🔗 :返回橡皮擦编辑图链接 - ✅ :检查未定义图标并提供警告 - MCP 使用指南 - 如何与 Claude Desktop、VS Code、Windsurf 或其他环境使用。- Eraser 文档 - 通用橡皮擦文档 - 橡皮图即代码文档 - 语法信息 - 橡皮擦 DSL API 参考 - 关于端点和参数的信息 这将输出带有图片URL的JSON: - --图型(必填):图的类型(例如:

概述(AI 翻译)

一个 Python MCP(模型上下文协议)服务器和 CLI 工具,用于使用 Eraser API 渲染图表。

特色

  • 📊 多种图表类型:序列图、流程图、ER、云架构等
  • 🎨 可自定义:主题、背景和缩放选项
  • 📦 灵活输出:获取图片URL或base64编码的文件内容
  • 🔗 橡皮擦文件URL:返回橡皮擦编辑图的链接
  • ✅ 图标验证:检查未定义图标并提供警告

文献资料

  • MCP 使用指南 - 如何与 Claude Desktop、VS Code、Windsurf 或其他环境使用。
  • 橡皮擦文档 - 通用橡皮擦文档
  • 橡皮擦图即代码文档 - 关于语法的信息
  • Eraser DSL API 参考 - 关于所用端点和参数的信息

基本用法

这将输出带有图片URL的JSON:

如果检测到未定义的图标:

参数

  • --diagram-type(必填):图的类型(例如,时序图、云架构图)
  • --code(必需):橡皮擦语法中的图示代码
  • --return-file:返回 base64 编码的图像数据,而非 URL(默认为 False)

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

Eraser Diagram Renderer

A Python MCP (Model Context Protocol) server and CLI tool to render diagrams using the Eraser API.

Features

  • 📊 Multiple Diagram Types: Sequence, flowchart, ER, cloud architecture, and more
  • 🎨 Customizable: Themes, backgrounds, and scaling options
  • 📦 Flexible Output: Get image URLs or base64-encoded file content
  • 🔗 Eraser File URL: Returns link to edit diagram in Eraser
  • ✅ Icon Validation: Checks for undefined icons and provides warnings

Documentation

Basic Usage

python render_eraser_diagram.py --diagram-type sequence-diagram --code "Alice -> Bob: Hello"

This will output JSON with the image URL:

{
  "success": true,
  "message": "Diagram rendered successfully",
  "image_url": "https://app.eraser.io/workspace/...",
  "create_eraser_file_url": "https://app.eraser.io/workspace/..."
}

If undefined icons are detected:

{
  "success": true,
  "message": "Diagram rendered successfully",
  "image_url": "https://app.eraser.io/workspace/...",
  "create_eraser_file_url": "https://app.eraser.io/workspace/...",
  "warning": "Warning: The following icons are not defined in the standard Eraser icons list: custom-icon. These icons may not render correctly. You can disable this warning by setting SKIP_ICON_CHECK=true."
}

Parameters

  • --diagram-type (required): Type of diagram (e.g., sequence-diagram, cloud-architecture-diagram)
  • --code (required): Diagram code in Eraser syntax
  • --return-file: Return base64-encoded image data instead of URL (defaults to False)
  • --no-background: Disable background (defaults to background enabled)
  • --theme: Choose “light” or “dark” theme (defaults to “light”)
  • --scale: Scale factor - “1”, “2”, or “3” (defaults to “1”)

Note: Due to a bug in the Eraser API, the image cache is only invalidated when the diagram code changes. Changes to theme or background parameters alone will not generate a new image if the same code was previously rendered with different settings.

Authentication

For CLI usage, set your Eraser API token in one of these ways:

  1. Environment variable:

    export ERASER_API_TOKEN=your_token_here
    python render_eraser_diagram.py --diagram-type sequence-diagram --code "A -> B"
    
  2. .env file in the project directory:

    echo "ERASER_API_TOKEN=your_token_here" > .env
    

For MCP server usage with Claude Desktop, see the MCP Usage Guide.

在 GitHub 查看完整 README

安装

docker run -p 8000:8000 \
新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "eraser": { "type": "streamable-http", "url": "http://localhost:8000/mcp", "headers": { "Authorization": "Bearer your_auth_token" } } } }