isabelle-mcp 0.1.0__tar.gz
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.
- isabelle_mcp-0.1.0/LICENSE +21 -0
- isabelle_mcp-0.1.0/PKG-INFO +184 -0
- isabelle_mcp-0.1.0/README.md +144 -0
- isabelle_mcp-0.1.0/pyproject.toml +128 -0
- isabelle_mcp-0.1.0/setup.cfg +4 -0
- isabelle_mcp-0.1.0/src/isabelle_mcp/__init__.py +5 -0
- isabelle_mcp-0.1.0/src/isabelle_mcp/evaluation.py +756 -0
- isabelle_mcp-0.1.0/src/isabelle_mcp/file_watcher.py +225 -0
- isabelle_mcp-0.1.0/src/isabelle_mcp/install.py +227 -0
- isabelle_mcp-0.1.0/src/isabelle_mcp/instructions.py +87 -0
- isabelle_mcp-0.1.0/src/isabelle_mcp/lsp_client.py +1398 -0
- isabelle_mcp-0.1.0/src/isabelle_mcp/models.py +201 -0
- isabelle_mcp-0.1.0/src/isabelle_mcp/processing.py +234 -0
- isabelle_mcp-0.1.0/src/isabelle_mcp/py.typed +2 -0
- isabelle_mcp-0.1.0/src/isabelle_mcp/server.py +423 -0
- isabelle_mcp-0.1.0/src/isabelle_mcp/tools/__init__.py +12 -0
- isabelle_mcp-0.1.0/src/isabelle_mcp/tools/command_output.py +94 -0
- isabelle_mcp-0.1.0/src/isabelle_mcp/tools/definition.py +97 -0
- isabelle_mcp-0.1.0/src/isabelle_mcp/tools/goal.py +44 -0
- isabelle_mcp-0.1.0/src/isabelle_mcp/tools/hover.py +113 -0
- isabelle_mcp-0.1.0/src/isabelle_mcp/tools/local_occurrences.py +97 -0
- isabelle_mcp-0.1.0/src/isabelle_mcp/tools/session.py +10 -0
- isabelle_mcp-0.1.0/src/isabelle_mcp/utils/__init__.py +59 -0
- isabelle_mcp-0.1.0/src/isabelle_mcp/utils/core.py +95 -0
- isabelle_mcp-0.1.0/src/isabelle_mcp/utils/formatters.py +217 -0
- isabelle_mcp-0.1.0/src/isabelle_mcp/utils/isabelle_symbols.py +197 -0
- isabelle_mcp-0.1.0/src/isabelle_mcp/utils/isabelle_tokens.py +272 -0
- isabelle_mcp-0.1.0/src/isabelle_mcp.egg-info/PKG-INFO +184 -0
- isabelle_mcp-0.1.0/src/isabelle_mcp.egg-info/SOURCES.txt +47 -0
- isabelle_mcp-0.1.0/src/isabelle_mcp.egg-info/dependency_links.txt +1 -0
- isabelle_mcp-0.1.0/src/isabelle_mcp.egg-info/entry_points.txt +2 -0
- isabelle_mcp-0.1.0/src/isabelle_mcp.egg-info/requires.txt +15 -0
- isabelle_mcp-0.1.0/src/isabelle_mcp.egg-info/top_level.txt +1 -0
- isabelle_mcp-0.1.0/tests/test_edge_cases.py +133 -0
- isabelle_mcp-0.1.0/tests/test_file_watcher.py +177 -0
- isabelle_mcp-0.1.0/tests/test_heap_sources.py +96 -0
- isabelle_mcp-0.1.0/tests/test_install.py +221 -0
- isabelle_mcp-0.1.0/tests/test_integration.py +71 -0
- isabelle_mcp-0.1.0/tests/test_isabelle_tokens.py +225 -0
- isabelle_mcp-0.1.0/tests/test_lsp_client.py +826 -0
- isabelle_mcp-0.1.0/tests/test_server.py +340 -0
- isabelle_mcp-0.1.0/tests/test_tools_command_output.py +120 -0
- isabelle_mcp-0.1.0/tests/test_tools_definition.py +141 -0
- isabelle_mcp-0.1.0/tests/test_tools_evaluate.py +450 -0
- isabelle_mcp-0.1.0/tests/test_tools_goal.py +53 -0
- isabelle_mcp-0.1.0/tests/test_tools_hover.py +150 -0
- isabelle_mcp-0.1.0/tests/test_tools_local_occurrences.py +70 -0
- isabelle_mcp-0.1.0/tests/test_tools_session.py +10 -0
- isabelle_mcp-0.1.0/tests/test_utils.py +292 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2026 Qiyuan Xu
|
|
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.
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: isabelle-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MCP server bridging AI agents with the Isabelle proof assistant via its LSP/PIDE interface
|
|
5
|
+
Author-email: Qiyuan Xu <xqyww123@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/xqyww123/Isabelle-MCP
|
|
8
|
+
Project-URL: Documentation, https://github.com/xqyww123/Isabelle-MCP/tree/main/docs
|
|
9
|
+
Project-URL: Repository, https://github.com/xqyww123/Isabelle-MCP
|
|
10
|
+
Project-URL: Issues, https://github.com/xqyww123/Isabelle-MCP/issues
|
|
11
|
+
Project-URL: Changelog, https://github.com/xqyww123/Isabelle-MCP/blob/main/CHANGELOG.md
|
|
12
|
+
Keywords: isabelle,theorem-prover,mcp,lsp,ai-assistance
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: Science/Research
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Typing :: Typed
|
|
22
|
+
Requires-Python: >=3.12
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: beautifulsoup4>=4.12.0
|
|
26
|
+
Requires-Dist: fastmcp<4,>=3.2
|
|
27
|
+
Requires-Dist: mcp>=1.0.0
|
|
28
|
+
Requires-Dist: my-better-isabelle-prover>=0.1.0
|
|
29
|
+
Requires-Dist: pydantic>=2.0.0
|
|
30
|
+
Requires-Dist: watchdog>=3.0.0
|
|
31
|
+
Provides-Extra: dev
|
|
32
|
+
Requires-Dist: coverage>=7.0.0; extra == "dev"
|
|
33
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
34
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
35
|
+
Requires-Dist: pytest-cov>=7.0.0; extra == "dev"
|
|
36
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
37
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
38
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
39
|
+
Dynamic: license-file
|
|
40
|
+
|
|
41
|
+
# Isabelle-MCP
|
|
42
|
+
|
|
43
|
+
MCP server that lets AI agents (Claude Code, Codex, …) drive the Isabelle
|
|
44
|
+
theorem prover through its LSP/PIDE commands — fully autonomously, with no
|
|
45
|
+
human in the loop.
|
|
46
|
+
|
|
47
|
+
**Python ≥ 3.12 | v0.1.0 (MVP)**
|
|
48
|
+
|
|
49
|
+
## Purpose
|
|
50
|
+
|
|
51
|
+
This MCP server exists so that Claude / Codex can issue Isabelle LSP commands
|
|
52
|
+
**without any human mediation**. The entire Isabelle process is encapsulated
|
|
53
|
+
behind the MCP tools — it exposes **no UI to the user**. The agent works by
|
|
54
|
+
editing `.thy`/`.ML` files on disk and calling the tools to evaluate them and
|
|
55
|
+
query proof states; nobody watches or steers the prover interactively.
|
|
56
|
+
|
|
57
|
+
This server is **not designed for human–AI collaboration** (there is no
|
|
58
|
+
jEdit/VSCode front-end in the picture). It implements a single
|
|
59
|
+
AI ↔ Isabelle, no-human-in-the-loop model.
|
|
60
|
+
|
|
61
|
+
> ⚠️ **One agent per server instance.** This server holds a single Isabelle
|
|
62
|
+
> session with global mutable state — one set of open documents, one
|
|
63
|
+
> caret/perspective, and one evaluation in flight at a time. It is
|
|
64
|
+
> **single-threaded and not concurrency-safe**: pointing multiple agents at one
|
|
65
|
+
> instance, or interleaving concurrent requests, corrupts the evaluation/caret/
|
|
66
|
+
> document state with catastrophic, hard-to-debug results. The server runs over
|
|
67
|
+
> **stdio**, so each agent already gets its own dedicated server process (and its
|
|
68
|
+
> own `isabelle vscode_server`) — just don't share one or drive it concurrently.
|
|
69
|
+
|
|
70
|
+
> [!IMPORTANT]
|
|
71
|
+
> **Patch Isabelle first — this server does not work on a stock Isabelle.** It
|
|
72
|
+
> drives `isabelle vscode_server` through PIDE LSP requests
|
|
73
|
+
> (`PIDE/output_at_position`, `PIDE/cancel_execution`, …) that only exist after
|
|
74
|
+
> applying the
|
|
75
|
+
> [my-better-isabelle-prover](https://github.com/xqyww123/my_better_isabelle_prover)
|
|
76
|
+
> patches:
|
|
77
|
+
>
|
|
78
|
+
> ```bash
|
|
79
|
+
> pip install my-better-isabelle-prover # via pip or uv tool; needs Python ≥ 3.12
|
|
80
|
+
> my-better-isabelle patch # apply patches + rebuild the Scala components
|
|
81
|
+
> my-better-isabelle status # verify: every patch reports "applied"
|
|
82
|
+
> ```
|
|
83
|
+
>
|
|
84
|
+
> `isabelle-mcp install` checks this (when `isabelle` is reachable) and refuses to
|
|
85
|
+
> register the server against an unpatched Isabelle. The server re-checks at
|
|
86
|
+
> run time too: every `isabelle_launch` verifies the patches (via its bundled
|
|
87
|
+
> copy of the patch manager) and refuses to start an unpatched Isabelle —
|
|
88
|
+
> bypass with `isabelle-mcp --skip-patch-check` for hand-patched setups the
|
|
89
|
+
> patch manager cannot recognize. Compatibility notes
|
|
90
|
+
> (PEP 668, non-global Isabelle, …) are in [AGENTS.md](AGENTS.md).
|
|
91
|
+
|
|
92
|
+
## Quick Start
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
pip install isabelle-mcp # or: uv tool install isabelle-mcp
|
|
96
|
+
|
|
97
|
+
# register into Claude Code / Codex (auto-detects whichever is installed):
|
|
98
|
+
isabelle-mcp install
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
For Claude Desktop, register manually instead
|
|
102
|
+
(`~/.config/claude/claude_desktop_config.json`):
|
|
103
|
+
|
|
104
|
+
```json
|
|
105
|
+
{
|
|
106
|
+
"mcpServers": {
|
|
107
|
+
"isabelle": {
|
|
108
|
+
"command": "isabelle-mcp"
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
The session/logic is **not** configured here — the agent picks it at run time by
|
|
115
|
+
calling the `isabelle_launch` tool (see Tools below).
|
|
116
|
+
|
|
117
|
+
## Running the server
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
isabelle-mcp # stdio transport (the only transport)
|
|
121
|
+
isabelle-mcp -- -o editor_output_state=true # args after `--` go to isabelle vscode_server
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
The server starts no prover at launch; the connected agent calls `isabelle_launch`
|
|
125
|
+
to start one for a chosen session.
|
|
126
|
+
|
|
127
|
+
| Flag | Default | Meaning |
|
|
128
|
+
|------|---------|---------|
|
|
129
|
+
| `install` | — | Register the server with Claude Code / Codex (see `isabelle-mcp install --help`) |
|
|
130
|
+
| `--version` | — | Print the version and exit |
|
|
131
|
+
| `--skip-patch-check` | — | Skip the my-better-isabelle-prover patch verification at session launch |
|
|
132
|
+
| `-- ...` | — | Everything after `--` is forwarded to `isabelle vscode_server` |
|
|
133
|
+
|
|
134
|
+
### Environment variables
|
|
135
|
+
|
|
136
|
+
These are read once at process startup; a connected agent cannot change them.
|
|
137
|
+
|
|
138
|
+
| Variable | Default | Effect |
|
|
139
|
+
|----------|---------|--------|
|
|
140
|
+
| `ISABELLE_MCP_EVAL_POLL_INTERVAL` | `10` | Seconds an evaluate/poll call waits before returning `in_progress` |
|
|
141
|
+
| `ISABELLE_MCP_DUMP` | unset | If set to a path, append a JSON wire-log of all LSP traffic (debugging) |
|
|
142
|
+
|
|
143
|
+
## Tools
|
|
144
|
+
|
|
145
|
+
| Tool | Description |
|
|
146
|
+
|------|-------------|
|
|
147
|
+
| `isabelle_launch` | Start (or restart) the prover with the session/logic that fits the work (bare `Main` is only a minimal fallback); **call this first** |
|
|
148
|
+
| `isabelle_terminate` | Terminate the running prover (the MCP server stays up; you can relaunch) |
|
|
149
|
+
| `isabelle_evaluate_to` | Evaluate the theory up to a line; returns a per-file snapshot of errors / warnings / running command lines |
|
|
150
|
+
| `isabelle_evaluation_status` | Poll progress of a running evaluation (same snapshot) |
|
|
151
|
+
| `isabelle_cancel_evaluation` | Cancel a running evaluation |
|
|
152
|
+
| `isabelle_hover` | Type info and documentation at position |
|
|
153
|
+
| `isabelle_definition` | Jump to symbol definition |
|
|
154
|
+
| `isabelle_local_occurrences` | In-file occurrences (definition + uses) of a local entity |
|
|
155
|
+
| `isabelle_goal` | **Proof goals** — omit after_text for before/after diff |
|
|
156
|
+
| `isabelle_command_output` | Prover output messages |
|
|
157
|
+
| `isabelle_session_info` | Current session info |
|
|
158
|
+
|
|
159
|
+
All positions are **1-indexed**. File paths must be **absolute**.
|
|
160
|
+
|
|
161
|
+
PIDE tools (goal, command_output) are best-effort wrappers around async PIDE notifications and may time out.
|
|
162
|
+
|
|
163
|
+
## Development
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
pip install -e ".[dev]" # editable install from a checkout
|
|
167
|
+
pytest # unit tests
|
|
168
|
+
pytest -m integration # requires running Isabelle
|
|
169
|
+
python -m mypy src/ # type checking
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Architecture
|
|
173
|
+
|
|
174
|
+
```
|
|
175
|
+
server.py FastMCP entry point — tool registration, lifespan
|
|
176
|
+
lsp_client.py JSON-RPC 2.0 client for isabelle vscode_server
|
|
177
|
+
tools/ Tool implementations (one file per tool)
|
|
178
|
+
utils/ Position conversion, URI handling, HTML parsing
|
|
179
|
+
models.py Pydantic output models
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## License
|
|
183
|
+
|
|
184
|
+
See LICENSE.
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# Isabelle-MCP
|
|
2
|
+
|
|
3
|
+
MCP server that lets AI agents (Claude Code, Codex, …) drive the Isabelle
|
|
4
|
+
theorem prover through its LSP/PIDE commands — fully autonomously, with no
|
|
5
|
+
human in the loop.
|
|
6
|
+
|
|
7
|
+
**Python ≥ 3.12 | v0.1.0 (MVP)**
|
|
8
|
+
|
|
9
|
+
## Purpose
|
|
10
|
+
|
|
11
|
+
This MCP server exists so that Claude / Codex can issue Isabelle LSP commands
|
|
12
|
+
**without any human mediation**. The entire Isabelle process is encapsulated
|
|
13
|
+
behind the MCP tools — it exposes **no UI to the user**. The agent works by
|
|
14
|
+
editing `.thy`/`.ML` files on disk and calling the tools to evaluate them and
|
|
15
|
+
query proof states; nobody watches or steers the prover interactively.
|
|
16
|
+
|
|
17
|
+
This server is **not designed for human–AI collaboration** (there is no
|
|
18
|
+
jEdit/VSCode front-end in the picture). It implements a single
|
|
19
|
+
AI ↔ Isabelle, no-human-in-the-loop model.
|
|
20
|
+
|
|
21
|
+
> ⚠️ **One agent per server instance.** This server holds a single Isabelle
|
|
22
|
+
> session with global mutable state — one set of open documents, one
|
|
23
|
+
> caret/perspective, and one evaluation in flight at a time. It is
|
|
24
|
+
> **single-threaded and not concurrency-safe**: pointing multiple agents at one
|
|
25
|
+
> instance, or interleaving concurrent requests, corrupts the evaluation/caret/
|
|
26
|
+
> document state with catastrophic, hard-to-debug results. The server runs over
|
|
27
|
+
> **stdio**, so each agent already gets its own dedicated server process (and its
|
|
28
|
+
> own `isabelle vscode_server`) — just don't share one or drive it concurrently.
|
|
29
|
+
|
|
30
|
+
> [!IMPORTANT]
|
|
31
|
+
> **Patch Isabelle first — this server does not work on a stock Isabelle.** It
|
|
32
|
+
> drives `isabelle vscode_server` through PIDE LSP requests
|
|
33
|
+
> (`PIDE/output_at_position`, `PIDE/cancel_execution`, …) that only exist after
|
|
34
|
+
> applying the
|
|
35
|
+
> [my-better-isabelle-prover](https://github.com/xqyww123/my_better_isabelle_prover)
|
|
36
|
+
> patches:
|
|
37
|
+
>
|
|
38
|
+
> ```bash
|
|
39
|
+
> pip install my-better-isabelle-prover # via pip or uv tool; needs Python ≥ 3.12
|
|
40
|
+
> my-better-isabelle patch # apply patches + rebuild the Scala components
|
|
41
|
+
> my-better-isabelle status # verify: every patch reports "applied"
|
|
42
|
+
> ```
|
|
43
|
+
>
|
|
44
|
+
> `isabelle-mcp install` checks this (when `isabelle` is reachable) and refuses to
|
|
45
|
+
> register the server against an unpatched Isabelle. The server re-checks at
|
|
46
|
+
> run time too: every `isabelle_launch` verifies the patches (via its bundled
|
|
47
|
+
> copy of the patch manager) and refuses to start an unpatched Isabelle —
|
|
48
|
+
> bypass with `isabelle-mcp --skip-patch-check` for hand-patched setups the
|
|
49
|
+
> patch manager cannot recognize. Compatibility notes
|
|
50
|
+
> (PEP 668, non-global Isabelle, …) are in [AGENTS.md](AGENTS.md).
|
|
51
|
+
|
|
52
|
+
## Quick Start
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install isabelle-mcp # or: uv tool install isabelle-mcp
|
|
56
|
+
|
|
57
|
+
# register into Claude Code / Codex (auto-detects whichever is installed):
|
|
58
|
+
isabelle-mcp install
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
For Claude Desktop, register manually instead
|
|
62
|
+
(`~/.config/claude/claude_desktop_config.json`):
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"mcpServers": {
|
|
67
|
+
"isabelle": {
|
|
68
|
+
"command": "isabelle-mcp"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The session/logic is **not** configured here — the agent picks it at run time by
|
|
75
|
+
calling the `isabelle_launch` tool (see Tools below).
|
|
76
|
+
|
|
77
|
+
## Running the server
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
isabelle-mcp # stdio transport (the only transport)
|
|
81
|
+
isabelle-mcp -- -o editor_output_state=true # args after `--` go to isabelle vscode_server
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
The server starts no prover at launch; the connected agent calls `isabelle_launch`
|
|
85
|
+
to start one for a chosen session.
|
|
86
|
+
|
|
87
|
+
| Flag | Default | Meaning |
|
|
88
|
+
|------|---------|---------|
|
|
89
|
+
| `install` | — | Register the server with Claude Code / Codex (see `isabelle-mcp install --help`) |
|
|
90
|
+
| `--version` | — | Print the version and exit |
|
|
91
|
+
| `--skip-patch-check` | — | Skip the my-better-isabelle-prover patch verification at session launch |
|
|
92
|
+
| `-- ...` | — | Everything after `--` is forwarded to `isabelle vscode_server` |
|
|
93
|
+
|
|
94
|
+
### Environment variables
|
|
95
|
+
|
|
96
|
+
These are read once at process startup; a connected agent cannot change them.
|
|
97
|
+
|
|
98
|
+
| Variable | Default | Effect |
|
|
99
|
+
|----------|---------|--------|
|
|
100
|
+
| `ISABELLE_MCP_EVAL_POLL_INTERVAL` | `10` | Seconds an evaluate/poll call waits before returning `in_progress` |
|
|
101
|
+
| `ISABELLE_MCP_DUMP` | unset | If set to a path, append a JSON wire-log of all LSP traffic (debugging) |
|
|
102
|
+
|
|
103
|
+
## Tools
|
|
104
|
+
|
|
105
|
+
| Tool | Description |
|
|
106
|
+
|------|-------------|
|
|
107
|
+
| `isabelle_launch` | Start (or restart) the prover with the session/logic that fits the work (bare `Main` is only a minimal fallback); **call this first** |
|
|
108
|
+
| `isabelle_terminate` | Terminate the running prover (the MCP server stays up; you can relaunch) |
|
|
109
|
+
| `isabelle_evaluate_to` | Evaluate the theory up to a line; returns a per-file snapshot of errors / warnings / running command lines |
|
|
110
|
+
| `isabelle_evaluation_status` | Poll progress of a running evaluation (same snapshot) |
|
|
111
|
+
| `isabelle_cancel_evaluation` | Cancel a running evaluation |
|
|
112
|
+
| `isabelle_hover` | Type info and documentation at position |
|
|
113
|
+
| `isabelle_definition` | Jump to symbol definition |
|
|
114
|
+
| `isabelle_local_occurrences` | In-file occurrences (definition + uses) of a local entity |
|
|
115
|
+
| `isabelle_goal` | **Proof goals** — omit after_text for before/after diff |
|
|
116
|
+
| `isabelle_command_output` | Prover output messages |
|
|
117
|
+
| `isabelle_session_info` | Current session info |
|
|
118
|
+
|
|
119
|
+
All positions are **1-indexed**. File paths must be **absolute**.
|
|
120
|
+
|
|
121
|
+
PIDE tools (goal, command_output) are best-effort wrappers around async PIDE notifications and may time out.
|
|
122
|
+
|
|
123
|
+
## Development
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
pip install -e ".[dev]" # editable install from a checkout
|
|
127
|
+
pytest # unit tests
|
|
128
|
+
pytest -m integration # requires running Isabelle
|
|
129
|
+
python -m mypy src/ # type checking
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Architecture
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
server.py FastMCP entry point — tool registration, lifespan
|
|
136
|
+
lsp_client.py JSON-RPC 2.0 client for isabelle vscode_server
|
|
137
|
+
tools/ Tool implementations (one file per tool)
|
|
138
|
+
utils/ Position conversion, URI handling, HTML parsing
|
|
139
|
+
models.py Pydantic output models
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## License
|
|
143
|
+
|
|
144
|
+
See LICENSE.
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "isabelle-mcp"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "MCP server bridging AI agents with the Isabelle proof assistant via its LSP/PIDE interface"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.12"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [
|
|
14
|
+
{name = "Qiyuan Xu", email = "xqyww123@gmail.com"}
|
|
15
|
+
]
|
|
16
|
+
keywords = ["isabelle", "theorem-prover", "mcp", "lsp", "ai-assistance"]
|
|
17
|
+
classifiers = [
|
|
18
|
+
"Development Status :: 3 - Alpha",
|
|
19
|
+
"Intended Audience :: Developers",
|
|
20
|
+
"Intended Audience :: Science/Research",
|
|
21
|
+
"Topic :: Scientific/Engineering :: Mathematics",
|
|
22
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
23
|
+
"Programming Language :: Python :: 3",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Programming Language :: Python :: 3.13",
|
|
26
|
+
"Typing :: Typed",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
dependencies = [
|
|
30
|
+
"beautifulsoup4>=4.12.0",
|
|
31
|
+
"fastmcp>=3.2,<4",
|
|
32
|
+
"mcp>=1.0.0",
|
|
33
|
+
"my-better-isabelle-prover>=0.1.0",
|
|
34
|
+
"pydantic>=2.0.0",
|
|
35
|
+
"watchdog>=3.0.0",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[project.optional-dependencies]
|
|
39
|
+
dev = [
|
|
40
|
+
"coverage>=7.0.0",
|
|
41
|
+
"pytest>=7.0.0",
|
|
42
|
+
"pytest-asyncio>=0.21.0",
|
|
43
|
+
"pytest-cov>=7.0.0",
|
|
44
|
+
"mypy>=1.0.0",
|
|
45
|
+
"black>=23.0.0",
|
|
46
|
+
"ruff>=0.1.0",
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
[project.urls]
|
|
50
|
+
Homepage = "https://github.com/xqyww123/Isabelle-MCP"
|
|
51
|
+
Documentation = "https://github.com/xqyww123/Isabelle-MCP/tree/main/docs"
|
|
52
|
+
Repository = "https://github.com/xqyww123/Isabelle-MCP"
|
|
53
|
+
Issues = "https://github.com/xqyww123/Isabelle-MCP/issues"
|
|
54
|
+
Changelog = "https://github.com/xqyww123/Isabelle-MCP/blob/main/CHANGELOG.md"
|
|
55
|
+
|
|
56
|
+
[project.scripts]
|
|
57
|
+
isabelle-mcp = "isabelle_mcp.server:main"
|
|
58
|
+
|
|
59
|
+
[tool.setuptools.dynamic]
|
|
60
|
+
version = {attr = "isabelle_mcp.__version__"}
|
|
61
|
+
|
|
62
|
+
[tool.setuptools.packages.find]
|
|
63
|
+
where = ["src"]
|
|
64
|
+
|
|
65
|
+
[tool.setuptools.package-data]
|
|
66
|
+
isabelle_mcp = ["py.typed"]
|
|
67
|
+
|
|
68
|
+
[tool.black]
|
|
69
|
+
line-length = 100
|
|
70
|
+
target-version = ["py312", "py313"]
|
|
71
|
+
include = '\.pyi?$'
|
|
72
|
+
extend-exclude = '''
|
|
73
|
+
/(
|
|
74
|
+
# directories
|
|
75
|
+
\.eggs
|
|
76
|
+
| \.git
|
|
77
|
+
| \.mypy_cache
|
|
78
|
+
| \.pytest_cache
|
|
79
|
+
| \.venv
|
|
80
|
+
| build
|
|
81
|
+
| dist
|
|
82
|
+
)/
|
|
83
|
+
'''
|
|
84
|
+
|
|
85
|
+
[tool.mypy]
|
|
86
|
+
python_version = "3.12"
|
|
87
|
+
warn_return_any = true
|
|
88
|
+
warn_unused_configs = true
|
|
89
|
+
disallow_untyped_defs = true
|
|
90
|
+
disallow_incomplete_defs = true
|
|
91
|
+
check_untyped_defs = true
|
|
92
|
+
disallow_untyped_calls = true
|
|
93
|
+
disallow_untyped_decorators = false
|
|
94
|
+
no_implicit_optional = true
|
|
95
|
+
warn_redundant_casts = true
|
|
96
|
+
warn_unused_ignores = true
|
|
97
|
+
warn_no_return = true
|
|
98
|
+
strict_equality = true
|
|
99
|
+
|
|
100
|
+
[tool.ruff]
|
|
101
|
+
line-length = 100
|
|
102
|
+
target-version = "py312"
|
|
103
|
+
|
|
104
|
+
[tool.ruff.lint]
|
|
105
|
+
select = [
|
|
106
|
+
"E", # pycodestyle errors
|
|
107
|
+
"W", # pycodestyle warnings
|
|
108
|
+
"F", # pyflakes
|
|
109
|
+
"I", # isort
|
|
110
|
+
"B", # flake8-bugbear
|
|
111
|
+
"C4", # flake8-comprehensions
|
|
112
|
+
"UP", # pyupgrade
|
|
113
|
+
]
|
|
114
|
+
ignore = [
|
|
115
|
+
"E501", # line too long (handled by black)
|
|
116
|
+
"B008", # do not perform function calls in argument defaults
|
|
117
|
+
]
|
|
118
|
+
|
|
119
|
+
[tool.pytest.ini_options]
|
|
120
|
+
testpaths = ["tests"]
|
|
121
|
+
python_files = ["test_*.py"]
|
|
122
|
+
python_classes = ["Test*"]
|
|
123
|
+
python_functions = ["test_*"]
|
|
124
|
+
asyncio_mode = "auto"
|
|
125
|
+
markers = [
|
|
126
|
+
"integration: marks tests as integration tests (deselect with '-m \"not integration\"')",
|
|
127
|
+
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
|
|
128
|
+
]
|