oOo0oOo/lean-lsp-mcp

Lean Theorem Prover MCP

What it solves

This project provides a bridge between LLM agents and the Lean theorem prover. It allows AI agents to interact with Lean projects programmatically, enabling them to analyze code, check proof states, and search for relevant mathematical theorems and definitions without requiring a human to manually copy-paste information between the prover and the LLM.

How it works

It implements a Model Context Protocol (MCP) server that communicates with Lean via the Language Server Protocol (LSP) using the leanclient library. The server exposes a set of tools that an MCP-compatible agent (like Claude Code, Cursor, or VSCode) can call to:

  • Inspect Lean Projects: Access diagnostics, goal states, term information, and hover documentation.
  • Search for Theorems: Use external search tools like Loogle, Lean Search, and Lean Hammer to find existing proofs and definitions.
  • Run Code: Execute Lean code snippets, with an optional fast REPL mode for quicker iterations.
  • Manage Files: Read and write to Lean files within the project scope.

Who it’s for

It is designed for researchers and developers building agentic reasoning systems for formal mathematics, autoformalization, and automated theorem proving.

Highlights

  • Broad Toolset: Includes tools for goal state inspection, local source scanning (via ripgrep), and multiple remote/local search backends.
  • LSP Integration: Leverages the existing Lean Language Server for deep project analysis.
  • Flexible Deployment: Supports multiple transport methods including stdio, HTTP streaming, and SSE, and can be run in a Docker container for better isolation.
  • Local Loogle Support: Allows running a local instance of the Loogle search engine to bypass remote API rate limits.

Related

  • Project
  • Project
  • Project
  • Project
  • Project