Stockflow
Exports stock-and-flow and causal loop diagrams as SVG vector files for journals, theses, slides and web use.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Stockflow
Publication-quality Forrester (stock-and-flow) and causal loop diagrams, built by AI agents. MCP server · CLI · live web editor · Claude Code skill — zero dependencies, ~170 kB installed.
Stockflow lets an assistant such as Claude turn a system dynamics model into a clean diagram in a single tool call: stocks, flows, clouds, auxiliaries, constants, exogenous variables, delays, lookup tables, information links with polarity and R/B feedback loops. It lays everything out automatically, checks the notation, detects the feedback loops and their polarity, and exports vector PDF/EPS/SVG ready for journals, theses and slides. It draws models; it does not simulate them.
Features
Academic style by default — monochrome, serif (Times metrics, embedded in the PDF), thin uniform strokes, dashed information links, typographic
+/−polarities and classic R/B loop markers. Prints well in grayscale.Figure furniture — automatic symbol legend (only the symbols in use),
Figure N.caption and source line, in English or Spanish.Exports — PDF and EPS (vector, for LaTeX/Word), SVG, PNG at 300/600 dpi. A colourful, animated modern style is available for slides and the web.
Automatic layout — stock chains on a grid, flows and clouds on free sides, parallel pipes, labels that do not overlap, polarity signs and loop markers that avoid text, cycle-aware ordering for causal diagrams.
Model checks — feedback loops with computed polarity, plus warnings for notation errors (information links into stocks, flows without drivers, constants receiving links, causal links without polarity…).
Live editor — drag nodes and clouds, bend links, create elements with the keyboard, edit captions; it updates by itself whenever the agent or the CLI changes the diagram. In academic style the canvas shows the exact page that will be exported.
Fast and light — no npm dependencies, CLI start-up ≈ 50 ms, a 30-node diagram renders in ≈ 2 ms.
Related MCP server: OpenKer Modeler MCP Server
Install and connect your agents
Stockflow is one local program. Every AI agent talks to it the same way: the agent launches
stockflow mcp (an MCP server over stdio) and gets the diagram_* tools; all agents share the same diagrams and the
same live editor. The skill (SKILL.md) is the "how to model and draw" guide for agents that support skills; agents
without skills get the same guidance from the MCP server's instructions and tool descriptions.
Requires Node.js ≥ 20. PDF/EPS/PNG export uses rsvg-convert (librsvg: pacman -S librsvg,
apt install librsvg2-bin, brew install librsvg); SVG export needs nothing else.
1. Install once (~200 kB, downloads a tarball, no git history):
curl -fsSL https://raw.githubusercontent.com/Jairodaniel-17/stockflow/master/install.sh | shThe installer puts the stockflow CLI in ~/.local/bin and runs stockflow connect, which detects your agents and
registers the MCP server (and the skill, where supported) in each of them.
2. Connect agents (any time, e.g. after installing a new agent):
stockflow connect # every agent detected on this machine
stockflow connect codex cursor # only these
stockflow connect --list # status
stockflow disconnect # undo (a .bak-stockflow copy of each config is kept)Agent | What | Skill |
Claude Code |
|
|
Codex CLI |
|
|
Claude Desktop |
| — |
Cursor |
| — |
VS Code (Copilot) |
| — |
Gemini CLI |
| — |
Windsurf |
| — |
OpenCode |
| — |
Absolute paths are used for node and the script, so desktop apps that do not inherit your shell PATH work too.
Restart the agent after connecting.
Any other MCP client: point it to the stdio command printed by stockflow connect --list:
{ "mcpServers": { "stockflow": { "command": "node", "args": ["/path/to/stockflow/bin/stockflow.js", "mcp"] } } }Agents without MCP but with a shell can use the CLI directly (stockflow create model.json, stockflow render …).
Alternatives: as a Claude Code plugin (skill + MCP bundled) —
claude plugin marketplace add Jairodaniel-17/stockflow && claude plugin install stockflow@stockflow — or with npm —
npm install -g github:Jairodaniel-17/stockflow && stockflow connect.
Using it from an AI agent
Ask for the diagram in plain language, e.g. "Draw the Forrester diagram of an SIR epidemic for my paper, in English, as Figure 2". The agent will typically call:
Tool | Purpose |
| Create a whole diagram (nodes, links, loops, caption…) in one call; positions are optional |
| Add or change elements by id, remove ids, re-layout |
| Feedback loops (R/B) and notation warnings |
| Export SVG/PDF/EPS/PNG; |
| Open the live editor |
| Housekeeping |
Example input:
{
"title": "SIR epidemic", "type": "forrester", "auto_loops": true, "legend": true, "lang": "en",
"figure": "2", "caption": "Stock-and-flow structure of the SIR model.", "source": "Adapted from Sterman (2000).",
"nodes": [
{"id": "s", "type": "stock", "label": "Susceptible"},
{"id": "i", "type": "stock", "label": "Infected"},
{"id": "r", "type": "stock", "label": "Recovered"},
{"id": "infection", "type": "flow", "label": "Infection", "from": "s", "to": "i"},
{"id": "recovery", "type": "flow", "label": "Recovery", "from": "i", "to": "r"},
{"id": "contact", "type": "constant", "label": "Contact rate"},
{"id": "duration", "type": "constant", "label": "Illness duration"}
],
"links": [
{"from": "s", "to": "infection", "polarity": "+"}, {"from": "i", "to": "infection", "polarity": "+"},
{"from": "contact", "to": "infection", "polarity": "+"},
{"from": "i", "to": "recovery", "polarity": "+"}, {"from": "duration", "to": "recovery", "polarity": "-"}
]
}Notation
Symbol |
| Notes |
Stock / level (rectangle) |
| Changes only through flows |
Flow / rate (valve on a double pipe) |
|
|
Auxiliary (circle) |
| |
Constant / parameter (line with small circle) |
| Receives no links |
Exogenous variable (double circle) |
| Receives no links |
Delay (box with three cells) |
| |
Lookup table |
| |
Cloud |
| Usually implicit through |
Causal variable (text) |
| For |
Links: polarity +/-, curve (-1.5…1.5), delay: true (‖ mark), style solid/dashed, label.
Loops: type R/B, nodes (marker is centred automatically), label, dir cw/ccw.
shadow: true draws a shadow variable as <Name>. Spanish type names are accepted too (nivel, flujo, auxiliar…).
CLI
stockflow create examples/cacao.json --loops # full diagram from JSON
stockflow new store --title "Inventory" # or step by step
stockflow add store stock Inventory
stockflow add store flow Sales --from inventory
stockflow add store aux Demand
stockflow link store demand sales +
stockflow analyze store
stockflow meta store --figure 2 --caption "Inventory structure." --source "Own elaboration" --lang en --legend
stockflow render store -o store.pdf # .eps .svg .png (--dpi 300) --style modern --theme dark
stockflow open store # live editor at http://localhost:4610
stockflow mcp # MCP server on stdioDiagrams are JSON files in ~/.local/share/stockflow/diagrams (STOCKFLOW_HOME changes it, STOCKFLOW_PORT the editor port).
Editor shortcuts
S stock · W flow (click source then target; empty space = cloud) · X auxiliary · C constant ·
E exogenous · D delay · B table · Q causal variable · K link · O loop marker · V select ·
L auto-layout · F fit · A loops and warnings · G figure panel · T theme · M animation ·
Ctrl+Z / Ctrl+Shift+Z undo/redo · arrows nudge · drag a link to bend it.
License
MIT © Jairo Mendoza
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Software diagrams for developers, teams and agents — give your AI agents diagramming superpowers.
Draw causal loop diagrams in the chat and edit them on a shared link.
Create and edit architecture diagrams from your AI agent; get an SVG and a live editable canvas.
Immutable diagrams for AI agents: create, edit, validate and render versioned diagrams over MCP.
Related MCP Servers
- AlicenseBqualityCmaintenanceEnables AI assistants to programmatically create, read, validate, and modify Stella system dynamics models in the XMILE format. It supports building complex stock-and-flow diagrams and exporting them as .stmx files for use in Stella Professional.445MIT
- -licenseNot gradedqualityNot gradedmaintenanceEnables AI agents to traverse SysML v2 model graphs, query requirements, and perform impact analysis for model-based systems engineering. It allows agents to interact with plain-text models to automate documentation and refine system architectures.-
- AlicenseBqualityDmaintenanceEnables AI agents to create publication-quality scientific diagrams, flowcharts, and architecture diagrams in OmniGraffle via natural language commands.3710MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to build, edit, organize, and export Excalidraw diagrams (architecture, flowcharts, etc.) entirely headless, producing .excalidraw files, SVG, and PNG renders.3,392 npmMIT