This guide helps you quickly set up a Lean + Claude Code development environment.
git clone https://github.com/project-numina/numina-lean-agent
cd numina-lean-agent/tutorial
./setup.sh myprojectSee setup.sh for details.
# Install elan
curl https://elan.lean-lang.org/elan-init.sh -sSf | sh
# Refresh your shell environment
source ~/.elan/env
# Create Lean project
lake new myproject math && cd myproject
lake update && lake exe cache get && lake build
# Install Claude Code
curl -fsSL https://claude.ai/install.sh | bash
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
# Restart your terminal (or `source ~/.bashrc` / `source ~/.zshrc`, depending on your shell)
# Setup lean-lsp-mcp
git clone https://github.com/project-numina/lean-lsp-mcp ~/lean-lsp-mcp
chmod +x ~/lean-lsp-mcp/numina-lean-mcp.sh
# Add MCP (run from your project directory!)
cd myproject
claude mcp add lean-lsp -- ~/lean-lsp-mcp/numina-lean-mcp.sh
# Verify
claude mcp listEnsure git and curl are installed:
git --version
curl --versionIf not installed, use your system's package manager to install them first.
You can find the official installation guide here, or follow the steps below.
Run the following command to install elan, the Lean version manager:
curl https://elan.lean-lang.org/elan-init.sh -sSf | shAfter installation, refresh your environment:
source ~/.elan/env # loads Lean into your PATHOr restart your terminal.
Verify: Run
lean --versionto confirm installation.
lake new myproject math
cd myproject
lake update
lake exe cache get
lake buildNote: The
mathtemplate automatically configures Mathlib dependencies.lake exe cache getdownloads pre-compiled caches to speed up the first build.
Option 1: Using npm
npm install -g @anthropic-ai/claude-codeOption 2: Using install script (no npm required)
curl -fsSL https://claude.ai/install.sh | bashMore info: Claude Code Official Documentation
curl -LsSf https://astral.sh/uv/install.sh | shRestart your terminal or run source ~/.bashrc after installation.
If you're using zsh, run source ~/.zshrc instead.
# Clone the repository
git clone https://github.com/project-numina/lean-lsp-mcp
cd lean-lsp-mcp
# Add execute permission
chmod +x numina-lean-mcp.shIMPORTANT: MCP configuration is directory-specific. The MCP server is registered for the directory where you run the
claude mcp addcommand. You must run this command from your Lean project directory (or a parent directory) for the MCP to be available when working on that project.
Replace the path with your actual absolute path:
# Navigate to your Lean project first
cd /path/to/myproject
# Then add the MCP server
claude mcp add lean-lsp -- /absolute/path/to/lean-lsp-mcp/numina-lean-mcp.shExample:
cd ~/myproject
claude mcp add lean-lsp -- /home/username/lean-lsp-mcp/numina-lean-mcp.shTip: To make the MCP available globally (for all projects), run the command from your home directory (
~) or use the--scope userflag.
claude mcp listExpected output:
Checking MCP server health...
lean-lsp: /home/username/lean-lsp-mcp/numina-lean-mcp.sh - ✓ Connected
Issue: Shows uvx lean-lsp-mcp instead of custom path
This means the official version was installed instead of the project version. Remove and re-add:
claude mcp remove lean-lsp
claude mcp add lean-lsp -- /absolute/path/to/lean-lsp-mcp/numina-lean-mcp.shIssue: lake command not found or fails
This usually means ~/.elan/env is not sourced in your PATH. Add the following to your shell configuration file (~/.bashrc or ~/.zshrc):
source ~/.elan/envThen restart your terminal or run:
source ~/.elan/envIssue: Connection failed (Failed to connect)
- Verify the path is correct
- Ensure the file has execute permission:
chmod +x numina-lean-mcp.sh - Check the log file:
cat /path/to/lean-lsp-mcp/mcp_lean_lsp.log - Confirm uv is properly installed:
uv --version
Issue: MCP not showing when running Claude Code
The MCP configuration is tied to the directory where it was added. Make sure you:
- Added the MCP from your project directory (or a parent directory)
- Are running
claudefrom the same project directory
To check where your MCP is configured:
claude mcp listRun the following commands inside Claude Code:
/plugin marketplace add cameronfreer/lean4-skills
/plugin install lean4-theorem-proving # Core skill
/plugin install lean4-memories # Optional: memory featureMore info: lean4-skills GitHub
Navigate to your Lean project directory and start Claude Code:
cd myproject
claudeTest inside Claude Code:
- Type
/mcpto check MCP connection status - Try asking Claude to analyze or write Lean code