Loops
by morliont
README.md
# Loops — causal loop diagrams, drawn with you in chat
[](https://github.com/morliont/causal-loop-diagram-generator/actions/workflows/ci.yml)
[](LICENSE)
Describe a messy, recurring problem to Claude — support tickets climbing despite hiring,
roads congesting again after widening, exam panic crowding out learning — and Loops draws
the feedback loops that drive it. You get a link, open the same diagram, edit it by hand,
and Claude reads your version back and carries on from there.
A causal loop diagram (CLD) is a picture of the feedback loops
behind a problem: arrows whose **+** or **−** sign says "goes up together" or "goes down
when the other goes up", **R** loops that amplify, **B** loops that push back, and delay
marks where an effect arrives late. It's the standard vocabulary of system dynamics
(Forrester, Meadows, Sterman), minus the fiddly drawing tool.
- **Live site:** <https://loops.thijsmorlion.com>
- **MCP endpoint:** `https://loops.thijsmorlion.com/mcp` (streamable HTTP)
- Listed in the official MCP Registry as `io.github.morliont/loops`
No install, no account, no fee.
## How people use it
1. **Describe the situation in a chat**, in one or two sentences.
2. Claude drafts the diagram — a few variables, named loops, signs and delays —
and you can open it in the chat itself on Claude surfaces that support MCP apps.
3. **Everything is a shared link** (`loops.thijsmorlion.com/d/…`). Open it anywhere to
view, edit by hand, undo/redo, and export. Anyone with the link sees the live document.
4. Keep talking: add a variable mid-sentence and Claude edits the same diagram rather
than starting over.
### Examples
Real diagrams, made by describing a mess in one sentence:
- SaaS support backlog grows despite hiring —
<https://loops.thijsmorlion.com/d/Vbee-PlnpTxB78-EvwwUdw>
- Exam panic vs. deep learning —
<https://loops.thijsmorlion.com/d/TWRrXvlqWJvMJGm4p4Q5Gw>
- Why widened roads re-congest (induced demand) —
<https://loops.thijsmorlion.com/d/q4IW1LX3WVsHmUj3RT14mQ>
Example links are live documents; they expire 90 days after last use.
## Why it draws better loops than "just ask the model"
The diagram rules live in the **server**, not in a prompt you hope the model remembers:
- Variable names stay neutral and measurable ("Wait time", not "Longer waits"), and the
server reuses existing variables instead of spawning near-duplicates.
- Every link sign is decided by one question: "if the cause goes up, does the effect go
up or down?"
- Delay marks are set per link when an effect arrives noticeably later.
- Loop types are **computed by the tool** — the model may reuse the tool's B/R names and
never invents them. The editor's side panel shows each loop's full path and type.
- First drafts stay small: 1–3 core loops, ~12 variables at most, and the server nudges
for the loops stories usually forget (the driver, the thing that pushes back, the quick
fix vs. the slow one).
- Errors come back per-command with a reason and next steps, so the assistant fixes the
one wrong command without redrawing everything.
## Connect it to your assistant
### Claude (web / desktop app)
1. Open Claude → **Settings** → **Connectors**.
2. Choose to add a **custom connector**.
3. Paste `https://loops.thijsmorlion.com/mcp` and save.
4. Start a chat and describe a situation you want to understand.
In a Claude Team or Enterprise organization, only an **owner** can add custom connectors —
ask yours to add it for the team.
### Claude Code
```bash
claude mcp add --scope user --transport http loops https://loops.thijsmorlion.com/mcp
```
### Claude Desktop
Claude Desktop runs local servers only, so it bridges through
[`mcp-remote`](https://www.npmjs.com/package/mcp-remote). Install
[Node.js](https://nodejs.org) first.
1. Settings → **Developer** → **Edit Config** — this opens `claude_desktop_config.json`.
2. Add the `loops` entry below under `mcpServers`.
3. Quit and reopen Claude Desktop.
```json
{
"mcpServers": {
"loops": {
"command": "npx",
"args": ["-y", "mcp-remote", "https://loops.thijsmorlion.com/mcp"]
}
}
}
```
### Other assistants
Any MCP client that speaks streamable HTTP can use the endpoint above. ChatGPT support is
coming later. Full instructions are also maintained on the site at
[loops.thijsmorlion.com/connect](https://loops.thijsmorlion.com/connect).
## What it stores (plain words)
- **No accounts.** The only thing stored is the diagram itself.
- Diagrams live server-side in an Upstash Redis database in the **EU**, and are deleted
**90 days** after last use. Details: [the privacy page](https://loops.thijsmorlion.com/privacy).
- **Anyone with a `/d/…` link can view and edit** the diagram. Links are live documents,
not snapshots — share deliberately.
- Diagrams render in the shared editor: signed arrows, delay marks (‖), loop badges
(B1/R1), a Loops side panel with each loop's type and full path, export, undo/redo.
- Abuse protection: per-diagram write rate limits and a daily cap on new diagrams.
## MCP tools
Three tools, all stateless JSON-RPC over HTTP:
- **`create_diagram`** — batch commands to build a first draft; returns the diagram id.
- **`edit_diagram`** — batch commands applied to the latest stored version (add/rename
variables and links, set delays, name loops).
- **`get_diagram`** — read a diagram by id, or by pasted `/d/…` link; useful for an
assistant to pick up a human's hand edits. Carries a UI extension
(`ui://loops/diagram.html`) for clients that support MCP apps.
## Self-hosting
Runs anywhere Node runs; it deploys to Vercel out of the box (that's what powers
loops.thijsmorlion.com).
```bash
pnpm install
pnpm build
pnpm start
```
Environment variables:
- `PUBLIC_BASE_URL` — the public origin, e.g. `https://loops.thijsmorlion.com`, no
trailing slash. Required in production; on Vercel it also redirects `*.vercel.app`
hosts to it (`src/proxy.ts`).
- `UPSTASH_REDIS_REST_URL` + `UPSTASH_REDIS_REST_TOKEN` — the Redis store, required in
production. Outside production without them, an in-memory store is used.
- Optional limits: `LIMIT_DIAGRAM_WRITE_PER_MIN`, `LIMIT_DAILY_CREATE`,
`LIMIT_SITE_IP_PER_MIN`, `LIMIT_SITE_404_PER_HOUR`.
- Optional alert: `ALERT_WEBHOOK_URL` gets one plain-text POST per day when the daily
create cap trips (an [ntfy.sh](https://ntfy.sh) topic URL works); the log line to
match is `daily-create-fuse-tripped`.
- Logging: one line per MCP tool call — `mcp: tool=<name> outcome=<ok|error|failed>
bytes=<size>` — and nothing else, deliberately.
## Development
```bash
pnpm dev # local dev server
pnpm test # vitest unit tests
pnpm eval:report # diagram-quality evals
pnpm typecheck # next typegen + tsc --noEmit
pnpm lint # eslint
pnpm format:check # prettier
```
Next.js App Router; diagram canvas is [React Flow](https://reactflow.dev); the MCP server
speaks streamable HTTP. CI runs the checks above on every push.
Design background: [`docs/specs/2026-10-24-chat-connector-design.md`](docs/specs/2026-10-24-chat-connector-design.md).
## License
[AGPL-3.0](LICENSE) © 2026 Thijs Morlion. Copyleft applies to the code; that includes
anything you serve from a modified fork, even as a hosted service. If you want to use it
under different terms, open an issue.
## About
Built by [Thijs Morlion](https://thijsmorlion.com) with AI agents, as an open,
agent-operated experiment. Questions and feedback → the issue tracker.
This server cannot be deployed
Maintenance
ActivityActive
ResponsivenessNo recent community issues