add_diagram
Insert Mermaid diagrams into Slidev slides by appending, inserting at a position, or replacing a slide; preview changes with dry_run before writing.
Instructions
Add a Mermaid diagram to a Slidev presentation slide. Supports all Mermaid diagram types including flowcharts, sequence diagrams, class diagrams, ER diagrams, Gantt charts, pie charts, git graphs, mind maps, timelines, and more. The diagram is wrapped in a ```mermaid code block as required by Slidev. Can append a new slide, insert at a position, or replace an existing slide. Set dry_run=true to preview the slides.md diff without writing. Reference: https://mermaid.js.org/intro/syntax-reference.html
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"diagram_type": "<diagram_type>",
"definition": "<definition>"
},
"name": "add_diagram"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| index | No | If provided (and slide_number is not set), INSERTS the new diagram slide at this 1-based position. If both index and slide_number are omitted, appends at the end. | |
| title | No | Optional slide heading (rendered as # heading above the diagram). Leave empty to show only the diagram with no title. | |
| layout | No | Slidev layout to apply to this slide (e.g. 'center', 'default', 'full'). Defaults to 'default' if omitted. | |
| caption | No | Optional caption displayed below the diagram. Useful for citing sources or adding brief notes. | |
| dry_run | No | Preview the change without writing slides.md. Returns dryRun, wouldWrite, and diff. | |
| definition | Yes | The Mermaid diagram definition. Do NOT include the opening diagram type keyword if it is already captured by diagram_type — instead provide only the diagram body. However, for diagram types like 'flowchart', 'graph', 'sequenceDiagram', etc. that require a direction or keyword as the first line (e.g. 'flowchart TD' or 'sequenceDiagram'), include the full definition starting from that keyword. IMPORTANT: The tool wraps your definition in ```mermaid ... ``` automatically. Do NOT add the code fence yourself. Example for flowchart: flowchart TD A[Start] --> B{Decision} B -->|Yes| C[Result] Example for sequenceDiagram: sequenceDiagram Alice->>Bob: Hello Bob-->>Alice: Hi! | |
| diagram_type | Yes | Mermaid diagram type. Supported types: flowchart/graph — Directed flowcharts and graphs sequenceDiagram — Sequence/interaction diagrams classDiagram — UML class diagrams stateDiagram-v2 — State machine diagrams erDiagram — Entity-relationship diagrams gantt — Project/schedule Gantt charts pie — Pie/donut charts journey — User journey maps gitGraph — Git branching history mindmap — Mind maps timeline — Timeline diagrams quadrantChart — 2x2 quadrant analysis xychart-beta — Bar/line XY charts block-beta — Block/box diagrams packet-beta — Network packet structure architecture-beta — Cloud/system architecture requirementDiagram — Requirements traceability c4Context — C4 architecture context sankey-beta — Sankey flow/energy diagrams zenuml — ZenUML sequence diagrams Reference: https://mermaid.js.org/intro/syntax-reference.html | |
| slide_number | No | If provided, REPLACES the existing slide at this 1-based position with the diagram slide. If omitted, a new slide is APPENDED at the end of the presentation. |