lean-lsp-mcp

lean-lsp-mcp

Interact with the Lean theorem prover via the Language Server Protocol.

174
Stars
20
Forks
14
Releases

Overview

Lean-lsp-mcp is an MCP server that enables agentic interaction with the Lean theorem prover through the Language Server Protocol using leanclient. It provides a broad toolkit for LLM agents to understand, analyze, and interact with Lean projects. The server exposes rich Lean tooling, including diagnostics, proof goals, term information, and hover documentation, within an LSP-based interface. It also integrates external search tools such as LeanSearch, Loogle, Lean Finder, Lean Hammer, and Lean State Search to locate relevant theorems and definitions. A local search option, lean_local_search (requiring ripgrep), helps agents verify declarations inside the project. A suite of MCP tools supports file outline, diagnostic messages, goals, term goals, hover information, symbol declarations, code completions, and on-demand code execution, plus multi-attempt evaluation to compare proof candidates. The project ships with out-of-the-box setup guidance and configurable environments for editors like VSCode, Cursor, and Claude Code. It supports multiple transports (stdio, streamable-http, sse) and optional bearer authentication via LEAN_LSP_MCP_TOKEN. Optional environment variables tailor project paths, logging, and access control.

Details

Owner
oOo0oOo
Language
Python
License
MIT License
Updated
2025-12-07

Features

Rich Lean Interaction

Access diagnostics, goal states, term information, hover documentation and more for Lean projects.

External Search Tools Integration

Leverages LeanSearch, Loogle, Lean Finder, Lean Hammer and Lean State Search to locate theorems and definitions.

Local Search Tools

Supports lean_local_search (requires ripgrep) to search within the local Lean project.

File & Code Introspection Tools

Provides file outline, diagnostics, declaration contents, completions, run_code and multi_attempt for Lean code.

Project Build & Tooling

Includes lean_build to rebuild the Lean project and restart the Lean LSP server.

Transport & Authentication

Supports stdio, streamable-http and sse transports; optional bearer token authentication.

Out-of-the-box Config & Env

Works with default config and provides environment variables examples with cross-editor setup.

Audience

LLM AgentsInteracting with Lean projects through MCP-enabled LSP for reasoning and exploration.
Lean DevelopersUsing MCP to inspect diagnostics, goals, hover info, and definitions during development.
Editor IntegratorsConfigure editors (VSCode, Cursor, Claude Code) to access Lean tooling via MCP.
ResearchersExperiment with agentic theorem proving and AI-assisted Lean analysis workflows.
AI/ML EngineersPrototype agents that query Lean, retrieve diagnostics, and locate relevant theorems.

Tags

LeanMCPLSPleanclientLean4Theorem ProverAI AgentsExternal Search ToolsLocal Search ToolsEditor Integration