Skip to main content

lean-lsp-mcp

Lean Theorem Prover MCP

PyPI version last update license

MCP that allows agentic interaction with the Lean theorem prover via the Language Server Protocol using leanclient.

Currently beta testing: Please help us by submitting bug reports, feedback and feature requests.

Setup

  1. Install uv, a Python package manager.
  2. Add JSON configuration to your IDE/Setup.
  3. Configure env variable LEAN_PROJECT_PATH.

Install uv

Install uv for your system.

E.g. on Linux/MacOS:

curl -LsSf https://astral.sh/uv/install.sh | sh

VSCode Insiders

VSCode Insiders (bleeding edge version of VSCode) has introduced agent mode in February 2025. This feature will eventually be released in the stable version of VSCode.

  1. One-click config setup:

Install in VS Code Insiders

OR manually add config to settings.json (global):

{
    "mcp": {
        "servers": {
            "lean-lsp": {
                "command": ["uvx"],
                "args": ["lean-lsp-mcp"],
                "env": {
                    "LEAN_PROJECT_PATH": "/path/to/lean/project"
                }
            }
        }
    }
}
  1. Next change the env variable LEAN_PROJECT_PATH to point to the root of your Lean project. This is required for the MCP to work. You can also remove this from the config and set this env variable differently.

  2. Click "Start" above server config, open a Lean file, change to agent mode in the chat and run e.g. "auto proof" to get started:

VS Code Agent Mode

Cursor

  1. Open MCP Settings (File > Preferences > Cursor Settings > MCP)

  2. "+ Add a new global MCP Server" > ("Create File")

  3. Paste the server config into mcp.json file and adjust the LEAN_PROJECT_PATH to point to the root of your Lean project:

{
    "mcpServers": {
        "lean-lsp": {
            "command": "uvx",
            "args": ["lean-lsp-mcp"],
            "env": {
                "LEAN_PROJECT_PATH": "/path/to/lean/project"
            }
        }
    }
}
  1. Open a Lean file and run e.g. "auto proof" in a new chat.

Other Setups

Other setups, such as Claude Desktop, Claude Code or OpenAI Agent SDK should work with similar configs (untested).

Tools

Lean LSP MCP currently provides various tools to interact with the Lean LSP server:

Meta tools

  • lean_auto_proof_instructions: Get detailed instructions on how to use the Lean LSP MCP to automatically prove theorems. This is a tool call because many clients do not support prompts yet.

Core interactions

  • lean_diagnostic_messages: Get all diagnostic messages for a Lean file. This includes infos, warnings and errors.

  • lean_goal: Get the proof goal at a specific location in a Lean file.

  • lean_term_goal: Get the term goal at a specific position.

  • lean_hover_info: Retrieve hover information for symbols, terms, and expressions in a Lean file.

  • lean_proofs_complete: Check if all proofs in a file are complete.

File operations

  • lean_file_contents: Get the contents of a Lean file, optionally with line number annotations.

Project-level tools

  • lean_project_path: Get the path to the current Lean project root directory.

  • lean_project_functional: Check if the Lean project and LSP server are functional and responding properly.

  • lean_lsp_restart: Restart the LSP server and optionally rebuild the Lean project.

  • LeanTool: Provides an MCP "code interpreter" for Lean.

License & Citation

MIT licensed. See LICENSE for more information.

Citing this repository is highly appreciated but not required by the license.

@software{lean-lsp-mcp,
  author = {Oliver Dressler},
  title = {{Lean LSP MCP: Tools for agentic interaction with the Lean theorem prover}},
  url = {https://github.com/oOo0oOo/lean-lsp-mcp},
  month = {3},
  year = {2025}
}

Metadata

Release files for lean-lsp-mcp 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lean-lsp-mcp 0.1.3
File Size Uploaded Provenance Actions
lean_lsp_mcp-0.1.3.tar.gz 10.6 kB Without provenance Details for lean_lsp_mcp-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lean-lsp-mcp 0.1.3
File Interpreter ABI Platform Actions
lean_lsp_mcp-0.1.3-py3-none-any.whl Python 3 none any Details for lean_lsp_mcp-0.1.3-py3-none-any.whl

Total release size: 20.0 kB

Release files / lean_lsp_mcp-0.1.3.tar.gz

Download URL lean_lsp_mcp-0.1.3.tar.gz
Size 10.6 kB
Tags Source
SHA-256 checksum
How to use checksums
284a97745fee26bb28c18bb1036da4df844b471a3391432904440d7a17ea577e
BLAKE2b-256 checksum
How to use checksums
aa4e24dca73bcde1dd9d1d22803d5a07a95671a141a1cab2a437700c58307267
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.10

Release files / lean_lsp_mcp-0.1.3-py3-none-any.whl

Download URL lean_lsp_mcp-0.1.3-py3-none-any.whl
Size 9.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
beb9f08cbdeadb4730f64303742fd64937ce73eef9102c096d4b0f3c4bf61e42
BLAKE2b-256 checksum
How to use checksums
2498f43caa9d752deddf4d795b2ed60463f44fb7caffea85c9216d70b27a78b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.10

Security for lean-lsp-mcp 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page