Skip to main content
Glama

diagram-mcp

MCP-Server, der Diagramm-als-Code-Text in PNG-Dateien auf Ihrer Festplatte rendert. Kein Browser, kein Netzwerk, kein externer Dienst. Nützlich, um Flussdiagramme zu erzeugen, die Sie in Dokumentationen, Tickets oder READMEs einfügen können.

example

Werkzeuge

  • render_diagram: rendert Code in eine PNG-Datei und gibt den Dateipfad zurück

  • preview_diagram: zeichnet das Diagramm als Textgrafik direkt in die Konversation, schreibt keine Datei

  • validate_diagram: parst den Code und meldet Fehler mit Zeilennummern, schreibt nichts

  • diagram_syntax: die Sprachreferenz

Related MCP server: mermaid-mcp

Installation

Erfordert Node 20.12+.

git clone https://github.com/JVmano/diagram-mcp.git
cd diagram-mcp
npm install
npm run build

Registrieren Sie ihn dann bei Claude Code:

claude mcp add diagram --scope user \
  --env DIAGRAM_MCP_OUTPUT_DIR=$HOME/Documents/diagram-renders \
  -- node "$(pwd)/dist/index.js"

Oder fügen Sie ihn manuell zur .mcp.json / Ihrer Benutzerkonfiguration hinzu:

{
  "mcpServers": {
    "diagram": {
      "type": "stdio",
      "command": "node",
      "args": ["/absolute/path/to/diagram-mcp/dist/index.js"],
      "env": { "DIAGRAM_MCP_OUTPUT_DIR": "/absolute/path/to/renders" }
    }
  }
}

Starten Sie die Sitzung neu und fordern Sie dann ein Diagramm an. Führen Sie nach dem Ziehen von Änderungen npm run build erneut aus.

Sprache

title "Reward approval flow"
direction TB

node event "Conversion recorded" shape=rounded
node auto "Auto-approve?" shape=diamond size=200x100
node queue "Manual review queue"

event -> auto
auto -> queue "no"

Formen: rect, rounded, ellipse, diamond, hexagon. Verbindungen: from -> to ["label"] [style=solid|dashed]. Positionen mit at=x,y sind optional. Lassen Sie sie weg, und das Layout platziert die Formen. Rufen Sie diagram_syntax auf, um die vollständige Referenz zu erhalten.

Konfiguration

Alle optional, alle mit Standardwerten. Siehe .env.example. Die gerenderten Dateien werden in DIAGRAM_MCP_OUTPUT_DIR gespeichert (Standard: ~/Documents/diagram-renders). Ein expliziter outputPath muss innerhalb dieses Verzeichnisses oder des Arbeitsverzeichnisses liegen, es sei denn, DIAGRAM_MCP_ALLOW_ANY_OUTPUT_PATH=true ist gesetzt.

Entwicklung

npm test          # unit tests
npm run test:e2e  # builds, then drives the server over stdio
npm run verify    # typecheck, test, build, e2e

Der Parser, das Layout und die SVG-Generierung in src/core werden mit einem lokalen Diagrammeditor-Projekt gemeinsam genutzt; npm run check:sync vergleicht sie damit, wenn es im Nachbarverzeichnis ausgecheckt ist.

Lizenz

MIT

Available Tools

4 tools
diagram_syntaxDiagram language referenceA
Read-onlyIdempotent

Return the full diagram-as-code language reference, with shapes, options and a worked example.

Inputs: no named parameters.

preview_diagramPreview diagram as textA
Read-onlyIdempotent

Draw the diagram as text art so it can be shown directly in the conversation. Writes no file. Use render_diagram when a PNG is needed.

Inputs: code (required), maxCols.

render_diagramRender diagram to PNGA

Render diagram-as-code text to a PNG file and return the path. Runs locally with no browser and no network. Returns an error listing the offending line numbers if the code does not parse.

Inputs: code (required), name, scale, padding, +3 more.

validate_diagramValidate diagram codeA
Read-onlyIdempotent

Parse diagram code and report errors and warnings with line numbers, without writing any file.

Inputs: code (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.3/5.0

    Scored across 4 tools

    Disambiguation5/5

    Each tool has a distinct purpose: syntax reference, validation, text preview, and PNG rendering. The descriptions clearly differentiate the outputs, and render_diagram explicitly notes when to use it over preview_diagram.

    Naming Consistency4/5

    Three tools follow the verb_diagram pattern (render_diagram, validate_diagram, preview_diagram), while diagram_syntax reverses the order. The convention is still readable and consistent in style, with only a minor deviation.

    Tool Count5/5

    Four tools is well-scoped for a diagram-as-code server. Each tool covers a necessary part of the workflow without redundancy or unnecessary bulk.

    Completeness5/5

    The toolset covers the full authoring loop: learn the syntax, validate the code, preview as text, and render to a PNG file. There are no obvious missing operations for the stated local rendering purpose.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers