mcp-plantuml-server

xilu0/mcp-plantuml-server

3.2

If you are the rightful owner of mcp-plantuml-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

The MCP server is designed to handle image rendering tasks, specifically focusing on PlantUML to image conversion.

Tools
3
Resources
0
Prompts
0

MCP (Model Context Protocol) 服务器很适合处理图像渲染任务。该项目实现一个PlantUML渲染MCP服务器的实现方案。

为什么适合MCP?

PlantUML渲染任务符合MCP服务器的典型应用场景:

  • 单一职责:专注于PlantUML到图片的转换
  • 工具化:可以作为工具被AI助手或其他应用调用
  • 状态无关:每次渲染都是独立的操作

实现方案

让我创建一个完整的MCP服务器实现:现在让我创建配置文件和使用示例:## 安装和使用步骤

1. 安装依赖

# 创建项目目录
mkdir mcp-plantuml-server
cd mcp-plantuml-server

# 初始化项目并安装依赖
npm init -y
npm install @modelcontextprotocol/sdk node-plantuml sharp

2. 系统要求

PlantUML需要Java环境和Graphviz:

# macOS
brew install openjdk graphviz

# Ubuntu/Debian
sudo apt-get install default-jre graphviz

# Windows
# 安装 Java: https://www.java.com/download/
# 安装 Graphviz: https://graphviz.org/download/

3. 配置Claude Desktop

找到Claude Desktop配置文件:

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

添加PlantUML服务器配置。

4. 功能特点

这个MCP服务器提供了三个主要工具:

  1. render_plantuml: 直接渲染PlantUML文本

    • 支持PNG、SVG、TXT格式
    • 返回文件路径和base64编码的图像
  2. render_plantuml_from_file: 从文件渲染

    • 读取.puml文件
    • 自动保存到同目录
  3. validate_plantuml: 语法验证

    • 检查基本语法
    • 返回验证结果和错误信息

5. 扩展功能建议

你还可以添加以下功能:

  • 批量渲染: 处理多个PlantUML文件
  • 缓存机制: 避免重复渲染相同内容
  • 自定义样式: 支持PlantUML主题配置
  • 实时预览: WebSocket支持实时更新
  • 图像优化: 使用Sharp进行后处理

这个实现提供了一个完整的PlantUML渲染MCP服务器,可以轻松集成到Claude Desktop或其他支持MCP协议的应用中。需要其他功能或有问题吗?

usage

把@系统架构图.puml渲染成图片,同名保存,使用图片格式后缀

⏺ I'll help you render the PlantUML file 系统架构图.puml to an image with the same name. Let me first check if the file exists and then render it.

⏺ Read(系统架构图.puml) ⎿ Read 18 lines (ctrl+o to expand)

⏺ Now I'll render this PlantUML file to a PNG image with the same name:

⏺ mcp-plantuml-server - render_plantuml_from_file (MCP)(input_path: "/Users/linwang/src/github/xiluo/mcp-plantuml-server/系统架构图.puml", output_path: "/Users/linwang/src/github/xiluo/mcp-plantuml-server/系统架构图.png", format: "png") ⎿
"success": true, "path": "/Users/linwang/src/github/xiluo/mcp-plantuml-server/系统架构图.png", … +236 lines (ctrl+o to expand)

⏺ 已成功将 系统架构图.puml 文件渲染为 PNG 图片,保存为 系统架构图.png。图片已生成在同一目录下,文件大小为 24.77KB。