
AI Agent for Lean LSP MCP
Integrate agentic interaction with the Lean Theorem Prover using the Lean LSP MCP server. Unlock advanced Lean diagnostics, auto proofing, code completions, and theorem search with seamless Language Server Protocol (LSP) connectivity for VSCode, Cursor, Claude Code, and more. Empower LLM agents to analyze and automate Lean mathematical proofs efficiently.

Automated Proof Analysis & Code Insights
Leverage rich Lean file interactions through the MCP server. Instantly access diagnostics, proof goals, term information, hover documentation, and code auto-completions directly in your IDE or with agentic workflows. Simplify Lean project management and boost proof development speed.
- Lean File Diagnostics.
- Receive comprehensive Lean file error, warning, and info messages to debug and refine proofs with precision.
- Proof Goal Extraction.
- Extract proof goals at any location—enabling stepwise automation and verification in Lean projects.
- Code Hover & Documentation.
- Instantly retrieve hover information for terms and symbols, boosting learning and productivity.
- Code Completion Support.
- Find available identifiers and auto-completion suggestions to accelerate Lean code writing.

Integrated Search & Discovery Tools
Tap into next-level theorem and definition discovery with integrated tools like leansearch, loogle, lean_hammer, and lean_state_search. Enable LLM agents and users to quickly locate relevant proofs, definitions, and mathematical resources—making Lean more accessible than ever.
- Theorem & Definition Search.
- Locate relevant theorems and definitions efficiently using external tools like leansearch and loogle.
- Automated Proof Assistance.
- Harness lean_hammer and lean_state_search for advanced proof strategies and premise selection.
- Easy Tool Integration.
- Configure external search and proof tools for seamless access via environment variables.

Flexible Setup & Secure Connectivity
Deploy Lean LSP MCP in VSCode, Cursor, Claude Code, or other LSP-compatible clients with simple configuration. Choose from multiple transport methods, including stdio and HTTP streaming, and secure your server with bearer token authentication and fine-grained environment variable control.
- Multi-Client Support.
- Seamlessly connect with VSCode, Cursor, Claude Code, and other LSP-compatible tools for flexible workflows.
- Bearer Token Authentication.
- Restrict server access with secure bearer token authentication for HTTP/SSE transports.
- Environment Variable Config.
- Customize integrations and access with project path, search URL, and advanced settings.
MCP INTEGRATION
Available Lean LSP MCP Integration Tools
The following tools are available as part of the Lean LSP MCP integration:
- lean_file_contents
Get the contents of a Lean file, optionally including line number annotations.
- lean_diagnostic_messages
Retrieve all diagnostic messages (infos, warnings, errors) for a Lean file.
- lean_goal
Get the proof goal at a specified location in a Lean file to understand the current proof state.
- lean_term_goal
Retrieve the term goal at a specific position (line and column) in a Lean file.
- lean_hover_info
Get hover information or documentation for symbols and terms at a given position in a Lean file.
- lean_declaration_file
Obtain the file contents where a specific symbol or term is declared.
- lean_completions
Find available code completions or import suggestions at a specified position in a Lean file.
- lean_run_code
Run or compile an independent Lean code snippet or file and return the output or error.
- lean_multi_attempt
Attempt multiple Lean code snippets and return the goal state and diagnostics for each.
Supercharge Lean Projects with Agentic LLM Tools
Unlock powerful, automated interaction with Lean theorem proving in your IDE or agent platform. Diagnose, search, and solve proofs with easy setup and advanced integrations—perfect for research, education, and AI workflows.
What is LeanMCP
LeanMCP is a developer-friendly, scalable, and reliable hosting platform designed specifically for Machine Comprehension Processes (MCPs). The platform provides a lightweight, serverless environment that enables users to host, deploy, and interact with MCPs efficiently. LeanMCP specifically supports agentic interaction with the Lean theorem prover via the Language Server Protocol (LSP), allowing AI agents and users to analyze, understand, and manipulate Lean projects programmatically. With built-in support for advanced search tools like leansearch, loogle, lean_hammer, and lean_state_search, LeanMCP streamlines the process of theorem proving and automated reasoning, offering a robust toolkit for developers and AI researchers working with formal verification and mathematical proofs.
Capabilities
What we can do with LeanMCP
LeanMCP allows users to leverage a rich set of features for interacting with Lean theorem prover projects. You can access deep diagnostic information, hover documentation, and goal states, as well as use external tools for searching and proving theorems. The platform supports easy integration with various IDEs and is optimized for use by both developers and AI agents.
- Rich Lean Interaction
- Access diagnostics, goal states, term information, and hover documentation from Lean projects.
- Advanced Theorem Search
- Utilize tools like leansearch, loogle, lean_hammer, and lean_state_search to find relevant theorems and definitions.
- Agentic Automation
- Enable LLM agents to analyze, understand, and interact with Lean code automatically.
- Easy Integration
- Simple setup for various clients including VSCode, Cursor, and Claude Code.
- Serverless Hosting
- Deploy and manage MCPs in a scalable, serverless environment without manual server management.

What is LeanMCP
AI agents can greatly benefit from LeanMCP by programmatically accessing the Lean theorem prover's capabilities. This enables automation in formal verification, theorem proving, and mathematical reasoning. Agents can use LeanMCP to suggest proof steps, analyze code, and deliver more robust formal mathematics solutions, fostering research and development in AI-driven mathematics and verification.