Diagrams MCP Server

v0.11.0
io.github.mohammad-emad-dev/diagrams-mcp-server Checked 2 days ago Published 1 month ago

Local-first MCP server for PlantUML and Mermaid diagrams with drift detection.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

diagrams_list List Architecture Diagrams

List all PlantUML and Mermaid diagram files stored under the project's diagrams directory. This tool scans the configured diagrams root recursively and returns every file with a recognized diagram extension (.puml, .plantuml, .mmd, .mermaid). It does NOT create, modify, or render diagrams — read-only. Args: - type_filter ('plantuml' | 'mermaid' | 'all'): Restrict results to one diagram type (default: 'all') - offset (number, optional): Zero-based number of matching diagrams to skip (default: 0) - limit (number, optional): Maximum diagrams to return (1-500). Omit to return every remai…

ParameterTypeDescription
limitintegerMaximum number of diagrams to return (1-500). Omit to return every remaining match.
offsetintegerZero-based number of matching diagrams to skip before the returned page (default: 0).
type_filterstringRestrict results to a single diagram type, or 'all' for both.

diagrams_get Get Diagram Source

Retrieve the raw source text of a single PlantUML or Mermaid diagram, in full or as an explicit character window. Args: - relative_path (string): Path to the diagram relative to the diagrams root, as returned by diagrams_list - offset (number, optional): Zero-based character offset where the returned window starts (default: 0) - max_chars (number, optional): Maximum characters to return from offset (1-100000). Omit to return the full source Returns: JSON with schema: { "relative_path": string, "type": "plantuml" | "mermaid", "content": string, // full source, or t…

ParameterTypeDescription
relative_path *stringPath to the diagram, relative to the diagrams root (e.g. 'system/order-flow.puml'). Get this from diagrams_list.
max_charsintegerMaximum characters to return starting at offset (1-100000). Omit to return the full source.
offsetintegerZero-based character offset into the diagram source where the returned window starts (default: 0).

diagrams_create Create New Diagram

Create a new PlantUML or Mermaid diagram file under the diagrams root. The diagram type is inferred from the file extension in relative_path: - .puml or .plantuml -> PlantUML - .mmd or .mermaid -> Mermaid This tool refuses to overwrite an existing file — use diagrams_update for that. Intermediate directories in relative_path are created automatically. Performs a basic, dependency-free syntax check before writing (not full validation): PlantUML must include @startuml/@enduml boundaries; Mermaid must start with a known diagram declaration. Clearly invalid or empty sources are rejected w…

ParameterTypeDescription
content *stringFull PlantUML or Mermaid source text for the diagram.
relative_path *stringPath for the new diagram, relative to the diagrams root, including extension (.puml, .plantuml, .mmd, or .mermaid). E.g. 'system/order-flow.puml'.

diagrams_update Update Existing Diagram

Replace the full content of an existing PlantUML or Mermaid diagram file. This performs a full-content replace, not a partial edit — pass the complete new diagram source. To create a new diagram, use diagrams_create (or set create_if_missing=true here). Performs a basic, dependency-free syntax check before writing (not full validation): PlantUML must include @startuml/@enduml boundaries; Mermaid must start with a known diagram declaration. Clearly invalid or empty sources are rejected without overwriting the existing file. Args: - relative_path (string): Path to the diagram, relative to…

ParameterTypeDescription
content *stringNew full PlantUML or Mermaid source text that replaces the existing content.
relative_path *stringPath to the existing diagram, relative to the diagrams root.
create_if_missingbooleanIf true and no diagram exists at relative_path, create it instead of failing (default: false).

diagrams_delete Delete Diagram

Delete a single PlantUML or Mermaid diagram file from the diagrams root. This is destructive and cannot be undone — the file is removed from disk. To replace content instead, use diagrams_update. To remove then recreate with different content, delete first, then use diagrams_create. Args: - relative_path (string): Path to the diagram relative to the diagrams root, as returned by diagrams_list Returns: JSON with schema: { "relative_path": string, "deleted": true } Examples: - Use when: "Remove the outdated order-flow diagram" -> relative_path="system/order-flow.puml" -…

ParameterTypeDescription
relative_path *stringPath to the diagram to delete, relative to the diagrams root (e.g. 'system/order-flow.puml'). Get this from diagrams_list.

diagrams_render Render Diagram to Image

Render a PlantUML or Mermaid diagram to an image (SVG or PNG) and return it as base64-encoded image content. Rendering requirements: - Mermaid: requires the 'mmdc' CLI (install with: npm install -g @mermaid-js/mermaid-cli). No fallback exists. - PlantUML: uses a local 'plantuml' CLI if installed. Without one, rendering fails unless remote rendering is explicitly enabled with ALLOW_REMOTE_PLANTUML=true, in which case it falls back to the configured PlantUML rendering server over HTTPS (requires internet access; sends diagram source to that server). DISABLE_REMOTE_PLANTUML=true always disab…

ParameterTypeDescription
relative_path *stringPath to the diagram to render, relative to the diagrams root.
formatstringOutput image format (default: 'svg').

diagrams_export Export Diagram as a Self-Contained HTML File

Package a stored PlantUML or Mermaid diagram and its rendered SVG into one self-contained HTML file you can share or open outside the repo. The SVG is encoded as a data image, so renderer markup is not parsed into the HTML DOM. SVG image processing disables scripts and external resource loading. A restrictive content security policy allows only data images and inline wrapper styles. SVG text is not selectable in the exported image. Diagram source is escaped in a native collapsible block when include_source is set, and the artifact works offline without new dependencies. Rendering uses the sam…

ParameterTypeDescription
relative_path *stringPath to the diagram to export, relative to the diagrams root.
include_sourcebooleanEmbed the diagram source in a collapsible block so the artifact explains itself (default: true). The block is a native <details> element, so it works without JavaScript.

diagrams_save_export Save Diagram Export as HTML File

Save a stored PlantUML or Mermaid diagram as one self-contained HTML file inside the diagrams root. The SVG is encoded as a data image, so renderer markup is not parsed into the HTML DOM. SVG image processing disables scripts and external resource loading. A restrictive content security policy allows only data images and inline wrapper styles. SVG text is not selectable in the exported image. Diagram source is escaped in a native collapsible block when include_source is set, and the artifact works offline without new dependencies. Rendering uses the same path and the same rules as diagrams_re…

ParameterTypeDescription
output_path *stringPath for the saved HTML file, relative to the diagrams root, ending in .html (case-insensitive). Intermediate directories are created. Existing files are refused, never overwritten.
relative_path *stringPath to the diagram to export, relative to the diagrams root.
include_sourcebooleanEmbed the diagram source in a collapsible block so the artifact explains itself (default: true). The block is a native <details> element, so it works without JavaScript.

diagrams_check_consistency Check Diagram-to-Code Consistency

Compare class/interface/component names mentioned in a PlantUML or Mermaid diagram against identifiers that actually exist in the codebase, to catch documentation drift. This is a heuristic, text-based check (not a full semantic/AST analysis): it extracts entity names from class/interface/enum/component declarations in the diagram, then searches source files under the project root for a matching identifier as a whole word. It flags names that appear in the diagram but were not found anywhere in the scanned code — a signal the diagram may be outdated, or the code was renamed/removed/not yet…

ParameterTypeDescription
relative_path *stringPath to the diagram to check, relative to the diagrams root.

diagrams_generate Generate a Class Diagram from Code

Draft a PlantUML or Mermaid class diagram from a slice of the codebase, returning source text to review and then save with diagrams_create. This is the generative flip side of diagrams_check_consistency: the same code-reading machinery that detects drift can seed the diagram in the first place. It reads class/interface/enum/type/function declarations under the requested scope and emits one box per declared name, plus extends/implements edges when the TypeScript AST can evidence them. It never writes: nothing lands in the diagrams directory without an explicit diagrams_create call. It is a he…

ParameterTypeDescription
formatstringOutput dialect for the generated class diagram (default: 'puml').
include_relationsbooleanEmit 'A <|-- B' / 'A <|.. B' extends/implements edges when relation evidence is available (default: true). Relations are read from TypeScript heritage clauses only, so a scope without TypeScript-famil…
max_entitiesintegerHard cap on emitted class/interface declarations, an integer between 1 and 60 (default: 30). The applied cap is reported as entity_limit; anything past it is counted in entities_available and flagged…
scopestringRelative path under the project root pointing at a file or a directory to read (default: '.', the whole project root). Absolute paths and anything that resolves outside the project root are refused.

diagrams_generate_sequence Generate a Sequence Diagram from Code

Draft a PlantUML or Mermaid sequence diagram from the message-call patterns in a slice of the codebase, returning source text to review and then save with diagrams_create. Static call-site order is not runtime order. This tool reads call sites in the order a reader meets them and says so in every result: a call inside a callback, promise, or listener is counted in deferred_count and excluded from the messages, because its real position in the conversation is unknowable from source. It is the generative flip side of the consistency checker's ordered call graph: the same caller-to-callee evide…

ParameterTypeDescription
formatstringOutput dialect for the generated sequence diagram (default: 'puml').
include_call_parenthesesbooleanWhen true, emitted message labels append '()' in both dialects (default: false). Structured messages.message values stay bare.
max_messagesintegerHard cap on emitted messages, an integer between 1 and 50 (default: 20). The applied cap is reported as message_limit; messages past it, or to a participant the participant cap removed, are counted in…
max_participantsintegerHard cap on declared participants, an integer between 1 and 20 (default: 8). The applied cap is reported as participant_limit; anything past it is counted in participants_available and flagged by part…
scopestringRelative path under the project root pointing at a file or a directory to read (default: '.', the whole project root). Absolute paths and anything that resolves outside the project root are refused.

diagrams_diff Diff Two Diagrams

Compare two diagram sources — two stored files, or a stored file against inline text — and report the added, removed, and renamed entity names in structured form. This is the review-time companion to diagrams_check_consistency: that tool asks whether a diagram still matches the code, this one asks what changed between two versions of the diagram itself. Give it the previous version as a_relative_path or a_content and the new version as the b side, and it lists what a reviewer needs to confirm. It is pure comparison over sources the store already knows how to read: no writes, no network, n…

ParameterTypeDescription
a_contentstringSide a as inline source text (no file read). Exactly one of a_relative_path or a_content must be given; the dialect is detected from the source itself.
a_relative_pathstringSide a as a stored diagram: path relative to the diagrams root (e.g. 'system/order-flow.puml'). Exactly one of a_relative_path or a_content must be given.
b_contentstringSide b as inline source text. Exactly one of b_relative_path or b_content must be given; the dialect is detected from the source itself.
b_relative_pathstringSide b as a stored diagram: path relative to the diagrams root. Exactly one of b_relative_path or b_content must be given.
compare_call_orderbooleanCompare recognized message-call names in order, including repetitions (default: false). Plain labels, arguments, endpoints and control flow are not compared.
include_rename_evidencebooleanInclude exact recognized diagram message-call counts for paired rename names (default: false). Limited to 100 pairs and 10000 calls per side. This is label evidence only and does not scan code or prov…

diagrams_template Instantiate a Diagram Skeleton

Emit a built-in starter skeleton (class, sequence, or C4-context) or a custom project template in PlantUML or Mermaid, returning validated source text to fill in and then save with diagrams_create. Built-in skeletons are pure and require no filesystem or code scan. Custom templates read one named JSON file under PROJECT_ROOT/.diagrams-templates; identical inputs and file contents yield identical source. No template evaluates code or fetches remote resources. It never writes: nothing lands in the diagrams directory without an explicit diagrams_create call, and the emitted source clears the ex…

ParameterTypeDescription
entities *arrayEntity names to instantiate, 1 to 20 of them, each an identifier matching /^[A-Za-z_][A-Za-z0-9_]*$/ at most 60 characters long, with no duplicates. Names are emitted in the given order, one declarati…
template *stringWhich starter skeleton to emit: 'class' (a box per entity), 'sequence' (a participant per entity), 'c4_context' (one context-level system per entity), or 'custom' (a named JSON template in the project…
custom_templatestringCustom template identifier without extension or path; required only when template is 'custom'.
formatstringOutput dialect for the skeleton (default: 'puml').
titlestringOptional diagram title, at most 200 characters. Whitespace-only is rejected rather than emitting an empty title line. Internal whitespace runs are collapsed so the title stays one line, and the normal…

diagrams_list_templates List Available Diagram Templates

Discover the diagram templates diagrams_template can instantiate, without reading any template contents. Lists the built-in skeleton kinds (each supports 'puml' and 'mermaid') plus the custom-template candidate names found as *.json entries directly under PROJECT_ROOT/.diagrams-templates. A candidate name is an identifier to pass as custom_template to diagrams_template with template='custom'; the definition, the selected dialect, and the emitted source are validated there, not here. Discovery reads directory entries only — file contents are never read, so a malformed JSON file can still app…

diagrams_scaffold Scaffold TypeScript or JavaScript Classes from a Diagram

Draft bounded empty exported TypeScript or JavaScript classes from entity-name candidates in a stored PlantUML or Mermaid diagram, returning source text to review and then save yourself. TypeScript is the default language. This reads heuristic entity-name candidates through the existing extractor unchanged, so candidates may include aliases, namespaces, components, participants, and call names such as charge. By default (all opt-in flags false) TypeScript mode does NOT recover class kinds, members, field types, relations, or runtime behavior. Every result says so with confidence "heuristic" p…

ParameterTypeDescription
relative_path *stringPath to the diagram to scaffold from, relative to the diagrams root.
include_membersbooleanTypeScript-only opt-in heuristic member stubs from plain class NAME { ... } blocks (default: false). With other opt-ins disabled, false keeps empty classes with no new keys; true adds throwing stubs p…
include_relationsbooleanTypeScript-only opt-in named association fields (default: false). Implies include_types and include_members. Only labeled --> relations between explicitly declared, emitted plain classes are used; no…
include_typesbooleanTypeScript-only opt-in heuristic field types for member stubs (default: false). True implies include_members=true; with relations disabled, false adds no new keys. True resolves field labels to string…
languagestringOutput language (default: typescript). JavaScript emits empty exported class shells only and cannot be combined with include_members, include_types, or include_relations.
max_entitiesintegerHard cap on emitted class shells, an integer between 1 and 60 (default: 30). The applied cap is reported as entity_limit; anything past it is counted in entities_available and flagged by entities_capp…