使用说明
plantuml-mcp
从自然语言描述生成PlantUML图的MCP(模型上下文协议)服务器。它由内置的PlantUML语法文档提供支持,可以生成准确、符合标准的图表,而无需猜测语法。
特性
- 🧠 文档感知生成 --在生成每个图之前阅读官方PlantUML语法文档
- 📐 符合UML标准 --遵循标准的UML原则和约定
- 🎨 清洁输出 --默认情况下,没有标题,没有不必要的颜色,样式最少
- 🖼️ 内联渲染 --克劳德的回答中直接呈现了图表
- ✏️ 编辑器链接 --每个图都包含一个链接,可以在PlantUML编辑器中打开和编辑它
- 📦 独立 --运行时没有外部依赖关系,文档与服务器捆绑在一起
支持的图表类型
| 类型 | 描述 |
|---|---|
sequence |
工艺流程和系统交互 |
use case |
参与者和系统用例关系 |
class |
面向对象的类结构 |
activity |
工作流程和决策流程 |
component |
系统架构和组件 |
state |
状态机和生命周期图 |
object |
运行时对象快照 |
deployment |
基础设施和部署拓扑 |
timing |
基于时间的状态转换 |
gantt |
项目时间表和时间表 |
mindmap |
分层概念图 |
wbs |
工作分解结构 |
archimate |
企业架构 |
network |
网络拓扑图 |
wireframe |
UI线框模型 |
ebnf |
语法和句法定义 |
regex |
正则表达式图 |
安装
先决条件
- Node.js 18+
- npm
设置
git clone https://github.com/MeesEgberts/plantuml-mcp.git
cd plantuml-mcp
npm install
npm run build
用法
使用克劳德桌面
将服务器添加到Claude Desktop配置文件中:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
视窗: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"plantuml": {
"command": "node",
"args": ["/absolute/path/to/plantuml-mcp/build/index.js"]
}
}
}
然后重新启动Claude Desktop。
与Claude.ai
通过Claude.ai中的MCP设置添加服务器,并将其指向正在运行的服务器。
运作原理
服务器公开了两个工具:
read_docs --从捆绑的markdown文件中获取所请求图表类型的官方PlantUML语法文档。克劳德总是先说这个。
create_diagram --获取有效的PlantUML标记,对其进行编码,并返回:
- 通过PlantUML服务器渲染的内联图像
- 在中打开和编辑图表的链接 PlantUML编辑器
生成规则
每个生成的图表都遵循这些默认值:
- ✅ 标准UML符号和约定
- ✅ 干净、最少的标记
- ❌ 不
title指令 - ❌ 无颜色或自定义
skinparam样式(除非明确要求)
示例提示
Use the plantuml MCP to create a sequence diagram showing a user login flow
with JWT authentication.
Use the plantuml MCP to create a class diagram for an e-commerce platform
with Order, Product, Customer, and Payment classes.
Use the plantuml MCP to create a state diagram for a subscription lifecycle
including trial, active, past due, paused, and cancelled states.
发展
# Run directly without building (recommended for development)
npm run dev
# Build
npm run build
# Build output
build/
├── index.js
└── resources/
├── plantuml-sequence-diagram-docs.md
├── plantuml-class-diagram-docs.md
└── ...
项目结构
src/
├── index.ts # MCP server entry point, tool registration
├── resources/ # PlantUML syntax documentation (markdown)
│ ├── plantuml-sequence-diagram-docs.md
│ ├── plantuml-class-diagram-docs.md
│ └── ...
└── utils/
└── register-resources.ts # Auto-registers all markdown docs as MCP resources
脚本
npm run build # Compile TypeScript + copy resources to build/
npm run dev # Run with tsx (no build step)
npm run fetch:plantuml-docs # Fetch latest PlantUML docs into resources/
技术栈
- 模型上下文协议SDK
- plantuml编码器
- 佐德 --输入模式验证
- TypeScript
许可证
ISC©米斯·埃格伯特
