Lean Lsp MCP
Lean Theorem Prover MCP
What is Lean Lsp MCP?
Lean Lsp MCP is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to lean theorem prover mcp
Lean Theorem Prover MCP
This server falls under the Coding Agents category on MCPgee, the world's largest MCP server directory with 33,000+ servers.
Features
- Lean Theorem Prover MCP
Use Cases
Maintainer
Works with
Installation
Manual Installation
npx lean-lspConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
How to Set Up and Use Lean Lsp MCP
The Lean LSP MCP server bridges AI coding assistants with the Lean 4 theorem prover through the Language Server Protocol, enabling real-time diagnostics, goal state inspection, and theorem search from within your AI client. It exposes tools like LeanSearch, Loogle, Lean Finder, and Lean Hammer so agents can locate relevant theorems and definitions, execute Lean code, and validate proofs without leaving the conversation. This is particularly valuable for mathematicians and formal verification engineers who want AI assistance drafting or checking Lean 4 proofs. The server supports REPL mode for fast iterative attempts and can run a local Loogle search index for offline use.
Prerequisites
- uv package manager installed (curl -LsSf https://astral.sh/uv/install.sh | sh)
- A Lean 4 project with a lean-toolchain file and lakefile.lean or lakefile.toml
- Run 'lake build' in your project before starting the server to avoid client timeouts
- ripgrep (rg) installed for local file search functionality (optional but recommended)
- An MCP-compatible client such as Claude Desktop, VS Code, Cursor, or Claude Code
Install uv package manager
The server is distributed via PyPI and run with uvx, so you need the uv tool installed first.
curl -LsSf https://astral.sh/uv/install.sh | shBuild your Lean project first
Run a full lake build before starting the MCP server. Lean's initial elaboration can be slow and will cause timeout errors if the server has to trigger it during a client request.
cd /path/to/your/lean/project && lake buildAdd the server to your MCP client
For Claude Code, add the server from the root of your Lean project directory. For other clients, use the JSON configuration in the next step.
claude mcp add lean-lsp uvx lean-lsp-mcpConfigure environment variables
Set LEAN_PROJECT_PATH to point to your project root, and optionally set LEAN_LOG_LEVEL and LEAN_MCP_DISABLED_TOOLS to control verbosity and which tools are active. LEAN_REPL=true enables a ~5x faster iterative mode if you add the repl dependency to lakefile.toml.
Enable REPL mode for faster iteration (optional)
Add the repl package to your lakefile.toml to unlock LEAN_REPL mode, which dramatically speeds up repeated line-level proof attempts.
require repl from git "https://github.com/leanprover-community/repl" @ "main"Install ripgrep for local search
ripgrep enables the local file search tool so the agent can search through your project's Lean source files by pattern.
brew install ripgrep # macOS
# or: apt install ripgrep # Debian/UbuntuLean Lsp MCP Examples
Client configuration
JSON configuration for Claude Desktop or VS Code MCP settings, pointing at the lean-lsp-mcp package with the project path and logging set.
{
"mcpServers": {
"lean-lsp": {
"command": "uvx",
"args": ["lean-lsp-mcp"],
"env": {
"LEAN_PROJECT_PATH": "/path/to/your/lean/project",
"LEAN_LOG_LEVEL": "NONE",
"LEAN_REPL": "true"
}
}
}
}Prompts to try
Example prompts you can send to your AI assistant once the server is connected to a Lean 4 project.
- "What are the current Lean diagnostics for the file Mathlib/Algebra/Group/Basic.lean?"
- "Search LeanSearch for theorems about natural number induction."
- "What is the goal state at line 42 of my current proof?"
- "Run this Lean snippet and show me the output: #check Nat.add_comm"
- "Use Loogle to find theorems with signature `Nat -> Nat -> Prop`"Troubleshooting Lean Lsp MCP
Client times out when the server starts
This almost always means lake build has not been run. Run 'lake build' in your project root first, then restart the MCP server. Initial Lean elaboration can take several minutes.
Tools like LeanSearch or Loogle return no results
These tools require internet access to reach external backends by default. Set LEAN_LOOGLE_LOCAL=true (Unix only, ~2GB disk, ~5-10 min initial build) if you need offline support, or check that the server process has outbound network access.
LEAN_PROJECT_PATH is not being picked up
Ensure the env key is set correctly in your client config JSON (not as a shell variable). The path must point to the directory containing lean-toolchain, not to a subdirectory or a .lean file.
Frequently Asked Questions about Lean Lsp MCP
What is Lean Lsp MCP?
Lean Lsp MCP is a Model Context Protocol (MCP) server that lean theorem prover mcp It connects AI assistants to external tools and data sources through a standardized interface.
How do I install Lean Lsp MCP?
Follow the installation instructions on the Lean Lsp MCP GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.
Which AI clients work with Lean Lsp MCP?
Lean Lsp MCP works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.
Is Lean Lsp MCP free to use?
Yes, Lean Lsp MCP is open source and available under the MIT license. You can use it freely in both personal and commercial projects.
Lean Lsp MCP Alternatives — Similar Coding Agents Servers
Looking for alternatives to Lean Lsp MCP? Here are other popular coding agents servers you can use with Claude, Cursor, and VS Code.
Dify
★ 142.2kProduction-ready platform for agentic workflow development.
Ruflo
★ 54.0k🌊 The leading agent orchestration platform for Claude. Deploy intelligent multi-agent swarms, coordinate autonomous workflows, and build conversational AI systems. Features enterprise-grade architecture, self-learning swarm intelligence, RAG integrat
Goose
★ 45.7kan open source, extensible AI agent that goes beyond code suggestions - install, execute, edit, and test with any LLM
Antigravity Awesome Skills
★ 38.3kInstallable GitHub library of 1,400+ agentic skills for Claude Code, Cursor, Codex CLI, Gemini CLI, Antigravity, and more. Includes installer CLI, bundles, workflows, and official/community skill collections.
AgentScope
★ 25.5kBuild and run agents you can see, understand and trust.
Serena
★ 24.5kA coding agent toolkit that provides IDE-like semantic code retrieval and editing tools, enabling LLMs to efficiently navigate and modify codebases using symbol-level operations instead of basic file reading and string replacements.
Browse More Coding Agents MCP Servers
Explore all coding agents servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.
Set Up Lean Lsp MCP in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
Ready to use Lean Lsp MCP?
Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.