UML-MCP supports TikZ/PGF graphics via Kroki. You can render TikZ and LaTeX snippets to SVG, PDF, PNG, or JPEG without installing TeX locally.
Use diagram_type: "tikz" with the generate_uml or generate_diagram_url tools. The code parameter is your TikZ/LaTeX source (snippet or full document).
The TikZ module provides a template library and auto-wrapping:
\begin{tikzpicture}...\end{tikzpicture}, the server wraps it in a minimal standalone LaTeX document and infers required TikZ libraries where possible.code already contains \documentclass, it is sent as-is to Kroki.Templates (via tools.kroki.tikz.TikZTemplateLibrary) include:
| Template | Description |
|---|---|
| flowchart | Decision/process flowchart |
| graph | Simple node-and-edge graph |
| math_plot | 2D function plot (pgfplots) |
| tree | Tree structure |
| automata | Finite state machine |
| geometry_circle | Circle and axes |
| mindmap_simple | Mind map |
| circuit_simple | Simple circuit (IEC) |
| coordinate_grid | XY grid |
| block_diagram | Input–Process–Output blocks |
Example files are in examples/:
example-tikz-flowchart.tex, example-tikz-math.tex, example-tikz-graph.texexample-tikz-automata.tex, example-tikz-tree.tex, example-tikz-3d.texexample-tikz-mindmap.tex, example-tikz-circuit.tex, example-tikz-block.tex| Format | Best for | Notes |
|---|---|---|
| SVG | Web, scaling | Vector, small size |
| Print, documents | Vector, high quality | |
| PNG | Presentations, UI | Raster, good compatibility |
| JPEG | Photos, large areas | Raster, smaller files |
Use output_format in the tool call (e.g. "svg", "pdf", "png", "jpeg").
Flowchart (uses shapes, arrows, positioning):
\begin{tikzpicture}[node distance=2cm]
\node[rectangle, draw] (start) {Start};
\node[diamond, draw, below of=start] (dec) {OK?};
\draw[->] (start) -- (dec);
\end{tikzpicture}
Math plot (uses pgfplots):
\begin{tikzpicture}
\begin{axis}[xlabel=$x$, ylabel=$f(x)$, grid=major]
\addplot[blue, domain=-2:2] {x^2};
\end{axis}
\end{tikzpicture}
Automata (uses automata, positioning):
\begin{tikzpicture}[shorten >=1pt, node distance=2cm]
\node[state, initial] (q0) {$q_0$};
\node[state, accepting, right of=q0] (q1) {$q_1$};
\draw[->] (q0) to node {1} (q1);
\end{tikzpicture}
\usetikzlibrary{...} in your code when you use features from a library; the server can also infer some libraries from common commands.\usepackage{pgfplots} and \pgfplotsset{compat=1.18} when needed.\documentclass{standalone}\usepackage{tikz}\usepackage{pgfplots}...).| Aspect | Kroki (default) | Local (Docker) |
|---|---|---|
| Setup | None | Docker build/run |
| Network | Required | Optional |
| Custom TeX | Kroki’s environment | Your image |
| Use case | Most diagrams | Offline or custom deps |
To use optional local compilation, set USE_LOCAL_LATEX=true and use the LaTeX Docker setup under tools/docker/ (see Optional Docker).
For local LaTeX/TikZ compilation without Kroki:
docker compose -f tools/docker/docker-compose.latex.yml build
docker compose -f tools/docker/docker-compose.latex.yml up -d
.tex file inside the container (e.g. from examples/):
docker exec -it uml-mcp-latex xelatex -interaction=nonstopmode /workspace/examples/example-tikz-flowchart.tex
See tools/docker/README.md for details and volume mounts.