Skip to main content
Glama

Lean plugin

Run Lean file diagnostics and verify a Lake package through MCP stdio. The npm package provides the MCP adapter. It does not ship or download Lean, Mathlib, or project dependencies.

Configure the server

  1. On Linux, install Bubblewrap at /usr/bin/bwrap and provision the official Lean 4.36.0 Linux release. Use the unpacked release directory, not an elan shim.

  2. Prepare one approved Lake workspace and its manifest before allowing the adapter to run. Keep tokens, environment files, sockets, and unrelated source out of this workspace.

  3. Install the package with Node.js 24 or later. Configure your MCP client to start the installed lean-plugin executable with the following environment variables:

    • LEAN_PLUGIN_PROJECT: Absolute path to the approved Lake workspace root.

    • LEAN_PLUGIN_TOOLCHAIN: Absolute path to the unpacked Lean Linux release.

Lean core and Std are the verified default. Mathlib support through the offline MCP is unverified. The server runs Lake without network access and excludes .git metadata from its workspace copy. A prepopulated .lake/packages directory or build cache alone leaves dependency resolution unverified.

The lake check phase defaults to 240 seconds. To increase it, set LEAN_PLUGIN_LAKE_CHECK_TIMEOUT_SECONDS in the server's startup environment to whole seconds from 240 to 600. An invalid setting prevents the server from starting. This setting does not change diagnostics or sandbox probe limits. Configure the MCP client to wait longer than the selected limit plus 25 seconds for the sandbox probes. A server-side timeout returns unavailable.

For local editing, use elan and the official Lean 4 extension for VS Code. The server reports verification as unavailable when Linux isolation or the exact toolchain is missing; it does not run Lean directly as a fallback.

Related MCP server: mcp-bridge

Tools

  • lean_diagnostics: Pass a project-relative .lean path as file. Get Lake elaboration diagnostics, not a proof certificate.

  • lean_verify: Pass an empty object. Get Lake's kernel replay and standard-axiom check for the default targets.

Both tools return status and output. A failed result means Lean or Lake ran and rejected the input. An unavailable result is not a proof failure and must not count as a pass. An invalid_input result means the requested file is not eligible for diagnostics.

Use the Lean skill already available in your agent environment for guidance on when to use each check and how to relate a proof to implementation behavior.

Available Tools

2 tools
lean_diagnosticsC

Elaborate a project-relative Lean source file in the approved Lake workspace.

Inputs: file (required).

lean_verifyB

Run sandboxed Lake proof verification on the approved package's default targets.

Inputs: no named parameters.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.1/5.0

    Scored across 2 tools

    Disambiguation5/5

    The two tools have clearly distinct purposes: lean_diagnostics elaborates a specific source file, while lean_verify runs package-level proof verification. An agent can easily choose between them based on whether it needs file diagnostics or target verification.

    Naming Consistency4/5

    Both tools use the same lean_ prefix and snake_case style, which is predictable. The only minor inconsistency is grammatical form: diagnostics is a noun while verify is a verb, but the pattern remains readable.

    Tool Count3/5

    Two tools is thin for a Lean plugin, even a narrowly scoped one. It covers the two core operations but leaves little room for related workflows, making the count borderline.

    Completeness3/5

    The surface covers file elaboration and package verification, but notable gaps remain: no build/clean, no listing or reading files, and no way to verify a specific non-default target. Agents may be able to work around some of these, but the lifecycle is incomplete.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables MCP clients to perform sandboxed file reads, writes, and listing, inspect credential-masked environment variables, check git status, and execute commands with strict timeouts over a clean stdio JSON-RPC channel.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI coding agents to query locally installed language servers over stdio MCP for read-only code intelligence, including definitions, references, implementations, hover types, symbols, and diagnostics.
      9 npm
      1
      Apache 2.0
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables MCP clients such as Claude Code, Codex and Cursor to check and verify Lean 4 proofs, inspect goals at a position, try tactics, list holes, and extract declarations against hosted Lean releases with pinned libraries. Edits are checked on warm remote workers that reuse Lean's work between calls, so agents can iterate on proofs against their intended statements.
      289 PyPI
      7
      MIT