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_infoA | 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_state_searchB | Limit: 6req/30s. Find lemmas to close the goal at a position. Searches premise-search.com. |
| lean_hammer_premiseA | Limit: 6req/30s. Get premise suggestions for automation tactics at a goal position. |
| lean_multi_attemptA | Try multiple tactics without modifying file. Returns goal state for each. |
| lean_run_codeA | 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 23 tools
The LSP-oriented tools (goal, term_goal, hover, diagnostics, code_actions) are clearly separated, but there is a dense cluster of five Mathlib/lemma-search tools (loogle, leansearch, leanfinder, local_search, state_search) plus hammer_premise that overlap in purpose and could easily be misselected. Descriptions help, but the boundaries among 'search by signature', 'search by meaning', and 'find lemmas for goal' are subtle.
All tools share a consistent lean_ snake_case prefix and mostly use noun phrases describing the returned information. However, a few action-style names (lean_build, lean_run_code, lean_get_widgets) and service/product names (lean_loogle, lean_leansearch) break the pure resource-noun pattern.
At 23 tools the count sits in the heavy range for an MCP server, even though each tool maps to a real Lean/LSP feature. Several search and goal-analysis tools could plausibly be consolidated, so the set feels somewhat over-scoped rather than tightly curated.
The surface covers a broad Lean proof-development workflow: diagnostics, goals, hover docs, completions, code actions, library search, execution, verification, profiling, and widgets. Minor gaps exist, such as no way to apply the resolved code-action edits or perform workspace-wide symbol search, but most workflows do not dead-end.