One Schema, 13 Targets
REST API, CLI, MCP server, VS Code extension, web UI, HTTP client, protocol buffers, property tests, formal verification — all from a single .morph file.
Write a .morph schema once. Generate branded types, REST APIs, CLIs, MCP servers, VS Code extensions, web UIs, and more — all mechanically correct.
bunx @morphdsl/cli generation:new-project pastebin --schema-file pastebin.morph
cd pastebin && bun install
bun run --filter '@pastebin/api' start
domain Pastebin
extensions {
storage [memory, sqlite, redis] default memory
}
context pastes "Simple pastebin for sharing text snippets." {
@root
entity Paste "A text snippet shared via URL." {
content: string "The paste content"
createdAt: string "When the paste was created"
title: string "Optional title for the paste"
}
@cli @api @ui
command createPaste "Create a new paste."
writes Paste
input {
content: string "The paste content"
title?: string "Optional title"
}
output Paste
emits PasteCreated "Emitted when a new paste is created"
@cli @api @ui
query listPastes "List all pastes."
reads Paste
input {}
output Paste[]
}
REST API, CLI, MCP server, VS Code extension, web UI, HTTP client, protocol buffers, property tests, formal verification — all from a single .morph file.
No LLMs in the pipeline. Every transformation is mechanical and structure-preserving. If the core is correct, derived apps are correct by construction.
Built on Lawvere's functorial semantics. A .morph schema defines an algebraic theory; each generator is a structure-preserving functor.
You write only domain handlers and scenario tests. Everything else — types, routes, commands, UI, client code — is generated.
5 storage backends (memory, JSON, SQLite, Redis, event-sourced), multiple auth strategies, domain events — all swappable via environment variables.
Scenarios run as algebraic laws across multiple targets. If core passes but API fails, the natural transformation has a bug — the diagram doesn't commute.
| Target | What it produces |
|---|---|
| dsl | Branded IDs, Effect schemas, operation descriptors |
| core | Handler interfaces, repository ports, DI layers |
| api | REST routes, OpenAPI spec, SSE event streams |
| cli | Interactive REPL and one-off commands |
| mcp | MCP server exposing operations as LLM tools |
| ui | Server-rendered web UI (Pico CSS) |
| vscode | VS Code extension with DSL language support |
| client | Type-safe HTTP client library |
| proto | Protocol buffer definitions |
| verification | SMT-LIB2 formal verification (Z3) |