lean-lsp-mcp 0.1.1__py3-none-any.whl → 0.11.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,569 @@
1
+ Metadata-Version: 2.4
2
+ Name: lean-lsp-mcp
3
+ Version: 0.11.2
4
+ Summary: Lean Theorem Prover MCP
5
+ Author-email: Oliver Dressler <hey@oli.show>
6
+ License-Expression: MIT
7
+ Project-URL: Repository, https://github.com/oOo0oOo/lean-lsp-mcp
8
+ Requires-Python: >=3.10
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: leanclient==0.4.0
12
+ Requires-Dist: mcp[cli]==1.19.0
13
+ Requires-Dist: orjson>=3.11.1
14
+ Provides-Extra: lint
15
+ Requires-Dist: ruff>=0.2.0; extra == "lint"
16
+ Provides-Extra: dev
17
+ Requires-Dist: ruff>=0.2.0; extra == "dev"
18
+ Requires-Dist: pytest>=8.3; extra == "dev"
19
+ Requires-Dist: anyio>=4.4; extra == "dev"
20
+ Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
21
+ Dynamic: license-file
22
+
23
+ <h1 align="center">
24
+ lean-lsp-mcp
25
+ </h1>
26
+
27
+ <h3 align="center">Lean Theorem Prover MCP</h3>
28
+
29
+ <p align="center">
30
+ <a href="https://pypi.org/project/lean-lsp-mcp/">
31
+ <img src="https://img.shields.io/pypi/v/lean-lsp-mcp.svg" alt="PyPI version" />
32
+ </a>
33
+ <a href="">
34
+ <img src="https://img.shields.io/github/last-commit/oOo0oOo/lean-lsp-mcp" alt="last update" />
35
+ </a>
36
+ <a href="https://github.com/oOo0oOo/lean-lsp-mcp/blob/master/LICENSE">
37
+ <img src="https://img.shields.io/github/license/oOo0oOo/lean-lsp-mcp.svg" alt="license" />
38
+ </a>
39
+ </p>
40
+
41
+ MCP server that allows agentic interaction with the [Lean theorem prover](https://lean-lang.org/) via the [Language Server Protocol](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/) using [leanclient](https://github.com/oOo0oOo/leanclient). This server provides a range of tools for LLM agents to understand, analyze and interact with Lean projects.
42
+
43
+ ## Key Features
44
+
45
+ * **Rich Lean Interaction**: Access diagnostics, goal states, term information, hover documentation and more.
46
+ * **External Search Tools**: Use `LeanSearch`, `Loogle`, `Lean Finder`, `Lean Hammer` and `Lean State Search` to find relevant theorems and definitions.
47
+ * **Easy Setup**: Simple configuration for various clients, including VSCode, Cursor and Claude Code.
48
+
49
+ ## Setup
50
+
51
+ ### Overview
52
+
53
+ 1. Install [uv](https://docs.astral.sh/uv/getting-started/installation/), a Python package manager.
54
+ 2. Make sure your Lean project builds quickly by running `lake build` manually.
55
+ 3. Configure your IDE/Setup
56
+ 4. (Optional, highly recommended) Install [ripgrep](https://github.com/BurntSushi/ripgrep?tab=readme-ov-file#installation) (`rg`) to reduce hallucinations using local search.
57
+
58
+ ### 1. Install uv
59
+
60
+ [Install uv](https://docs.astral.sh/uv/getting-started/installation/) for your system. On Linux/MacOS: `curl -LsSf https://astral.sh/uv/install.sh | sh`
61
+
62
+ ### 2. Run `lake build`
63
+
64
+ `lean-lsp-mcp` will run `lake serve` in the project root to use the language server (for most tools). Some clients (e.g. Cursor) might timeout during this process. Therefore, it is recommended to run `lake build` manually before starting the MCP. This ensures a faster build time and avoids timeouts.
65
+
66
+ ### 3. Configure your IDE/Setup
67
+
68
+ <details>
69
+ <summary><b>VSCode</b></summary>
70
+ One-click config setup:
71
+
72
+ [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install_Server-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=lean-lsp&config=%7B%22command%22%3A%22uvx%22%2C%22args%22%3A%5B%22lean-lsp-mcp%22%5D%7D)
73
+
74
+ [![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install_Server-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=lean-lsp&config=%7B%22command%22%3A%22uvx%22%2C%22args%22%3A%5B%22lean-lsp-mcp%22%5D%7D&quality=insiders)
75
+
76
+ OR using the setup wizard:
77
+
78
+ Ctrl+Shift+P > "MCP: Add Server..." > "Command (stdio)" > "uvx lean-lsp-mcp" > "lean-lsp" (or any name you like) > Global or Workspace
79
+
80
+ OR manually adding config by opening `mcp.json` with:
81
+
82
+ Ctrl+Shift+P > "MCP: Open User Configuration"
83
+
84
+ and adding the following
85
+
86
+ ```jsonc
87
+ {
88
+ "servers": {
89
+ "lean-lsp": {
90
+ "type": "stdio",
91
+ "command": "uvx",
92
+ "args": [
93
+ "lean-lsp-mcp"
94
+ ]
95
+ }
96
+ }
97
+ }
98
+ ```
99
+
100
+ If you installed VSCode on Windows and are using WSL2 as your development environment, you may need to use this config instead:
101
+
102
+ ```jsonc
103
+ {
104
+ "servers": {
105
+ "lean-lsp": {
106
+ "type": "stdio",
107
+ "command": "wsl.exe",
108
+ "args": [
109
+ "uvx",
110
+ "lean-lsp-mcp"
111
+ ]
112
+ }
113
+ }
114
+ }
115
+ ```
116
+ If that doesn't work, you can try cloning this repository and replace `"lean-lsp-mcp"` with `"/path/to/cloned/lean-lsp-mcp"`.
117
+
118
+ </details>
119
+
120
+ <details>
121
+ <summary><b>Cursor</b></summary>
122
+ 1. Open MCP Settings (File > Preferences > Cursor Settings > MCP)
123
+
124
+ 2. "+ Add a new global MCP Server" > ("Create File")
125
+
126
+ 3. Paste the server config into `mcp.json` file:
127
+
128
+ ```jsonc
129
+ {
130
+ "mcpServers": {
131
+ "lean-lsp": {
132
+ "command": "uvx",
133
+ "args": ["lean-lsp-mcp"]
134
+ }
135
+ }
136
+ }
137
+ ```
138
+ </details>
139
+
140
+ <details>
141
+ <summary><b>Claude Code</b></summary>
142
+ Run one of these commands in the root directory of your Lean project (where `lakefile.toml` is located):
143
+
144
+ ```bash
145
+ # Local-scoped MCP server
146
+ claude mcp add lean-lsp uvx lean-lsp-mcp
147
+
148
+ # OR project-scoped MCP server
149
+ # (creates or updates a .mcp.json file in the current directory)
150
+ claude mcp add lean-lsp -s project uvx lean-lsp-mcp
151
+ ```
152
+
153
+ You can find more details about MCP server configuration for Claude Code [here](https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/tutorials#configure-mcp-servers).
154
+ </details>
155
+
156
+ #### Claude Skill: Lean4 Theorem Proving
157
+
158
+ If you are using [Claude Desktop](https://modelcontextprotocol.io/quickstart/user) or [Claude Code](https://claude.ai/code), you can also install the [Lean4 Theorem Proving Skill](https://github.com/cameronfreer/lean4-skills/tree/main/plugins/lean4-theorem-proving). This skill provides additional prompts and templates for interacting with Lean4 projects and includes a section on interacting with the `lean-lsp-mcp` server.
159
+
160
+ ### 4. Install ripgrep (optional but recommended)
161
+
162
+ For the local search tool `lean_local_search`, install [ripgrep](https://github.com/BurntSushi/ripgrep?tab=readme-ov-file#installation) (`rg`) and make sure it is available in your PATH.
163
+
164
+ ## MCP Tools
165
+
166
+
167
+ ### File interactions (LSP)
168
+
169
+ #### lean_file_contents
170
+
171
+ Get the contents of a Lean file, optionally with line number annotations.
172
+
173
+ #### lean_diagnostic_messages
174
+
175
+ Get all diagnostic messages for a Lean file. This includes infos, warnings and errors.
176
+
177
+ <details>
178
+ <summary>Example output</summary>
179
+
180
+ ```
181
+ l20c42-l20c46, severity: 1
182
+ simp made no progress
183
+
184
+ l21c11-l21c45, severity: 1
185
+ function expected at
186
+ h_empty
187
+ term has type
188
+ T ∩ compl T = ∅
189
+
190
+ ...
191
+ ```
192
+ </details>
193
+
194
+ #### lean_goal
195
+
196
+ Get the proof goal at a specific location (line or line & column) in a Lean file.
197
+
198
+ <details>
199
+ <summary>Example output (line)</summary>
200
+
201
+ ```
202
+ Before:
203
+ S : Type u_1
204
+ inst✝¹ : Fintype S
205
+ inst✝ : Nonempty S
206
+ P : Finset (Set S)
207
+ hPP : ∀ T ∈ P, ∀ U ∈ P, T ∩ U ≠ ∅
208
+ hPS : ¬∃ T ∉ P, ∀ U ∈ P, T ∩ U ≠ ∅
209
+ compl : Set S → Set S := fun T ↦ univ \ T
210
+ hcompl : ∀ T ∈ P, compl T ∉ P
211
+ all_subsets : Finset (Set S) := Finset.univ
212
+ h_comp_in_P : ∀ T ∉ P, compl T ∈ P
213
+ h_partition : ∀ (T : Set S), T ∈ P ∨ compl T ∈ P
214
+ ⊢ P.card = 2 ^ (Fintype.card S - 1)
215
+ After:
216
+ no goals
217
+ ```
218
+ </details>
219
+
220
+ #### lean_term_goal
221
+
222
+ Get the term goal at a specific position (line & column) in a Lean file.
223
+
224
+ #### lean_hover_info
225
+
226
+ Retrieve hover information (documentation) for symbols, terms, and expressions in a Lean file (at a specific line & column).
227
+
228
+ <details>
229
+ <summary>Example output (hover info on a `sorry`)</summary>
230
+
231
+ ```
232
+ The `sorry` tactic is a temporary placeholder for an incomplete tactic proof,
233
+ closing the main goal using `exact sorry`.
234
+
235
+ This is intended for stubbing-out incomplete parts of a proof while still having a syntactically correct proof skeleton.
236
+ Lean will give a warning whenever a proof uses `sorry`, so you aren't likely to miss it,
237
+ but you can double check if a theorem depends on `sorry` by looking for `sorryAx` in the output
238
+ of the `#print axioms my_thm` command, the axiom used by the implementation of `sorry`.
239
+ ```
240
+ </details>
241
+
242
+ #### lean_declaration_file
243
+
244
+ Get the file contents where a symbol or term is declared.
245
+
246
+ #### lean_completions
247
+
248
+ Code auto-completion: Find available identifiers or import suggestions at a specific position (line & column) in a Lean file.
249
+
250
+ #### lean_run_code
251
+
252
+ Run/compile an independent Lean code snippet/file and return the result or error message.
253
+ <details>
254
+ <summary>Example output (code snippet: `#eval 5 * 7 + 3`)</summary>
255
+
256
+ ```
257
+ l1c1-l1c6, severity: 3
258
+ 38
259
+ ```
260
+ </details>
261
+
262
+ #### lean_multi_attempt
263
+
264
+ Attempt multiple lean code snippets on a line and return goal state and diagnostics for each snippet.
265
+ This tool is useful to screen different proof attempts before using the most promising one.
266
+
267
+ <details>
268
+ <summary>Example output (attempting `rw [Nat.pow_sub (Fintype.card_pos_of_nonempty S)]` and `by_contra h_neq`)</summary>
269
+
270
+ ```
271
+ rw [Nat.pow_sub (Fintype.card_pos_of_nonempty S)]:
272
+ S : Type u_1
273
+ inst✝¹ : Fintype S
274
+ inst✝ : Nonempty S
275
+ P : Finset (Set S)
276
+ hPP : ∀ T ∈ P, ∀ U ∈ P, T ∩ U ≠ ∅
277
+ hPS : ¬∃ T ∉ P, ∀ U ∈ P, T ∩ U ≠ ∅
278
+ ⊢ P.card = 2 ^ (Fintype.card S - 1)
279
+
280
+ l14c7-l14c51, severity: 1
281
+ unknown constant 'Nat.pow_sub'
282
+
283
+ by_contra h_neq:
284
+ S : Type u_1
285
+ inst✝¹ : Fintype S
286
+ inst✝ : Nonempty S
287
+ P : Finset (Set S)
288
+ hPP : ∀ T ∈ P, ∀ U ∈ P, T ∩ U ≠ ∅
289
+ hPS : ¬∃ T ∉ P, ∀ U ∈ P, T ∩ U ≠ ∅
290
+ h_neq : ¬P.card = 2 ^ (Fintype.card S - 1)
291
+ ⊢ False
292
+
293
+ ...
294
+ ```
295
+ </details>
296
+
297
+ ### Local Search Tools
298
+
299
+ #### lean_local_search
300
+
301
+ Search for Lean definitions and theorems in the local Lean project and stdlib.
302
+ This is useful to confirm declarations actually exist and prevent hallucinating APIs.
303
+
304
+ This tool requires [ripgrep](https://github.com/BurntSushi/ripgrep?tab=readme-ov-file#installation) (`rg`) to be installed and available in your PATH.
305
+
306
+ ### External Search Tools
307
+
308
+ Currently most external tools are separately **rate limited to 3 requests per 30 seconds**. Please don't ruin the fun for everyone by overusing these amazing free services!
309
+
310
+ Please cite the original authors of these tools if you use them!
311
+
312
+ #### lean_leansearch
313
+
314
+ Search for theorems in Mathlib using [leansearch.net](https://leansearch.net) (natural language search).
315
+
316
+ [Github Repository](https://github.com/frenzymath/LeanSearch) | [Arxiv Paper](https://arxiv.org/abs/2403.13310)
317
+
318
+ - Supports natural language, mixed queries, concepts, identifiers, and Lean terms.
319
+ - Example: `bijective map from injective`, `n + 1 <= m if n < m`, `Cauchy Schwarz`, `List.sum`, `{f : A → B} (hf : Injective f) : ∃ h, Bijective h`
320
+
321
+ <details>
322
+ <summary>Example output (query by LLM: `bijective map from injective`)</summary>
323
+
324
+ ```json
325
+ {
326
+ "module_name": "Mathlib.Logic.Function.Basic",
327
+ "kind": "theorem",
328
+ "name": "Function.Bijective.injective",
329
+ "signature": " {f : α → β} (hf : Bijective f) : Injective f",
330
+ "type": "∀ {α : Sort u_1} {β : Sort u_2} {f : α → β}, Function.Bijective f → Function.Injective f",
331
+ "value": ":= hf.1",
332
+ "informal_name": "Bijectivity Implies Injectivity",
333
+ "informal_description": "For any function $f \\colon \\alpha \\to \\beta$, if $f$ is bijective, then $f$ is injective."
334
+ },
335
+ ...
336
+ ```
337
+ </details>
338
+
339
+ #### lean_loogle
340
+
341
+ Search for Lean definitions and theorems using [loogle.lean-lang.org](https://loogle.lean-lang.org/).
342
+
343
+ [Github Repository](https://github.com/nomeata/loogle)
344
+
345
+ - Supports queries by constant, lemma name, subexpression, type, or conclusion.
346
+ - Example: `Real.sin`, `"differ"`, `_ * (_ ^ _)`, `(?a -> ?b) -> List ?a -> List ?b`, `|- tsum _ = _ * tsum _`
347
+
348
+ <details>
349
+ <summary>Example output (`Real.sin`)</summary>
350
+
351
+ ```json
352
+ [
353
+ {
354
+ "type": " (x : ℝ) : ℝ",
355
+ "name": "Real.sin",
356
+ "module": "Mathlib.Data.Complex.Trigonometric"
357
+ },
358
+ ...
359
+ ]
360
+ ```
361
+ </details>
362
+
363
+ #### lean_leanfinder
364
+
365
+ Semantic search for Mathlib theorems using [Lean Finder](https://huggingface.co/spaces/delta-lab-ai/Lean-Finder).
366
+
367
+ [Arxiv Paper](https://arxiv.org/abs/2510.15940)
368
+
369
+ - Supports informal descriptions, user questions, proof states, and statement fragments.
370
+ - Examples: `algebraic elements x,y over K with same minimal polynomial`, `Does y being a root of minpoly(x) imply minpoly(x)=minpoly(y)?`, `⊢ |re z| ≤ ‖z‖` + `transform to squared norm inequality`, `theorem restrict Ioi: restrict Ioi e = restrict Ici e`
371
+
372
+ <details>
373
+ <summary>Example output</summary>
374
+
375
+ Query: `Does y being a root of minpoly(x) imply minpoly(x)=minpoly(y)?`
376
+
377
+ ```json
378
+ [
379
+ [
380
+ "/-- If `y : L` is a root of `minpoly K x`, then `minpoly K y = minpoly K x`. -/\ntheorem eq_of_root {x y : L} (hx : IsAlgebraic K x)\n (h_ev : Polynomial.aeval y (minpoly K x) = 0) : minpoly K y = minpoly K x :=\n ((eq_iff_aeval_minpoly_eq_zero hx.isIntegral).mpr h_ev).symm",
381
+
382
+ "Let $L/K$ be a field extension, and let $x, y \\in L$ be elements such that $y$ is a root of the minimal polynomial of $x$ over $K$. If $x$ is algebraic over $K$, then the minimal polynomial of $y$ over $K$ is equal to the minimal polynomial of $x$ over $K$, i.e., $\\text{minpoly}_K(y) = \\text{minpoly}_K(x)$. This means that if $y$ satisfies the polynomial equation defined by $x$, then $y$ shares the same minimal polynomial as $x$."
383
+ ],
384
+ ...
385
+ ]
386
+ ```
387
+ </details>
388
+
389
+ #### lean_state_search
390
+
391
+ Search for applicable theorems for the current proof goal using [premise-search.com](https://premise-search.com/).
392
+
393
+ [Github Repository](https://github.com/ruc-ai4math/Premise-Retrieval) | [Arxiv Paper](https://arxiv.org/abs/2501.13959)
394
+
395
+ A self-hosted version is [available](https://github.com/ruc-ai4math/LeanStateSearch) and encouraged. You can set an environment variable `LEAN_STATE_SEARCH_URL` to point to your self-hosted instance. It defaults to `https://premise-search.com`.
396
+
397
+ Uses the first goal at a given line and column.
398
+ Returns a list of relevant theorems.
399
+ <details> <summary>Example output (line 24, column 3)</summary>
400
+
401
+ ```json
402
+ [
403
+ {
404
+ "name": "Nat.mul_zero",
405
+ "formal_type": "∀ (n : Nat), n * 0 = 0",
406
+ "module": "Init.Data.Nat.Basic"
407
+ },
408
+ ...
409
+ ]
410
+ ```
411
+ </details>
412
+
413
+
414
+ #### lean_hammer_premise
415
+
416
+ Search for relevant premises based on the current proof state using the [Lean Hammer Premise Search](https://github.com/hanwenzhu/lean-premise-server).
417
+
418
+ [Github Repository](https://github.com/hanwenzhu/lean-premise-server) | [Arxiv Paper](https://arxiv.org/abs/2506.07477)
419
+
420
+ A self-hosted version is [available](https://github.com/hanwenzhu/lean-premise-server) and encouraged. You can set an environment variable `LEAN_HAMMER_URL` to point to your self-hosted instance. It defaults to `http://leanpremise.net`.
421
+
422
+ Uses the first goal at a given line and column.
423
+ Returns a list of relevant premises (theorems) that can be used to prove the goal.
424
+
425
+ Note: We use a simplified version, [LeanHammer](https://github.com/JOSHCLUNE/LeanHammer) might have better premise search results.
426
+ <details><summary>Example output (line 24, column 3)</summary>
427
+
428
+ ```json
429
+ [
430
+ "MulOpposite.unop_injective",
431
+ "MulOpposite.op_injective",
432
+ "WellFoundedLT.induction",
433
+ ...
434
+ ]
435
+ ```
436
+ </details>
437
+
438
+ ### Project-level tools
439
+
440
+ #### lean_build
441
+
442
+ Rebuild the Lean project and restart the Lean LSP server.
443
+
444
+ ### Disabling Tools
445
+
446
+ Many clients allow the user to disable specific tools manually (e.g. lean_build).
447
+
448
+ **VSCode**: Click on the Wrench/Screwdriver icon in the chat.
449
+
450
+ **Cursor**: In "Cursor Settings" > "MCP" click on the name of a tool to disable it (strikethrough).
451
+
452
+ ## MCP Configuration
453
+
454
+ This MCP server works out-of-the-box without any configuration. However, a few optional settings are available.
455
+
456
+ ### Environment Variables
457
+
458
+ - `LEAN_LOG_LEVEL`: Log level for the server. Options are "INFO", "WARNING", "ERROR", "NONE". Defaults to "INFO".
459
+ - `LEAN_PROJECT_PATH`: Path to your Lean project root. Set this if the server cannot automatically detect your project.
460
+ - `LEAN_LSP_MCP_TOKEN`: Secret token for bearer authentication when using `streamable-http` or `sse` transport.
461
+ - `LEAN_STATE_SEARCH_URL`: URL for a self-hosted [premise-search.com](https://premise-search.com) instance.
462
+ - `LEAN_HAMMER_URL`: URL for a self-hosted [Lean Hammer Premise Search](https://github.com/hanwenzhu/lean-premise-server) instance.
463
+
464
+ You can also often set these environment variables in your MCP client configuration:
465
+ <details>
466
+ <summary><b>VSCode mcp.json Example</b></summary>
467
+
468
+ ```jsonc
469
+ {
470
+ "servers": {
471
+ "lean-lsp": {
472
+ "type": "stdio",
473
+ "command": "uvx",
474
+ "args": [
475
+ "lean-lsp-mcp"
476
+ ],
477
+ "env": {
478
+ "LEAN_PROJECT_PATH": "/path/to/your/lean/project",
479
+ "LEAN_LOG_LEVEL": "NONE"
480
+ }
481
+ }
482
+ }
483
+ }
484
+ ```
485
+ </details>
486
+
487
+ ### Transport Methods
488
+
489
+ The Lean LSP MCP server supports the following transport methods:
490
+
491
+ - `stdio`: Standard input/output (default)
492
+ - `streamable-http`: HTTP streaming
493
+ - `sse`: Server-sent events (MCP legacy, use `streamable-http` if possible)
494
+
495
+ You can specify the transport method using the `--transport` argument when running the server. For `sse` and `streamable-http` you can also optionally specify the host and port:
496
+
497
+ ```bash
498
+ uvx lean-lsp-mcp --transport stdio # Default transport
499
+ uvx lean-lsp-mcp --transport streamable-http # Available at http://127.0.0.1:8000/mcp
500
+ uvx lean-lsp-mcp --transport sse --host localhost --port 12345 # Available at http://localhost:12345/sse
501
+ ```
502
+
503
+ ### Bearer Token Authentication
504
+
505
+ Transport via `streamable-http` and `sse` supports bearer token authentication. This allows publicly accessible MCP servers to restrict access to authorized clients.
506
+
507
+ Set the `LEAN_LSP_MCP_TOKEN` environment variable (or see section 3 for setting env variables in MCP config) to a secret token before starting the server.
508
+
509
+ Example Linux/MacOS setup:
510
+
511
+ ```bash
512
+ export LEAN_LSP_MCP_TOKEN="your_secret_token"
513
+ uvx lean-lsp-mcp --transport streamable-http
514
+ ```
515
+
516
+ Clients should then include the token in the `Authorization` header.
517
+
518
+ ## Notes on MCP Security
519
+
520
+ There are many valid security concerns with the Model Context Protocol (MCP) in general!
521
+
522
+ This MCP server is meant as a research tool and is currently in beta.
523
+ While it does not handle any sensitive data such as passwords or API keys, it still includes various security risks:
524
+ - Access to your local file system.
525
+ - No input or output validation.
526
+
527
+ Please be aware of these risks. Feel free to audit the code and report security issues!
528
+
529
+ For more information, you can use [Awesome MCP Security](https://github.com/Puliczek/awesome-mcp-security) as a starting point.
530
+
531
+ ## Development
532
+
533
+ ### MCP Inspector
534
+
535
+ ```bash
536
+ npx @modelcontextprotocol/inspector uvx --with-editable path/to/lean-lsp-mcp python -m lean_lsp_mcp.server
537
+ ```
538
+
539
+ ### Run Tests
540
+
541
+ ```bash
542
+ uv sync --all-extras
543
+ uv run pytest tests
544
+ ```
545
+
546
+ ## Publications using lean-lsp-mcp
547
+
548
+ - Ax-Prover: A Deep Reasoning Agentic Framework for Theorem Proving in Mathematics and Quantum Physics [arxiv](https://arxiv.org/abs/2510.12787)
549
+
550
+ ## Related Projects
551
+
552
+ - [LeanTool](https://github.com/GasStationManager/LeanTool)
553
+ - [LeanExplore MCP](https://www.leanexplore.com/docs/mcp)
554
+
555
+ ## License & Citation
556
+
557
+ **MIT** licensed. See [LICENSE](LICENSE) for more information.
558
+
559
+ Citing this repository is highly appreciated but not required by the license.
560
+
561
+ ```bibtex
562
+ @software{lean-lsp-mcp,
563
+ author = {Oliver Dressler},
564
+ title = {{Lean LSP MCP: Tools for agentic interaction with the Lean theorem prover}},
565
+ url = {https://github.com/oOo0oOo/lean-lsp-mcp},
566
+ month = {3},
567
+ year = {2025}
568
+ }
569
+ ```
@@ -0,0 +1,14 @@
1
+ lean_lsp_mcp/__init__.py,sha256=lxqDq0G_sI2iu2Nniy-pTW7BE9Ux7ZXeDoGf0OAWIDc,763
2
+ lean_lsp_mcp/__main__.py,sha256=XnpTzfJc0T-j9tHtdkA8ovTr1c139ffTewcJGhxYDaM,49
3
+ lean_lsp_mcp/client_utils.py,sha256=Z-2AoFBA36UO8oeauTNUtquE6Yz_ZRTKz_9n1iapyJ4,4519
4
+ lean_lsp_mcp/file_utils.py,sha256=qddegF-T5-egZop8dPe_3Cma-3rRSKsAErVDQLecmbE,2916
5
+ lean_lsp_mcp/instructions.py,sha256=y_gHlbeJoKnPohmcSVrQQds6mbBO1en-lxnXAfEypZE,892
6
+ lean_lsp_mcp/search_utils.py,sha256=X2LPynDNLi767UDxbxHpMccOkbnfKJKv_HxvRNxIXM4,3984
7
+ lean_lsp_mcp/server.py,sha256=knA8HsJZeUNnMqNdv2rnAnS__Eblr0aPnlwKH1FrLbA,34661
8
+ lean_lsp_mcp/utils.py,sha256=zLu2VIhaX4yocY07F3Z94LB2jRGrkH1ID9SjR3poE9A,8255
9
+ lean_lsp_mcp-0.11.2.dist-info/licenses/LICENSE,sha256=CQlxnf0tQyoVrBE93JYvAUYxv6Z5Yg6sX0pwogOkFvo,1071
10
+ lean_lsp_mcp-0.11.2.dist-info/METADATA,sha256=2sGVG-wCFYATL2iKhQ7Twt_6jcvPumAk7P74y_2uCto,19626
11
+ lean_lsp_mcp-0.11.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
12
+ lean_lsp_mcp-0.11.2.dist-info/entry_points.txt,sha256=nQbvwctWkWD7I-2f4VrdVQBZYGUw8CnUnFC6QjXxOSE,51
13
+ lean_lsp_mcp-0.11.2.dist-info/top_level.txt,sha256=LGEK0lgMSNPIQ6mG8EO-adaZEGPi_0daDs004epOTF0,13
14
+ lean_lsp_mcp-0.11.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (78.1.0)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Oliver Dressler
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
lean_lsp_mcp/prompts.py DELETED
@@ -1,33 +0,0 @@
1
- PROMPT_AUTOMATIC_PROOF = """# Situation
2
- You are an AI that has studied all of known mathematics. Proof the theorem in the open file using lean 4.
3
-
4
- ## Important general rules!
5
-
6
- - Only work on one sorry at the time!
7
- - Write additional sorries whenever you encounter a new problem, solve them later one by one!
8
- - All line and column numbers are 1-indexed (as in the editor).
9
- - Attempt to solve the proof in tactics mode, convert if necessary.
10
- - If at any point you think you cannot solve the proof, stop immediately and explain why.
11
-
12
- ## MCP tools
13
- Out of the available mcp tools these are very important:
14
-
15
- `lean_diagnostic_messages`
16
- Use this to understand the current proof situation.
17
-
18
- `lean_goal` & `lean_term_goal`
19
- VERY USEFUL!! This is your main tool to understand the proof state and its evolution!!
20
- Use these very often!
21
-
22
- `lean_hover_info`
23
- Use this to understand the meaning of terms and lean syntax in general.
24
-
25
- `lean_proofs_complete`
26
- Use this to check whether all proofs in a file are complete.
27
-
28
- ## Suggested Proof Process
29
-
30
- 1. Extensive diagnostics phase!!
31
- 2. Suggest a small edit to make any progress towards proofing the current sorry.
32
- 3. Repeat until the proof is done.
33
- """
@@ -1,17 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: lean-lsp-mcp
3
- Version: 0.1.1
4
- Summary: MCP server to interact with Lean prover via LSP
5
- License-Expression: MIT
6
- Requires-Python: >=3.10
7
- Description-Content-Type: text/markdown
8
- Requires-Dist: leanclient>=0.1.7
9
- Requires-Dist: mcp[cli]>=1.5.0
10
- Provides-Extra: lint
11
- Requires-Dist: ruff>=0.2.0; extra == "lint"
12
- Provides-Extra: dev
13
- Requires-Dist: ruff>=0.2.0; extra == "dev"
14
-
15
- # Lean LSP MCP
16
-
17
- MCP that allows agents to interact with the Lean LSP server.
@@ -1,9 +0,0 @@
1
- lean_lsp_mcp/__init__.py,sha256=2R-1R7MLy8mPSRMSkYpjpKJi1iSIuHMW3xHo5BHO4q8,63
2
- lean_lsp_mcp/__main__.py,sha256=FXrfjaRWTFVsF51C6XJVS-yExULSZkS1RtrmHLYfXAw,48
3
- lean_lsp_mcp/prompts.py,sha256=bDkfgtKpbIc7ojkKPFr7QqHtTnxolUSvG-vmIS3OFY4,1200
4
- lean_lsp_mcp/server.py,sha256=PzdMocjgs3YUHRqqS-qRZKLEXNIpThR7zQJi5DtWZRs,12581
5
- lean_lsp_mcp-0.1.1.dist-info/METADATA,sha256=heIADNQaAGfZ4XLRbF_OHPhycJ33OIzCb5Y5d3imoBQ,471
6
- lean_lsp_mcp-0.1.1.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
7
- lean_lsp_mcp-0.1.1.dist-info/entry_points.txt,sha256=nQbvwctWkWD7I-2f4VrdVQBZYGUw8CnUnFC6QjXxOSE,51
8
- lean_lsp_mcp-0.1.1.dist-info/top_level.txt,sha256=LGEK0lgMSNPIQ6mG8EO-adaZEGPi_0daDs004epOTF0,13
9
- lean_lsp_mcp-0.1.1.dist-info/RECORD,,