MCP server for recursive LLM reasoning—load context, iterate with search/code/think tools, converge on answers
Project description
Aleph
"What my eyes beheld was simultaneous, but what I shall now write down will be successive, because language is successive."
— Jorge Luis Borges, "The Aleph" (1945)
Aleph is an MCP server for recursive LLM reasoning over documents. Instead of cramming context into a single prompt, the model iteratively explores it with search, code execution, and structured thinking tools—converging on answers with full provenance.
The Problem
Single-pass document analysis fails at scale:
- Context limits: Large documents exceed context windows
- Attention dilution: Important details get lost in noise
- No audit trail: You can't see how the model reached its conclusion
- Wasted tokens: The entire document is processed even when only fragments matter
The Solution
Recursive exploration with provenance tracking:
CONTEXT (stored in REPL as `ctx`)
│
▼
┌───────────────┐ ┌───────────────┐ ┌───────────────┐
│ LOAD │────▶│ EXPLORE │────▶│ CITE │
│ Store once │ │ search/peek/ │ │ Evidence │
│ in sandbox │ │ chunk/exec │ │ accumulates │
└───────────────┘ └───────────────┘ └───────┬───────┘
▲ │
│ ┌───────────┐ │
└────│ EVALUATE │◀───┘
│ progress │
└───────────┘
│ │
Low High
│ │
▼ ▼
Continue Finalize
(with citations)
The model sees metadata about the context, not the full text. It writes Python code to explore what it needs, when it needs it. Evidence auto-accumulates. Final answers include citations.
Quick Start
MCP Setup (Claude Desktop, Cursor, etc.)
pip install aleph-rlm
Add to Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"aleph": {
"command": "aleph-mcp-local"
}
}
}
Then use it:
You: Load this contract and find all liability exclusions
[AI calls load_context with document]
[AI calls search_context for "liab", "exclus", "indemnif"]
[AI calls cite() to tag key clauses]
[AI calls evaluate_progress → confidence 0.85]
[AI calls finalize with citations]
AI: Found 3 liability exclusions:
1. Section 4.2: Consequential damages excluded (lines 142-158)
2. Section 7.1: Force majeure carve-out (lines 289-301)
3. Section 9.3: Cap at contract value (lines 445-452)
Evidence: [4 citations with line ranges]
Python API
from aleph import Aleph, Budget
aleph = Aleph(
provider="anthropic",
root_model="claude-sonnet-4-20250514",
budget=Budget(max_cost_usd=1.0, max_iterations=20),
)
resp = await aleph.complete(
query="What are the key risks?",
context=large_document,
)
print(resp.answer)
print(f"Cost: ${resp.total_cost_usd:.4f}")
print(f"Iterations: {resp.total_iterations}")
MCP Tools
| Tool | Purpose |
|---|---|
load_context |
Store document in sandboxed REPL as ctx |
peek_context |
View character or line ranges |
search_context |
Regex search with evidence logging |
exec_python |
Run code against context (includes cite() helper) |
chunk_context |
Split into navigable chunks with metadata |
think |
Structure reasoning sub-steps |
evaluate_progress |
Check confidence and convergence |
get_evidence |
Retrieve citation trail with filtering |
get_status |
Session state and metrics |
summarize_so_far |
Compress history to manage context |
finalize |
Complete with answer and citations |
REPL Helpers
Available inside exec_python:
| Helper | Usage |
|---|---|
peek(start, end) |
View character range |
lines(start, end) |
View line range |
search(pattern, context_lines=2) |
Regex search |
chunk(size, overlap=0) |
Split into chunks |
cite(snippet, line_range, note) |
Tag evidence with provenance |
Why It Works
| Problem | Single-Pass | Aleph |
|---|---|---|
| Large documents | Truncate or summarize | Load once, explore iteratively |
| Finding specifics | Scan everything | Targeted search |
| Verification | Trust the output | Evidence with line numbers |
| Context limits | Hit the wall | Only fetch what's needed |
| Audit trail | None | Full citation history |
Provenance Tracking
Every exploration action is logged:
search_contextmatches record pattern and line rangescite()lets you tag findings with notesget_evidenceretrieves the full trail (filterable by source)finalizeincludes citations automatically
This makes Aleph suitable for auditable analysis: legal research, compliance review, technical due diligence.
Installation
pip install aleph-rlm
Optional extras:
pip install aleph-rlm[mcp] # MCP server support
pip install aleph-rlm[yaml] # YAML config files
pip install aleph-rlm[rich] # Better logging
For development:
git clone https://github.com/Hmbown/aleph.git
cd aleph
pip install -e '.[dev,mcp]'
pytest # 190 tests
Security
The sandbox is best-effort, not hardened.
Blocked: open, os, subprocess, socket, eval, exec, dunder access, imports outside allowlist
Allowed imports: re, json, csv, math, statistics, collections, itertools, functools, datetime, textwrap, difflib
For production: Run in a container with resource limits. Do not expose to untrusted users without additional isolation.
Configuration
Environment Variables
| Variable | Purpose |
|---|---|
ANTHROPIC_API_KEY |
Anthropic API (for Python API mode) |
OPENAI_API_KEY |
OpenAI API (for Python API mode) |
ALEPH_MAX_ITERATIONS |
Iteration limit |
ALEPH_MAX_COST |
Cost limit in USD |
MCP Server Options
aleph-mcp-local --timeout 30 --max-output 10000
Recent Changes
v0.1.1 (December 2025)
- Initial public release
- 12 MCP tools for recursive reasoning
- Provenance tracking with
cite()andget_evidence - Convergence metrics in
evaluate_progress - Session compression with
summarize_so_far - 190 tests passing
Research
Inspired by work on Recursive Language Models by Alex Zhang and Omar Khattab at MIT.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aleph_rlm-0.1.1.tar.gz.
File metadata
- Download URL: aleph_rlm-0.1.1.tar.gz
- Upload date:
- Size: 57.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
409087d2da441beb0233639a6ec90aec6c75f9f4892e541e01c5bd565b5d510a
|
|
| MD5 |
fc4097737a1e5f9d9731e500076e3a98
|
|
| BLAKE2b-256 |
1bb9861a3f689d28ed6a9684facf81468db08c60606c63fd6b6df38988270eba
|
Provenance
The following attestation bundles were made for aleph_rlm-0.1.1.tar.gz:
Publisher:
publish.yml on Hmbown/aleph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aleph_rlm-0.1.1.tar.gz -
Subject digest:
409087d2da441beb0233639a6ec90aec6c75f9f4892e541e01c5bd565b5d510a - Sigstore transparency entry: 765438397
- Sigstore integration time:
-
Permalink:
Hmbown/aleph@0aeed3aa50670354027221b404e756a487163d04 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Hmbown
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0aeed3aa50670354027221b404e756a487163d04 -
Trigger Event:
release
-
Statement type:
File details
Details for the file aleph_rlm-0.1.1-py3-none-any.whl.
File metadata
- Download URL: aleph_rlm-0.1.1-py3-none-any.whl
- Upload date:
- Size: 48.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4082a4c00ba73f2436fb951f5d4c4b71a6c5c3f9a0c33cab314ebff1564acbf
|
|
| MD5 |
08905195059d9a9dfbca31bdc92d658f
|
|
| BLAKE2b-256 |
6a975f6c578cb4bb767fc928032ebfe4a2075d186c3ed175f4c7eaa908028790
|
Provenance
The following attestation bundles were made for aleph_rlm-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on Hmbown/aleph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aleph_rlm-0.1.1-py3-none-any.whl -
Subject digest:
c4082a4c00ba73f2436fb951f5d4c4b71a6c5c3f9a0c33cab314ebff1564acbf - Sigstore transparency entry: 765438420
- Sigstore integration time:
-
Permalink:
Hmbown/aleph@0aeed3aa50670354027221b404e756a487163d04 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Hmbown
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0aeed3aa50670354027221b404e756a487163d04 -
Trigger Event:
release
-
Statement type: