Agent-first programming language where agents produce JSON AST
Edict
A programming language designed for AI agents. No parser. No syntax. Agents produce AST directly as JSON.
Edict is a statically-typed, effect-tracked programming language where the canonical program format is a JSON AST. It's purpose-built so AI agents can write, verify, and execute programs through a structured pipeline — no text parsing, no human-readable syntax, no ambiguity.
Agent (LLM)
│ produces JSON AST via MCP tool call
↓
Schema Validator ─── invalid? → StructuredError → Agent retries
↓
Name Resolver ────── undefined? → StructuredError + candidates → Agent retries
↓
Type Checker ─────── mismatch? → StructuredError + expected type → Agent retries
↓
Effect Checker ───── violation? → StructuredError + propagation chain → Agent retries
↓
Contract Verifier ── unproven? → StructuredError + counterexample → Agent retries
(Z3/SMT) ↓
Code Generator (pure-JS WASM encoder) → WASM → Execute
Features
- JSON AST — Programs are JSON objects, not text files. No lexer, no parser.
- Structured errors — Every error is a typed JSON object with enough context for an agent to self-repair.
- Type system —
Int,Float,String,Bool,Array<T>,Option<T>,Result<T,E>, records, enums, refinement types. - Effect tracking — Functions declare
pure,reads,writes,io,fails. The compiler verifies consistency. - Contract verification — Pre/post conditions verified at compile time by Z3 (via SMT). Failing contracts return concrete counterexamples.
- WASM compilation — Verified programs compile to WebAssembly via a pure-JS encoder and run in Node.js.
- MCP interface — All tools exposed via Model Context Protocol for direct agent integration.
- Schema migration — ASTs from older schema versions are auto-migrated. No breakage when the language evolves.
Execution Model
Edict compiles to WebAssembly and runs in a sandboxed VM. This is a deliberate security decision — not a limitation:
- No ambient authority — compiled WASM cannot access the filesystem, network, or OS unless the host explicitly provides those capabilities via the pluggable
EdictHostAdapterinterface - Compile-time capability declaration — the effect system (
io,reads,writes,fails) lets the host inspect what a program requires before running it - Runtime enforcement —
RunLimitscontrols execution timeout, memory ceiling, and filesystem sandboxing - Defense-in-depth — agent-generated code that runs immediately needs stronger isolation than human-reviewed code. The effect system + WASM sandbox + host adapter pattern provides exactly that
Host capabilities available through adapters: filesystem (sandboxed), HTTP, crypto (SHA-256, MD5, HMAC), environment variables, CLI arguments. New capabilities are added by extending EdictHostAdapter.
Quick Start
For AI Agents (MCP)
The fastest way to use Edict is through the MCP server — it exposes the entire compiler pipeline as tool calls:
npx edict-lang # start MCP server (stdio transport, no install needed)
Or install locally:
npm install edict-lang
npx edict-lang # start MCP server
Two calls to get started: edict_schema (learn the AST format) → edict_check (submit a program). See MCP Tools for the full tool list.
For Development
npm install
npm test # 2675 tests across 136 files
npm run mcp # start MCP server (stdio transport)
Docker
Run the Edict MCP server in a container — no local Node.js required:
# stdio transport (default — for local MCP clients)
docker run -i ghcr.io/sowiedu/edict
# HTTP transport (for remote/networked MCP clients)
docker run -p 3000:3000 -e EDICT_TRANSPORT=http ghcr.io/sowiedu/edict
Supported platforms: linux/amd64, linux/arm64.
Browser
Run the Edict compiler entirely in the browser — no server required:
| Bundle | Size | Phases | Use case |
|---|---|---|---|
edict-lang/browser |
318 KB | 1–3 (validate, resolve, typecheck, effects, lint, patch) | Lightweight checking |
edict-lang/browser-full |
~14 MB | 1–5 (+ WASM codegen, Z3 contracts, WASM execution) | Full compile & run |
import { compileBrowser, runBrowserDirect } from 'edict-lang/browser-full';
const result = compileBrowser(astJson);
if
Tools (2)
edict_schemaRetrieves the current AST schema format for program construction.edict_checkSubmits a program AST for validation, type-checking, and contract verification.Environment Variables
EDICT_TRANSPORTSets the transport protocol (e.g., http) for the MCP server.Configuration
{"mcpServers": {"edict": {"command": "npx", "args": ["-y", "edict-lang"]}}}