leanforge-mcp AGENTS.md

Repository instructions for leanforge-mcp, a Python server that runs parallel agents to find machine-checked Lean 4 proofs. They describe its technology stack, folder layout, and rules for running Lean.

In plain words
What is it for?
Use them when developing leanforge-mcp, especially its proof-search loop, job queue, Lean compiler wrapper, server tools, tests, and configuration.
Why use it?
They help coding agents locate the right files and follow the project’s requirements for testing, configuration, persistence, and subprocesses. This reduces guesswork when modifying the server.

Instructions file for CodexOpenCode

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/sandraschi/leanforge-mcp/agents-md
Clone the repo
git clone --depth 1 https://github.com/sandraschi/leanforge-mcp

Made for: Codex, OpenCode.

Per session 1,078 This file is loaded in full into every session.
When invoked 1,078 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.01078 $0.01078
Opus 5 $0.00539 $0.00539
Sonnet 5 $0.00216 $0.00216
Haiku 4.5 $0.00108 $0.00108

Measured yesterday against content hash 4186cb9cc31c, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

leanforge-mcp AGENTS.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

AGENTS.md · 110 lines

How it starts

The opening of the file, as written. The whole thing — 110 lines — stays where its author put it; the contents beside it link to each section on GitHub.

AGENTS.md -- leanforge-mcp

Agent protocols for Cursor, Windsurf, Claude Code, and any agentic IDE working in this repo.

Stack

  • Language: Python 3.11+, FastMCP >= 3.2.0
  • Package manager: uv
  • Lean: Lean 4 via elan, Mathlib4
  • Config: TOML via tomllib (stdlib, Python 3.11+)
  • Persistence: SQLite via aiosqlite
  • Linting: Ruff (formatter + linter)
  • Tests: pytest + pytest-asyncio

Repo layout

leanforge-mcp\
├── src\
│   ├── core\
│   │   ├── agent.py        # Subagent loop: LLM propose → Lean compile → repeat
│   │   ├── config.py       # TOML config loader + dataclasses
│   │   ├── job_manager.py  # SQLite job queue, status tracking
│   │   ├── lean_client.py  # Lean 4 subprocess wrapper
│   │   └── llm_client.py   # Multi-tier LLM client (Ollama / OpenAI-compat / Anthropic)
│   ├── tools\
│   │   ├── submit.py       # submit_theorem, submit_lean_file
│   │   ├── status.py       # get_proof_status, list_attempts, list_jobs, validate_lean
│   │   ├── control.py      # cancel_job
│   │   └── mathlib.py      # get_mathlib_search
│   ├── lean\
│   │   └── templates\      # .lean file templates for common theorem shapes
│   └── server.py           # FastMCP server entry point + main()
├── tests\
│   └── test_pipeline.py    # End-to-end pipeline tests
├── docs\
│   ├── ARCHITECTURE.md
│   ├── LEAN_PRIMER.md
│   └── BENCHMARK_RESULTS.md
├── data\                   # SQLite DB lives here (gitignored)
├── logs\                   # Log files (gitignored)
├── workspace\              # Temp Lean files per job (gitignored)
├── config.example.toml
├── config.toml             # Local config (gitignored)
├── pyproject.toml
├── start.ps1
├── glama.json
├── llms.txt
├── AGENTS.md
├── CLAUDE.md
└── README.md

Critical rules

Lean subprocess

  • lean_client.py shells out via asyncio.create_subprocess_exec -- never shell=True
  • Lean path must come from config; never hardcode
  • Capture both stdout and stderr; Lean emits errors to stderr
  • Timeout every compile call (default 30s); Lean can hang on malformed input
  • lean --stdin is faster than lake build for single-theorem proofs -- use it

Read the full file on GitHub · 110 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 110 lines · 1,078 tokens per session scan A 4186cb9cc31c

Subscribe to this mod's changes

leanforge-mcp AGENTS.md is an instructions file published in the GitHub repository sandraschi/leanforge-mcp (0 stars, last pushed yesterday), licensed MIT. It adds 1,078 tokens to every session, about $0.0054 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.