drawio
MCP server for creating and editing diagrams using draw.io. Allows generating diagrams from Mermaid or XML, searching shapes, and opening them in draw.io for export.
README
@achmadya-dev/mcp-drawio
MCP server for draw.io. Create diagrams via LLM — rendered inline in chat using MCP Apps.
Built on @achmadya-dev/mcp-core and @modelcontextprotocol/ext-apps.
Requirements
- Node.js ≥ 20
- MCP host with MCP Apps support (e.g. Cursor)
Install via npx
{
"mcpServers": {
"drawio": {
"command": "npx",
"args": ["-y", "@achmadya-dev/mcp-drawio"]
}
}
}
Tools
| Tool | Description |
|---|---|
show_inline_drawio |
Render a diagram inline in chat from Mermaid or draw.io XML |
search_shapes |
Search 10k+ industry icon shapes (AWS, Cisco, P&ID, …) for XML diagrams |
search_shapes is registered when the bundled shape index is present (included in the npm package after build).
show_inline_drawio
Provide exactly one of mermaid or xml:
| Input | Use for |
|---|---|
mermaid |
Flowchart, sequence, ER, class, state, gantt, mindmap, C4, and 25+ other types |
xml |
Hand-placed layouts, swimlanes, cloud/network/P&ID stencils, UI mockups |
Optional layout passes (XML only):
| Option | Effect |
|---|---|
postLayout: "elk" |
Re-layout vertices with ELK (flowcharts, pipelines, hierarchical diagrams) |
direction: "vertical" | "horizontal" |
ELK flow direction (XML only; defaults to vertical) |
routing: "libavoid" |
Obstacle-avoiding edge routing without moving vertices |
For industry icons in XML diagrams, call search_shapes first and use the returned style strings in mxCell attributes. References: xml-reference.md, mermaid-reference.md.
Inline viewer
The create_diagram tool renders an interactive iframe in chat:
- Zoom, pan, and fit-to-view
- Fullscreen mode
- Open in draw.io — opens the diagram in app.diagrams.net for editing and export (PNG, SVG, PDF)
To save a diagram as an image, use Open in draw.io → File → Export as.
Develop from source
git clone https://github.com/achmadya-dev/mcp-drawio.git
cd drawio-mcp
pnpm install
pnpm run build
pnpm start
Local Cursor config (.cursor/mcp.json):
{
"mcpServers": {
"drawio": {
"command": "node",
"args": ["${workspaceFolder}/dist/index.js"],
"cwd": "${workspaceFolder}"
}
}
}
After changing viewer or server code, rebuild and restart the MCP server in Cursor.
Scripts
| Command | Description |
|---|---|
pnpm run build |
Compile TypeScript and copy src/assets/ → dist/assets/ |
pnpm start |
Run MCP server (stdio) |
pnpm test |
Run tests |
pnpm run generate:shapes |
Regenerate shape search index (requires network) |
pnpm run format |
Format with Prettier |
Environment
| Variable | Description |
|---|---|
DOMAIN |
MCP Apps iframe domain (passed in resource _meta.ui) |
VIEWER_PATH |
Optional path to a local viewer-static.min.js override |
ELK_PATH |
Optional path to a local drawio-elk.min.js override |
MERMAID_PATH |
Optional path to a local drawio-mermaid.min.js override |
The draw.io viewer loads from https://viewer.diagrams.net by default (CDN). Optional bundle overrides are useful for offline development or pinning a specific draw.io release.
Project layout
src/
index.ts MCP server entry (stdio, MCP Apps)
drawio/
drawio.ts Bundle loader (HTML, shape index, references)
utils.ts createDiagram, searchShapes, validation
viewer/html.ts Inline MCP App viewer (draw.io + MCP SDK)
tools/
search_shapes.ts Shape search tool (defineTool)
assets/
shared/ Tool description references (XML, Mermaid)
shape-search/ Pre-built shape index (~10k shapes)
vendor/app/ libavoid WASM (edge routing in viewer)
scripts/
copy-assets.ts Build-time asset copy
generate-shape-index.ts
dist/ Published to npm
Diagram formats (quick guide)
| Need | Approach |
|---|---|
| Flowchart, sequence, ER, class, … | Mermaid via show_inline_drawio |
| AWS / Azure / Cisco / P&ID icons | XML + search_shapes |
| Edit or export PNG/SVG | Open in draw.io in the inline viewer |
libavoid vendor refresh
Browser WASM lives in src/assets/vendor/app/libavoid/. To refresh:
cd src/assets/vendor/app/libavoid
npm pack libavoid-js && tar -xzf libavoid-js-*.tgz
cp package/dist/index.js libavoid.min.js
cp package/dist/libavoid.wasm libavoid.wasm
Regenerate shape index (optional, when draw.io releases new shapes):
pnpm run generate:shapes
pnpm run build
Release
Uses Changesets:
pnpm changeset
pnpm run version-packages
Push to main → GitHub opens a Version packages PR → merge → npm publish via CI.
Requires NPM_TOKEN secret on the repository.
License
Apache-2.0
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.