← Back to directory
L

Lean Theorem Prover MCP

Community
Interact with Lean through the Language Server Protocol.
Category
Dev Tools #108 of 751
Stars
★ 575 Very popular
Transport
stdio (local process) · Streamable HTTP · SSE
Runtime
Python
Credentials
No credential needed
License
MIT
Last commit
59FMRS · C

The README describes the main interaction features, client configuration, transports, and optional settings, and calls out risks from local file access, code execution, and external search. The full tool list is linked in the README, but the supplied material does not include specific tool identifiers.

Strongest · Documentation 15/20 Weakest · Reliability 10/20

Reliability
10/20
Security and permissions
10/20
Maintenance
10/20
Documentation
15/20
Setup experience
14/20
Why each score
Reliability 10/20
The README describes stdio, streamable HTTP and SSE, tool configuration, dependencies, and expected error handling, and gives a test command. It provides no CI workflow or evidence of key-path test coverage; this static review cannot verify initialization, tool listing, or actual behavior. The static calibration caps the score at 12, and the lack of reproducible evidence warrants further deductions.
Security and permissions 10/20
The README discloses local filesystem access, I/O side effects from Lean build and analysis code, and network access for remote search. It also describes project-path boundaries, symlink protection, and HTTP bearer tokens. No source code is available to verify these controls, and permissions and confirmation for code-execution tools are not established. The supplied evidence does not support a red-line finding.
Maintenance 10/20
The supplied metadata says the project is not archived, is MIT licensed, and has 6 open issues. The README also points to PyPI installation and project maintenance entry points. There is no evidence here of commit or release cadence, issue response, dependency updates, or a security response process, so a midrange score is appropriate.
Documentation 15/20
The README covers multiple client configurations, transports, environment variables, authentication, path policy, REPL and local-search requirements, and security and resource limitations. Full tool parameters depend on external documentation not supplied here; troubleshooting, compatibility, and cost information are also incomplete, and README claims cannot be verified against source.
Setup experience 14/20
The README provides uvx and Nix installation paths plus configuration examples for VS Code, Cursor, Claude Code, and Mistral Vibe, and explains Lean project and optional dependency requirements. Users must separately install and build a Lean project, while some features require ripgrep, REPL, or substantial memory. With no source or execution evidence, the static calibration caps this score at 15.

Static review · not runReviewed 2026-11-29

Read the FMRS scoring method →

Fit and risk

What it can accessReads local filesWrites / deletes local filesRuns commands or codeUses the network

Best for

  • Developers and researchers working with Lean 4 and Lake projects.
  • Users who want an MCP client to inspect proof states, diagnostics, and Lean project contents.

Not for

  • Users who do not work with Lean projects or theorem-proving workflows.
  • Users who expect the server to provide the Lean toolchain; the project still needs a Lean toolchain.
  • Workflows that require tool calls to be strictly read-only or free of side effects.

Required permissions

  • Needs access to files in the active Lean project, resolved .lake/packages dependencies, and Lean standard-library source tree.
  • Build and analysis tools execute project or supplied Lean code, which may have I/O effects.
  • Remote search tools may access the external network; operators can disable the relevant tools.

Risks and side effects

  • The README describes the server as a research tool and says it is in beta.
  • Local file access, build and code-analysis capabilities, and network access for remote search present security risks.
  • The initial local Loogle Mathlib index can use substantial memory; the README reports a measured peak of about 13 GiB.

Setup

Before you start

Runtime:Python

