#mcp-server #mermaid #svg #edge #model-context-protocol

app diagram

A Rust CLI and MCP server for manipulating diagram

1 unstable release

new 0.1.0 May 13, 2026

#147 in Artificial intelligence

Apache-2.0

54KB
1.5K SLoC

diagram

A Rust CLI and MCP (Model Context Protocol) server for manipulating Mermaid diagrams. Parse, inspect, modify, and render .mmd files from the command line or through any MCP-compatible AI assistant.

Usage

CLI

# Parse a diagram and print as JSON
diagram parse sample.mmd

# Show diagram summary
diagram info sample.mmd

# Render diagram as SVG (stdout or --output)
diagram render sample.mmd
diagram render sample.mmd --output out.svg

# Manipulate nodes and edges
diagram add-node sample.mmd X "New Node"
diagram add-node sample.mmd X "New Node" --shape stadium
diagram update-node sample.mmd X --text "Updated"
diagram remove-node sample.mmd X
diagram add-edge sample.mmd A X --label "connects to"
diagram remove-edge sample.mmd A X

# Start MCP server
diagram mcp

MCP (AI Assistant Integration)

Start the MCP server with diagram mcp. It communicates over stdio using the Model Context Protocol.

Available tools:

Tool Description
parse_diagram Parse a .mmd file and return JSON
get_info Diagram summary (node/edge count, shapes)
render_svg Render diagram as SVG
add_node Add a node (id, text, optional shape)
remove_node Remove a node and its edges
update_node Update node text/shape
add_edge Add an edge (from, to, optional label)
remove_edge Remove an edge
get_mermaid Get the mermaid source code
list_nodes List all nodes
list_edges List all edges

MCP Client Configuration

Claude Desktop:

{
  "mcpServers": {
    "diagram": {
      "command": "cargo",
      "args": ["run", "--manifest-path", "/path/to/diagram-rs/Cargo.toml", "--", "mcp"]
    }
  }
}

Installation

cargo install --path .

Dependencies

  • rmcp — Rust MCP SDK (server + macros)
  • clap — CLI argument parsing
  • serde / serde_json — serialization
  • tokio — async runtime
  • schemars — JSON schema generation for MCP tools

Project Structure

src/
├── main.rs      # Entry point
├── cli.rs       # CLI subcommands
├── mcp.rs       # MCP server & tools
├── diagram.rs   # Core data model
├── parser.rs    # Mermaid parser
├── layout.rs    # Graph layout algorithm
└── renderer.rs  # SVG generation

Dependencies

~11–16MB
~207K SLoC