1. Conduid
  2. AI
  3. Lean4 MCP
MCP server · AI

Lean4 MCP

A lightweight MCP (Model Context Protocol) server that proxies between AI agents and the Lean 4 language server.

Unclaimed last commit 7 months ago ai
34Low

Scored 7 months ago · breakdown

About Lean4 MCP

Lean4 MCP is an MCP server published by RIvance in the AI category: a lightweight MCP (Model Context Protocol) server that proxies between AI agents and the Lean 4 language server.

The repository has 8 stars and 2 forks, with the last commit 7 months ago. Six months or more without a commit doesn't mean the server is broken, but check the open issues before depending on it in production.

Install

From source
git clone https://github.com/RIvance/lean4-mcp

This server has no ConduID identity, so agent calls to it are not receipted. Pin the version you install and review the source before granting it credentials.

Tools (10)

apply_editApply a targeted range edit

Parameters not published.

close_documentClose a document and free resources

Parameters not published.

file_statusCheck if Lean is still processing a file

Parameters not published.

get_diagnosticsGet compilation errors/warnings (waits for Lean to finish)

Parameters not published.

get_document_textRead current document content

Parameters not published.

get_goal_stateQuery tactic proof state at a position

Parameters not published.

list_documentsList all open documents across all workspaces

Parameters not published.

open_documentOpen a file by URI + text content

Parameters not published.

open_fileOpen a `.lean` file from disk by path (auto-detects Lake workspace)

Parameters not published.

replace_documentReplace entire file content

Parameters not published.

Ask AI

✦

Ask AI about Lean4 MCP

Powered by Claude · Grounded in docs

I know everything about Lean4 MCP. Ask me about installation, configuration, usage, or troubleshooting.

Security checks

  • ✓README presentThe repository ships documentation.

5 checks have not been run yet.

README

lean4-mcp-proxy

An MCP (Model Context Protocol) server that proxies between AI agents and the Lean 4 language server. It lets agents open Lean files, check for errors, inspect proof goals, and edit documents through the standard MCP tool-calling interface.

Inspired by vsrocq-mcp (PR#1194), an MCP server patch for the Rocq prover, originally authored by Kacper Korban and available at cu1ch3n/vsrocq-mcp.

:warning: Platform support: Tested on Linux. Windows and macOS support is not guaranteed.

Features

  • Open files from disk or memory, with automatic Lake workspace detection
  • Get diagnostics (errors, warnings) after Lean finishes type-checking
  • Query proof goals at any cursor position inside a tactic block
  • Edit documents — full replacement or targeted range edits

Tools

Tool Description
open_file Open a .lean file from disk by path (auto-detects Lake workspace)
open_document Open a file by URI + text content
get_diagnostics Get compilation errors/warnings (waits for Lean to finish)
get_goal_state Query tactic proof state at a position
replace_document Replace entire file content
apply_edit Apply a targeted range edit
get_document_text Read current document content
close_document Close a document and free resources
file_status Check if Lean is still processing a file
list_documents List all open documents across all workspaces

Prerequisites

  • Rust (edition 2021+)
  • Lean 4 (lean on PATH)
  • Lake (lake on PATH, included with Lean 4) — only needed for Lake projects

Build

cargo build --release

The binary is at target/release/lean4-mcp-proxy.

Usage

VS Code / Cursor Setup

Step 1: Build the MCP Server

cargo build --release

The binary will be at target/release/lean4-mcp-proxy.

Step 2: Configure MCP Settings

For VS Code with Cline/Roo-Cline:

  1. Open VS Code settings (Cmd/Ctrl + ,)
  2. Search for "MCP" or navigate to your MCP extension settings
  3. Add the server configuration to your MCP settings file (usually .vscode/mcp.json or global settings):
{
  "mcpServers": {
    "lean4-mcp": {
      "command": "/absolute/path/to/lean4-mcp-proxy",
      "args": []
    }
  }
}

For Cursor:

  1. Open Cursor Settings → Features → Model Context Protocol
  2. Add a new MCP server with:
    • Name: lean4-mcp
    • Command: /absolute/path/to/lean4-mcp-proxy
    • Args: (leave empty for auto-detection)

Step 3: Verify Installation

After restarting your editor, the MCP server should appear in your MCP tools list. You can verify by:

  1. Opening a Lean 4 file (.lean)
  2. Asking your AI assistant to "list available MCP tools"
  3. You should see tools like open_file, get_diagnostics, get_goal_state, etc.

Step 4: Using with Lake Projects

Lake workspaces are auto-detected from lakefile.lean when you open a file. For a default project, use:

{
  "mcpServers": {
    "lean4-mcp": {
      "command": "/absolute/path/to/lean4-mcp-proxy",
      "args": ["--lake-project", "/path/to/your/lake/project"]
    }
  }
}

Environment variables

Variable Description
LAKE_PROJECT Default Lake project root (alternative to --lake-project)
LEAN_BIN Custom path to lean binary
LAKE_BIN Custom path to lake binary
RUST_LOG Log level (info, debug, trace) — logs go to stderr

Protocol

Communicates over stdio using newline-delimited JSON-RPC (MCP protocol version 2024-11-05). The proxy translates MCP tool calls into LSP requests to the Lean 4 language server.

README copy captured when this server was indexed; it may lag the repository. The original is authoritative.

Questions

About Lean4 MCP

How do I install Lean4 MCP?

No package has been published for this server, so install it from source: clone the repository and follow its README.

Is Lean4 MCP safe to use with an AI agent?

Its trust score is 34 out of 100 (low). It passes 1 of the 1 static security checks run so far. It has no ConduID identity yet, so agent calls to it are not receipted.

Is Lean4 MCP still maintained?

The last commit was 7 months ago. That's long enough that you should check whether the maintainer is responding to issues before depending on it.