LEAN_LSP_MCP_TOKEN optionalsecret Bearer authentication secret for streamable-http or sse; provide a secret of your own.
Other optional settings (20)
LEAN_LOG_LEVEL optional Sets the server log level; choose INFO, WARNING, ERROR, or NONE.
LEAN_LOG_FILE_CONFIG optional Sets the path to a logging configuration file.
LEAN_PROJECT_PATH optional Sets the Lean project root; required for streamable-http and sse, and must contain lean-toolchain plus lakefile.lean or lakefile.toml.
LEAN_MCP_DISABLED_TOOLS optional Comma-separated tool names to remove from the MCP tool listing.
LEAN_MCP_INSTRUCTIONS optional Replaces the server instructions string.
LEAN_MCP_TOOL_DESCRIPTIONS optional JSON object for overriding tool descriptions.
LEAN_MCP_SCRATCH_SLOTS optional Sets the number of parallel scratch documents; defaults to 1.
LEAN_MCP_MAX_OUTPUT_CHARS optional Sets the per-field character budget for goal states and diagnostics; defaults to 6000, or 0 for no truncation.
LEAN_REPL optional Set to true, 1, or yes to enable REPL-based fast code runs and multi-attempts.
LEAN_REPL_PATH optional Sets the REPL binary path; auto-detected if unset.
LEAN_REPL_TIMEOUT optional Sets the timeout per REPL command in seconds; defaults to 60.
LEAN_REPL_MEM_MB optional Sets the memory budget per REPL in MiB; defaults to 16384.
LEAN_BUILD_CONCURRENCY optional Sets lean_build concurrency mode: allow, cancel, or share; defaults to allow.
LEAN_HAMMER_URL optional Sets the URL of a self-hosted Lean Hammer Premise Search instance.
LEAN_LOOGLE_LOCAL optional Set to true, 1, or yes to enable local Loogle.
LEAN_LOOGLE_MODULE optional Sets the root module for local Loogle searches; defaults to Mathlib.
LEAN_LOOGLE_LOCAL_ONLY optional Set to true, 1, or yes to disable remote Loogle fallback when local search is unavailable.
LEAN_LOOGLE_CACHE_DIR optional Sets the local Loogle cache directory; defaults to ~/.cache/lean-lsp-mcp/loogle.
LOOGLE_URL optional Sets the Loogle instance URL; defaults to https://loogle.lean-lang.org.
LOOGLE_HEADERS optional Sets extra Loogle request headers as a JSON object.

Install uv, then run lake build manually in the Lean project to reduce startup delays. A client can launch the server over stdio with uvx lean-lsp-mcp; the README provides configuration examples for VS Code, Cursor, Claude Code, and Mistral Vibe. By default, the server attempts to run lake serve in the project root. ripgrep is optional and is used by the local search tool.

.cursor/mcp.json
{"mcpServers":{"lean-lsp":{"command":"uvx","args":["lean-lsp-mcp"]}}}

Shown for Cursor. Other clients may use a different file or key (VS Code uses "servers") — the configurator below converts it.

.vscode/mcp.json
{
  "servers": {
    "lean-lsp": {
      "command": "uvx",
      "args": [
        "lean-lsp-mcp"
      ]
    }
  }
}

Goes in your project's .vscode/mcp.json (VS Code uses a "servers" key).

~/.codex/config.toml
[mcp_servers.lean-lsp]
command = "uvx"
args = ["lean-lsp-mcp"]

Append to ~/.codex/config.toml (OpenAI Codex CLI uses TOML).

Terminal
claude mcp add lean-lsp -- uvx lean-lsp-mcp

Run it in a terminal; replace any <…> placeholders with your own values first.

Check that it works

Confirm that Lean tools appear in your client's MCP tool list. Then ask to inspect the current proof goals; the server should return the Lean project's goal state.

Troubleshooting

  1. For slow startup or client timeouts, run lake build in the project root first.
  2. Check that the project root contains lean-toolchain and either lakefile.lean or lakefile.toml.
  3. Confirm uvx, the Lean toolchain, and lake are available; local search requires ripgrep on PATH.
  4. streamable-http and sse require LEAN_PROJECT_PATH at startup; check that the client and server are configured for the same transport.

Things to try

Once connected, you can ask your AI assistant things like:

  • Check the current Lean file for errors and explain the diagnostics.
  • Show me the current proof goals and local context.
  • Search for Lean theorems related to commutativity of natural number addition.

Use cases

Inspect diagnostics, proof goal states, term information, and hover documentation in Lean files.
Search Lean projects for relevant theorems and definitions.
Use an agent to assist with Lean code analysis and interactive theorem proving.

Supported clients

VS Code
Cursor
Claude Code
Mistral Vibe

Listed from the project's documentation, not tested by this site.

Overview

Lean Theorem Prover MCP is an MCP server that uses the Language Server Protocol and leanclient to help agents understand, analyze, and interact with Lean projects. It provides access to diagnostics, goal states, term information, and hover documentation, and can use LeanSearch, Loogle, Lean Finder, and Lean Hammer to search for theorems and definitions.

Similar servers

Source revision 7932203d79db Data synced 2026-12-05 Read the FMRS scoring method Markdown

Maintainer badge: embed FMRS score

Paste this Markdown into your repository README to display a live score badge:

README.md
[![FollowMCP](https://followmcp.com/badges/lean-lsp-mcp.svg)](https://followmcp.com/en/servers/lean-lsp-mcp)