hol4-mcp
OfficialClick on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@hol4-mcp check if the proof of my_theorem completes in myScript.sml"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
hol4-mcp
An MCP server that gives LLM agents interactive access to the HOL4 theorem prover. Agents can start HOL sessions, navigate proofs, inspect goal states, and build theories — all through structured tool calls.
Features
Proof cursor — Navigate to any position in a proof file and see the goal state. The cursor tracks file edits, replays tactics incrementally, and uses PolyML checkpoints for fast state restoration.
Multi-theorem files — Parse
*Script.smlfiles to discover theorems, definitions, and resume blocks. Enter any theorem and step through its proof.Holmake integration — Build theories with progress reporting and failure diagnostics (build logs, error context).
Session management — Multiple named HOL sessions with idle timeout, automatic garbage collection, and SIGINT-based interrupt for runaway tactics.
Change detection — Content hashing detects file edits automatically. No need to restart sessions after modifying proof files.
Pi extension — Ships with a pi extension that registers all tools dynamically.
Related MCP server: leanforge-mcp
Requirements
HOL4 installed, with
HOLDIRenvironment variable set (defaults to~/HOL)Python ≥ 3.11
uv (recommended) or pip
Installation
# From source
uv pip install -e .
# Or from wheel
uv pip install hol4-mcpPi
Pi uses an extension (not MCP config). Install it:
hol4-mcp install-piThis copies hol4-mcp.ts to ~/.pi/agent/extensions/. No other configuration needed — the extension spawns the MCP server as a subprocess on first tool use, discovers tools dynamically, and cleans up on session exit.
Make sure hol4-mcp is on your PATH and HOLDIR is set in your shell environment.
The agent sees a single hol4_mcp tool with actions list, call, interrupt, and restart.
Claude Code
Add to .mcp.json in your project root (or ~/.claude/mcp.json globally):
{
"mcpServers": {
"hol4": {
"command": "hol4-mcp",
"args": ["--transport", "stdio"],
"env": {
"HOLDIR": "/path/to/HOL"
}
}
}
}Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"hol4": {
"command": "hol4-mcp",
"args": ["--transport", "stdio"],
"env": {
"HOLDIR": "/path/to/HOL"
}
}
}
}Other MCP clients
Run the server directly:
# stdio (default, for MCP clients)
hol4-mcp
# HTTP or SSE
hol4-mcp serve --transport http --port 8000Tools
Session lifecycle
Tool | Description |
| Start a HOL REPL session in a working directory |
| Terminate a session |
| Restart session (preserves workdir and env) |
| List active sessions with age, status, and cursor info |
| Set environment variables and auto-restart |
Proof navigation
Tool | Description |
| Get proof state at a file position (line/col). Auto-inits session and cursor from |
| Check if a theorem's proof completes. Reports pass/fail, timing, and failure location. |
| Get file overview: theorem list, cheat count, per-proof timing. |
Raw interaction
Tool | Description |
| Send raw SML to HOL (for DB queries, type checking, term parsing) |
| Send SIGINT to abort a runaway tactic |
Build
Tool | Description |
| Run |
| Read a specific theory's build log |
| List available build logs |
Typical workflow
1. hol_state_at(line=15, col=1, file="myScript.sml")
→ Shows goals at that proof position
2. Edit the file (add/change tactics)
3. hol_state_at(line=18, col=1)
→ Auto-detects file change, re-parses, replays to new position
4. hol_check_proof(theorem="my_theorem")
→ Verifies proof completes, reports timing
5. holmake(workdir=".")
→ Final build verificationArchitecture
hol4_mcp/
├── hol_mcp_server.py # MCP tool definitions, session registry, FastMCP app
├── hol_session.py # HOL subprocess management (start/stop/send/interrupt)
├── hol_cursor.py # File proof cursor (parsing, replay, checkpoints)
├── hol_file_parser.py # Parse *Script.sml for theorems/definitions/resumes
├── sml_helpers/
│ ├── etq.sml # Legacy goaltree mode helpers
│ └── tactic_prefix.sml # TacticParse-based tactic replay (used by cursor)
└── pi_extension/
└── hol4-mcp.ts # Pi extension (MCP client over stdio)Key internals:
HOLSession — Wraps an
hol --zerosubprocess. Null-byte framing for response detection. Process-group signals for clean interrupt/kill.FileProofCursor — Parses theorems from file, loads dependencies via
holdeptool.exe, replays tactics using HOL'sTacticParse.sliceTacticBlock, and manages PolyMLSaveStatecheckpoints for fast state restoration (~1.4MB per theorem checkpoint vs ~132MB base).Change detection — SHA-256 content hashing. On file change, invalidates checkpoints/traces from the first changed line forward. Pre-theorem changes (imports, ancestors) trigger full session reinit.
Development
# Install dev dependencies
uv pip install --python .venv/bin/python -e ".[dev]"
# Run tests
.venv/bin/python -m pytest tests/ -q
# Run server with debug logging
hol4-mcp serve -vLicense
MIT — see LICENSE.
Available Tools
13 toolshol_check_proofHol Check ProofA
Check if a theorem's proof completes after editing.
Use this after editing a proof to see if it works now. More reliable than hol_state_at with line numbers which may be stale after edits.
Inputs: theorem (required), file, trace, session, +1 more. Returns: result
hol_file_statusHol File StatusC
Get current cursor position and file status.
Inputs: file, timing, session, workdir. Returns: result
hol_interruptHol InterruptB
Send SIGINT to abort runaway tactic.
Inputs: session. Returns: result
hol_logHol LogA
Read build log for a specific theory.
Use after holmake to inspect warnings or errors in detail.
Inputs: theory (required), workdir (required), limit. Returns: result
hol_logsHol LogsC
List available build logs.
Inputs: workdir (required). Returns: result
holmakeHolmakeC
Run Holmake --qof in directory.
Inputs: workdir (required), env, jobs, target, +3 more. Returns: result
hol_restartHol RestartA
Restart HOL session (stop + start, preserves workdir).
Only needed when:
HOL state is corrupted (rare)
Upstream dependencies changed (edited other .sml files that need Holmake)
NOT needed for edits to current proof file - state_at auto-detects changes.
Inputs: session. Returns: result
hol_sendHol SendA
Send raw SML command to HOL session.
WARNING: Do NOT use for proof navigation - use hol_state_at instead. hol_state_at handles file changes, checkpoints, and tactic replay automatically.
Inputs: command (required), session, timeout, max_output. Returns: result
hol_sessionsHol SessionsA
List all active HOL sessions with their workdir, age, status, cursor.
Inputs: no named parameters. Returns: result
hol_setenvHol SetenvA
Set environment variables for a HOL session and auto-restart to apply.
These are passed to the HOL process and affect Holmakefile INCLUDES expansion.
Example: hol_setenv({"VFMDIR": "/home/user/verifereum"})
Inputs: env (required), session. Returns: result
hol_startHol StartA
Start a HOL4 REPL session.
Idempotent - returns existing session if already running. Usually called automatically by hol_state_at (via file= parameter).
Inputs: workdir (required), env, name. Returns: result
hol_state_atHol State AtA
Get proof state at a file position.
Replays tactics from theorem start up to (but not including) the tactic at the given position, then shows current goals. Auto-enters theorem if needed.
By default only the top goal is shown (with total count). Set all_goals=True to see every goal on the stack.
If replay fails before reaching the requested position, the default behavior is to refuse to show goals (they would be from the wrong proof state). Set show_partial=True to see the best-effort goals anyway.
Inputs: line (required), col, file, session, +6 more. Returns: result
hol_stopHol StopC
Terminate HOL session.
Inputs: session. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 13 tools
The tools mostly target clearly distinct areas: session lifecycle, build/log inspection, and proof navigation. The only mild overlap is among hol_state_at, hol_check_proof, and hol_file_status, but their descriptions give enough guidance to choose correctly.
Almost all tools use the hol_ prefix with snake_case naming, making the set predictable. Minor deviations such as holmake (no underscore) and hol_setenv (compressed set-env) keep it from being perfectly consistent.
With 13 tools, the set is well-scoped for HOL4 session management, build/log handling, and proof inspection. Each tool appears to earn its place without obvious redundancy.
The surface covers session lifecycle, raw SML commands, environment setup, Holmake builds, build logs, and proof-state inspection/checking. Some lower-level operations are only reachable via hol_send raw SML, but core HOL4 workflows are covered.
Maintenance
Related MCP Connectors
AI-native programming language and toolchain for accountable, verifiable agent-driven development.
Architecture compiler for AI code. 11 tools, 92 actions, 872 Lean4 proofs, 100/100 self-cert.
Work on open research problems with your agent; results are checked by Lean, reproduction or review.
Deterministic reasoning stack for AI agents: simulate, decide & compute, plus cross-domain tools.
Related MCP Servers
- AlicenseBqualityBmaintenanceEnables LLM agents to interact with the Lean theorem prover through the Language Server Protocol, providing tools for analyzing Lean projects, accessing diagnostics, goal states, documentation, and searching for theorems using both local and external search services.22148,993 PyPI566MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI-driven formal proof search in Lean 4 by submitting theorems with sorry placeholders and running parallel LLM agents whose proposed edits are verified by the Lean compiler until a machine-checked proof is produced. Also provides Mathlib theorem search and job/attempt management tools.3MIT

narya-mcpofficial
AlicenseAqualityCmaintenanceEnables LLM agents to typecheck Narya files and develop proofs interactively by loading files into live sessions, inspecting and solving holes, searching for lemmas, and replaying edits.17Apache 2.0- AlicenseBqualityBmaintenanceEnables coding agents to drive HOL4's built-in hol lsp language server against individual SML script files, exposing proof diagnostics, goal states, evaluation, hover, definitions, symbols and completions as concise text tools. It manages server lifecycle, file syncing, proof-waiting, 1-based Unicode-aware positions, and detection of cheat usage.11BSD 3-Clause