iflow-mcp_ooo0ooo-lean-lsp-mcp
v0.20.0Lean Theorem Prover MCP
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
lean_build
Build the Lean project and restart LSP. Use only if needed (e.g. new imports).
| Parameter | Type | Description |
|---|---|---|
clean | boolean | Run lake clean first (slow) |
lean_project_path | Path to Lean project | |
output_lines | integer | Return last N lines of build log (0=none) |
lean_file_contents
DEPRECATED: Will be removed soon. DEPRECATED. Get file contents with optional line numbers.
| Parameter | Type | Description |
|---|---|---|
file_path * | string | Absolute path to Lean file |
annotate_lines | boolean | Add line numbers |
lean_file_outline
Get imports and declarations with type signatures. Token-efficient.
| Parameter | Type | Description |
|---|---|---|
file_path * | string | Absolute path to Lean file |
lean_diagnostic_messages
Get compiler diagnostics (errors, warnings, infos) for a Lean file.
| Parameter | Type | Description |
|---|---|---|
file_path * | string | Absolute path to Lean file |
declaration_name | Filter to declaration (slow) | |
end_line | Filter to line | |
start_line | Filter from line |
lean_goal
Get proof goals at a position. MOST IMPORTANT tool - use often! Omit column to see goals_before (line start) and goals_after (line end), showing how the tactic transforms the state. "no goals" = proof complete.
| Parameter | Type | Description |
|---|---|---|
file_path * | string | Absolute path to Lean file |
line * | integer | Line number (1-indexed) |
column | Column (1-indexed). Omit for before/after |
lean_term_goal
Get the expected type at a position.
| Parameter | Type | Description |
|---|---|---|
file_path * | string | Absolute path to Lean file |
line * | integer | Line number (1-indexed) |
column | Column (defaults to end of line) |
lean_hover_info
Get type signature and docs for a symbol. Essential for understanding APIs.
| Parameter | Type | Description |
|---|---|---|
column * | integer | Column at START of identifier |
file_path * | string | Absolute path to Lean file |
line * | integer | Line number (1-indexed) |
lean_completions
Get IDE autocompletions. Use on INCOMPLETE code (after `.` or partial name).
| Parameter | Type | Description |
|---|---|---|
column * | integer | Column number (1-indexed) |
file_path * | string | Absolute path to Lean file |
line * | integer | Line number (1-indexed) |
max_completions | integer | Max completions |
lean_declaration_file
Get file where a symbol is declared. Symbol must be present in file first.
| Parameter | Type | Description |
|---|---|---|
file_path * | string | Absolute path to Lean file |
symbol * | string | Symbol (case sensitive, must be in file) |
lean_multi_attempt
Try multiple tactics without modifying file. Returns goal state for each.
| Parameter | Type | Description |
|---|---|---|
file_path * | string | Absolute path to Lean file |
line * | integer | Line number (1-indexed) |
snippets * | array | Tactics to try (3+ recommended) |
lean_run_code
Run a code snippet and return diagnostics. Must include all imports.
| Parameter | Type | Description |
|---|---|---|
code * | string | Self-contained Lean code with imports |
lean_local_search
Fast local search to verify declarations exist. Use BEFORE trying a lemma name.
| Parameter | Type | Description |
|---|---|---|
query * | string | Declaration name or prefix |
limit | integer | Max matches |
project_root | Project root (inferred if omitted) |
lean_leansearch
Limit: 3req/30s. Search Mathlib via leansearch.net using natural language. Examples: "sum of two even numbers is even", "Cauchy-Schwarz inequality", "{f : A → B} (hf : Injective f) : ∃ g, LeftInverse g f"
| Parameter | Type | Description |
|---|---|---|
query * | string | Natural language or Lean term query |
num_results | integer | Max results |
lean_loogle
Search Mathlib by type signature via loogle.lean-lang.org. Examples: `Real.sin`, `"comm"`, `(?a → ?b) → List ?a → List ?b`, `_ * (_ ^ _)`, `|- _ < _ → _ + 1 < _ + 1`
| Parameter | Type | Description |
|---|---|---|
query * | string | Type pattern, constant, or name substring |
num_results | integer | Max results |
lean_leanfinder
Limit: 10req/30s. Semantic search by mathematical meaning via Lean Finder. Examples: "commutativity of addition on natural numbers", "I have h : n < m and need n + 1 < m + 1", proof state text.
| Parameter | Type | Description |
|---|---|---|
query * | string | Mathematical concept or proof state |
num_results | integer | Max results |
lean_state_search
Limit: 3req/30s. Find lemmas to close the goal at a position. Searches premise-search.com.
| Parameter | Type | Description |
|---|---|---|
column * | integer | Column number (1-indexed) |
file_path * | string | Absolute path to Lean file |
line * | integer | Line number (1-indexed) |
num_results | integer | Max results |
lean_hammer_premise
Limit: 3req/30s. Get premise suggestions for automation tactics at a goal position. Returns lemma names to try with `simp only [...]`, `aesop`, or as hints.
| Parameter | Type | Description |
|---|---|---|
column * | integer | Column number (1-indexed) |
file_path * | string | Absolute path to Lean file |
line * | integer | Line number (1-indexed) |
num_results | integer | Max results |
lean_profile_proof
Run `lean --profile` on a theorem. Returns per-line timing and categories.
| Parameter | Type | Description |
|---|---|---|
file_path * | string | Absolute path to Lean file |
line * | integer | Line where theorem starts (1-indexed) |
timeout | number | Max seconds to wait |
top_n | integer | Number of slowest lines to return |