tla-mcp
A TLA+ model checker as a Model Context Protocol server.
Plug a working model checker into Claude Code, Cursor, or any MCP-aware client. Validate specs, replay scenarios, and catch invariant violations without leaving the conversation.
What is this?
TLA+ is a specification language for designing and verifying concurrent and distributed systems. You describe what your protocol should do; a model checker tries every reachable state and tells you when something goes wrong.
The Model Context Protocol (MCP) is how agentic clients like Claude Code call external tools.
tla-mcp bridges the two. It's a stdio MCP server
built on top of tla-rs,
a fast TLA+ model checker written in Rust. Once registered,
your client can parse a spec, list its invariants, run a full
check with a budgeted time limit, and replay specific
scenarios — all from inside the chat.
Install
Pick whichever fits your toolchain. All paths install the same latest release.
Homebrew (macOS, Linuxbrew)
brew install fabracht/tla/tla-mcp
Installs both tla (model checker CLI) and tla-mcp (MCP server). The tap is updated on every release.
Install script (Linux, macOS)
curl -fsSL https://raw.githubusercontent.com/fabracht/tla-rs/main/scripts/install.sh | bash
SHA256-verified binary download. To install just the server, pass flags after bash -s --:
curl -fsSL https://raw.githubusercontent.com/fabracht/tla-rs/main/scripts/install.sh | bash -s -- --bin tla-mcp
Cargo (any platform with a Rust toolchain)
cargo install tla-checker --bin tla-mcp
Pre-built release binaries
Linux x86_64, macOS x86_64, macOS arm64, Windows x86_64 are attached to
every GitHub release
as tla-<platform> and tla-mcp-<platform>
(linux-amd64, macos-amd64, macos-arm64,
windows-amd64.exe), alongside a SHA256SUMS file and the
browser engine (tla_checker.js, tla_checker_bg.wasm).
Register with your client
Claude Code:
claude mcp add --scope user tla -- tla-mcp
Other MCP clients (e.g. claude_desktop_config.json):
{
"mcpServers": {
"tla": {
"command": "tla-mcp"
}
}
}
Restart the client. The eight tools become available immediately.
What the agent gets
Eight tools, versioned JSON schemas (schema_version: "2"):
tool | purpose |
|---|---|
validate_spec |
Parse a .tla file. Returns vars,
constants with resolved values, detected invariants,
has_init / has_next, plus structured parse errors with source spans.
|
list_invariants |
Return the invariants check_spec will verify: the definitions a cfg
INVARIANT directive lists, or, without one, those named Inv*,
TypeOK*, NotSolved*, or a module prefix plus Inv/TypeOK
(MInv, M_TypeOK).
|
check_spec |
Full model checking with required max_states / max_depth /
max_seconds budgets. Returns ok,
invariant_violation (with trace + actions), deadlock,
liveness_violation (prefix + cycle), property_violation (a cfg
PROPERTY failing on an initial state or a transition), limit_reached, or structured error.
|
replay_scenario |
Step through a spec along a guided path (step: <TLA+ expr> or
action: <Name> lines).
Returns per-step state snapshots + variable changes, or a failure with
available_actions on a mismatch.
|
validate_demo |
Run a demo manifest (named variants + ordered beats) and report pass/fail per beat and variant, with the failing assertions on a miss. |
append_beat |
Append a beat to a manifest, persisting it only if all its assertions pass.
Format-preserving — a .toml manifest stays TOML.
|
export_demo_doc |
Render a demo manifest to a tested Markdown walkthrough. |
export_demo_html |
Render a demo manifest to a self-contained, offline HTML walkthrough.
Pass explorable: true to embed the wasm engine as a live
in-browser state explorer (step actions, live invariants).
|
Why TLA+ for an agent?
Most "is this code correct?" questions an agent answers are really questions about reachable behavior — a race condition that fires in one specific interleaving, a queue that grows unboundedly under a corner-case workload, a consensus rule that lets two leaders coexist for one tick. Reasoning about all these by reading code is hard. Asking a model checker is straightforward, when the model checker is one tool call away.
tla-mcp is opinionated about how an agent should
use it. Tool descriptions explicitly tell the agent: budget
all three limits upfront; inspect constants before running;
treat limit_reached as inconclusive, not as a
pass; bugs are usually in the last transition of the trace.
These are not soft hints — they're encoded in the tool
metadata so they survive context truncation.