Lean LSP MCP
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| LEAN_LOG_LEVEL | No | Log level for the server. Options are "INFO", "WARNING", "ERROR", "NONE". | INFO |
| LEAN_HAMMER_URL | No | URL for a self-hosted Lean Hammer Premise Search instance. | http://leanpremise.net |
| LEAN_LOOGLE_LOCAL | No | Set to true, 1, or yes to enable local loogle. | |
| LEAN_PROJECT_PATH | No | Path to your Lean project root. Set this if the server cannot automatically detect your project. | |
| LEAN_LSP_MCP_TOKEN | No | Secret token for bearer authentication when using streamable-http or sse transport. | |
| LEAN_LOOGLE_CACHE_DIR | No | Override the cache directory for local loogle. | ~/.cache/lean-lsp-mcp/loogle |
| LEAN_STATE_SEARCH_URL | No | URL for a self-hosted premise-search.com instance. | https://premise-search.com |
Instructions
Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.
This server publishes no instructions, or was last inspected before Glama recorded them.
Capabilities
Features and capabilities supported by this server
Protocol revision2025-11-25
| Capability | Details |
|---|---|
| tools | {
"listChanged": false
} |
| prompts | {
"listChanged": false
} |
| resources | {
"subscribe": false,
"listChanged": false
} |
| experimental | {} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| lean_buildA | Build the Lean project and restart LSP. Use only if needed (e.g. new imports). |
| lean_file_outlineA | Get imports and declarations with type signatures. Token-efficient. |
| lean_diagnostic_messagesB | Get compiler diagnostics (errors, warnings, infos) for a Lean file. |
| lean_code_actionsA | Get LSP code actions for a line. Returns resolved edits for TryThis suggestions (simp?, exact?, apply?) and other quick fixes. |
| lean_goalA | Get proof goals at a position. MOST IMPORTANT tool - use often! |
| lean_term_goalB | Get the expected type at a position. |
| lean_hover_infoB | Get type signature and docs for a symbol. Essential for understanding APIs. |
| lean_completionsA | Get IDE autocompletions. Use on INCOMPLETE code (after |
| lean_declaration_fileA | Get the source of a symbol's declaration (declaration slice + context). |
| lean_referencesA | Find all references to a symbol (including the declaration). Position cursor at the symbol. |
| lean_local_searchA | Fast local search to verify declarations exist. Use BEFORE trying a lemma name. |
| lean_leansearchA | Limit: 90req/30s. Search Mathlib via leansearch.net using natural language. |
| lean_loogleA | Search Mathlib by type signature via loogle.lean-lang.org. |
| lean_leanfinderA | Limit: 10req/30s. Semantic search by mathematical meaning via Lean Finder. |
| lean_hammer_premiseA | Limit: 6req/30s. Get premise suggestions for automation tactics at a goal position. |
| lean_multi_attemptB | Try multiple tactics without modifying file. Returns goal state for each. |
| lean_run_codeB | Run a code snippet and return diagnostics. Must include all imports. |
| lean_verifyA | Check theorem axioms + optional source scan. Only scans the given file, not imports. |
| lean_minimal_hypothesesA | For each explicit |
| lean_profile_proofA | Run |
| lean_get_widgetsA | Get panel widgets at a position (proof visualizations, #html, custom widgets). Returns raw widget data - may be large. |
| lean_get_widget_sourceA | Get JavaScript source of a widget by hash. Useful for understanding custom widget rendering logic. Returns full JS module - may be large. |
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
No prompts | |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
No resources | |
TDQS
Scored across 22 tools
Most tools target distinct LSP operations (goals, hover, diagnostics, references, completions, widgets, build), and descriptions clarify their scope. However, there is a cluster of search tools (lean_loogle, lean_leanfinder, lean_leansearch, lean_local_search, lean_hammer_premise), and the two natural-language search tools lean_leanfinder and lean_leansearch are genuinely easy to confuse.
Every tool follows the same lean_ prefix with snake_case verb/noun naming (lean_build, lean_hover_info, lean_file_outline, lean_get_widgets). The convention is uniform throughout with no deviations.
22 tools is on the heavy side, but the Lean LSP domain legitimately encompasses many distinct operations (search, diagnostics, goals, widgets, profiling, verification). Each tool maps to a real capability, though the multiple search variants push it past ideal scope.
The surface covers the core Lean development lifecycle: build, diagnostics, hover, goals, term goals, search, references, completions, code actions, run code, and widgets. Minor gaps exist (e.g. no rename/format operations), but agents can work around these for most workflows.