smart-excalidraw-mcp
Generates Excalidraw diagrams from natural-language descriptions across 22 chart types, including arrow optimization and batch generation.
Outputs .excalidraw.md files compatible with Obsidian, allowing generated diagrams to be used directly in Obsidian vaults.
Supports local Ollama models through an OpenAI-compatible endpoint as the LLM backend for diagram generation.
Supports OpenAI-compatible APIs, including OpenAI models such as GPT-4o, as the LLM backend for natural-language diagram generation.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
🎨 smart-excalidraw-mcp
用自然语言生成专业图表的 MCP Server
支持任意 OpenAI 兼容的 LLM API,兼容 Claude Code、Cursor、OpenCode 等所有 MCP 客户端
💡 产品哲学
传统的图表工具往往需要手动拖拽、调整,耗时且效率低下。smart-excalidraw-mcp 的诞生,源于对 "AI 原生工作流" 的探索:
自然语言即指令:你只需用文字描述想要的图表,AI 自动完成绘制。
22 种图表类型:从流程图到架构图,从思维导图到 ER 图,覆盖绝大多数可视化场景。
九象限箭头优化:自动优化箭头连接点,让图表更专业、更美观。
多模型支持:不绑定单一服务商,支持 OpenAI、Anthropic、阿里云、本地 LLM 等。
跨工具兼容:支持所有 MCP 协议客户端(Claude Code、Cursor、OpenCode 等)。
Related MCP server: Excalidraw Architect MCP
✨ 核心特性
特性 | 说明 |
🗣️ 自然语言交互 | 直接在 AI 对话中用文字描述想要的图表 |
🎯 22 种图表类型 | 流程图、思维导图、架构图、ER 图、时序图等 |
⚡ 高质量输出 | 九象限箭头优化算法,自动优化连接 |
📦 开箱即用 | 支持任意 OpenAI 兼容 API |
🔧 灵活配置 | 支持 OpenAI、Anthropic、本地 LLM 等 |
🌐 跨工具兼容 | 支持 Claude Code、Cursor、OpenCode 等 MCP 客户端 |
📝 Obsidian 兼容 | 输出 |
🚀 快速开始
1. 安装
# 克隆仓库
git clone https://github.com/linyuan3421/smart-excalidraw-mcp.git
cd smart-excalidraw-mcp
# 安装依赖
npm install
# 构建
npm run build2. 配置 MCP 客户端
Claude Code
在 claude_desktop_config.json 中添加:
{
"mcpServers": {
"excalidraw": {
"command": "node",
"args": ["/path/to/smart-excalidraw-mcp/dist/src/index.js"],
"env": {
"LLM_API_KEY": "your-api-key-here",
"LLM_BASE_URL": "https://api.openai.com/v1",
"LLM_MODEL": "gpt-4o"
}
}
}
}Cursor
在项目根目录创建 .cursor/mcp.json:
{
"mcpServers": {
"excalidraw": {
"command": "node",
"args": ["/path/to/smart-excalidraw-mcp/dist/src/index.js"],
"env": {
"LLM_API_KEY": "your-api-key-here",
"LLM_BASE_URL": "https://api.openai.com/v1",
"LLM_MODEL": "gpt-4o"
}
}
}
}OpenCode
在 opencode.json 中添加:
{
"mcp": {
"excalidraw": {
"type": "local",
"command": ["node", "/path/to/smart-excalidraw-mcp/dist/src/index.js"],
"environment": {
"LLM_API_KEY": "your-api-key-here",
"LLM_BASE_URL": "https://api.openai.com/v1",
"LLM_MODEL": "gpt-4o"
}
}
}
}其他 MCP 客户端
任何支持 Model Context Protocol 的客户端都可以使用本 MCP。配置格式基本一致,只需将 command 指向编译后的 dist/src/index.js 文件。
3. 重启你的 MCP 客户端
4. 开始使用
你: "帮我创建一个用户登录流程图"
AI: ✅ 自动调用 MCP → 生成图表 → 返回文件⚙️ 环境变量配置
变量 | 说明 | 必填 | 默认值 |
| LLM API 密钥 | ✅ | - |
| API 基础 URL | ❌ |
|
| 模型名称 | ❌ |
|
| 提供商类型 | ❌ |
|
不同提供商配置
{
"env": {
"LLM_API_KEY": "sk-xxx",
"LLM_BASE_URL": "https://api.openai.com/v1",
"LLM_MODEL": "gpt-4o"
}
}{
"env": {
"LLM_API_KEY": "sk-ant-xxx",
"LLM_BASE_URL": "https://api.anthropic.com/v1",
"LLM_MODEL": "claude-sonnet-4-20250514"
}
}{
"env": {
"LLM_API_KEY": "ollama",
"LLM_BASE_URL": "http://localhost:11434/v1",
"LLM_MODEL": "llama3"
}
}{
"env": {
"LLM_API_KEY": "sk-xxx",
"LLM_BASE_URL": "https://dashscope.aliyuncs.com/compatible-mode/v1",
"LLM_MODEL": "qwen-plus"
}
}📖 MCP 工具说明
generate_diagram
生成单个图表。
text(必填) - 图表描述chartType(可选) - 图表类型,默认autooutputPath(可选) - 输出文件路径
batch_generate_diagrams
批量生成图表。
directory(必填) - 目录路径filePattern(可选) - 文件匹配模式,默认*.mdchartType(可选) - 图表类型concurrency(可选) - 并发数,默认 5
optimize_diagram
优化已有图表的箭头连接。
inputPath(必填) - 输入文件路径outputPath(可选) - 输出文件路径
list_chart_types
列出所有支持的图表类型。
📊 支持的图表类型(22 种)
类型 | 说明 | 类型 | 说明 |
| 自动识别 |
| 流程图 |
| 思维导图 |
| 层级图 |
| 时序图 |
| 关系图 |
| ER 图 |
| 对比图 |
| 时间线 |
| 树形图 |
| 网络拓扑图 |
| 架构图 |
| 数据流图 |
| 状态图 |
| 泳道图 |
| 概念图 |
| 鱼骨图 |
| SWOT 分析图 |
| 金字塔图 |
| 漏斗图 |
| 韦恩图 |
| 矩阵图 |
| 信息图 |
🔧 开发
项目结构
smart-excalidraw-mcp/
├── src/
│ ├── index.ts # MCP server 入口
│ └── client.ts # Excalidraw 客户端
├── lib/
│ ├── prompts.js # 提示词模板
│ ├── llm-client.js # LLM API 客户端
│ └── optimizeArrows.js # 箭头优化算法
├── dist/ # 编译输出
├── package.json
└── tsconfig.json构建
npm run build本地测试
npx @modelcontextprotocol/inspector node dist/src/index.js🛠️ 技术栈
Runtime: Node.js 18+
Language: TypeScript 5.0
Protocol: Model Context Protocol (MCP) 1.0
Compression: LZ-String (Obsidian compatible)
AI Integration: OpenAI Compatible Interface
🙏 致谢
本项目的核心实现借鉴自 smart-excalidraw-next,感谢原作者的开源贡献。
具体包括:
提示词系统 (
lib/prompts.js) - 图表生成的 Prompt 工程箭头优化算法 (
lib/optimizeArrows.js) - 九象限箭头连接优化图表类型定义 - 22 种图表类型及其说明
同时也感谢以下项目:
Excalidraw - 强大的白板工具
Model Context Protocol - MCP 协议
👨💻 关于作者
本项目由 [反时钟效率笔记] 设计与维护。
如果你喜欢这个项目,或者想获取更多 AI 相关的探索,欢迎关注我的公众号。
🤝 贡献
欢迎提交 Issue 或 Pull Request! 如果你喜欢这个项目,请给它一个 ⭐️ Star,这对我意义重大。
📄 许可证
MIT License.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Turn calls and notes into process flow diagrams in Claude, ChatGPT, VS Code, Cursor, and Teams.
Make editable flowcharts, process charts, funnels, timelines and data models from plain language.
Draw architecture diagrams, UML, planning boards and clickable wireframes from your AI assistant.
Create, edit and organize hand-drawn diagrams (flowcharts, ER, architecture) from any AI agent.
Related MCP Servers
- FlicenseNot gradedqualityAmaintenanceEnables AI coding assistants to turn natural-language descriptions of systems and data into editable, auto-laid-out Excalidraw diagrams across 25 types — from architecture and sequence diagrams to Gantt charts and scatter plots — plus optionally persist the architecture as a queryable, version-controlled knowledge graph. Runs fully offline with export to SVG and PNG, and diagrams can be revised afterward in natural language.-
- FlicenseNot gradedqualityAmaintenanceEnables AI assistants to turn architecture descriptions, flows, and data into 25 types of auto-laid-out, hand-drawn .excalidraw diagrams that stay editable, with optional SVG/PNG export and a version-controlled knowledge graph the AI can query and lint. Runs fully offline in Cursor, Claude Code, and Windsurf with no API keys, and diagrams can be revised through natural language.-
- FlicenseNot gradedqualityAmaintenanceEnables AI assistants to turn plain-language descriptions of systems, flows, and data into 25 kinds of fully laid-out, hand-drawn Excalidraw diagrams — architecture, sequence, ER, swimlane, Gantt, charts and more — with auto-styling for 50+ technologies and revision in natural language. Runs fully offline, exports to SVG and PNG without a browser or Node.js, and can optionally persist the architecture as a queryable knowledge graph.-
- FlicenseNot gradedqualityAmaintenanceEnables AI coding tools to turn architecture and other structured descriptions into auto-laid-out, hand-drawn Excalidraw diagrams across 25 diagram types, including architecture, flowcharts, sequence, ER, swimlanes, timelines, Gantt, and charts. It also supports natural-language revision, SVG/PNG export, and optionally a queryable knowledge graph of the system.-