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)
MCP server for recursive LLM reasoning over documents. Instead of cramming context into one prompt, the model iteratively explores with search, code execution, and structured thinking—converging on answers with citations.
Quick Start
pip install aleph-rlm[mcp]
aleph-rlm install # auto-detects Claude Desktop, Cursor, Windsurf, VS Code
aleph-rlm doctor # verify installation
Manual configuration
Add to your MCP client config:
{
"mcpServers": {
"aleph": {
"command": "aleph-mcp-local"
}
}
}
How It Works
CONTEXT (stored in REPL as `ctx`)
│
▼
┌───────────────┐ ┌───────────────┐ ┌───────────────┐
│ LOAD │────▶│ EXPLORE │────▶│ CITE │
│ Store once │ │ search/peek/ │ │ Evidence │
│ in sandbox │ │ chunk/exec │ │ accumulates │
└───────────────┘ └───────────────┘ └───────┬───────┘
▲ │
│ ┌───────────┐ │
└────│ EVALUATE │◀───┘
│ progress │
└───────────┘
│
┌─────────┴─────────┐
▼ ▼
Continue Finalize
(with citations)
The model sees metadata about context, not the full text. It writes Python to explore what it needs, refining searches based on what it learns. Evidence auto-accumulates.
Example
You: Load this contract and find all liability exclusions
[AI calls load_context, search_context, cite(), evaluate_progress, finalize]
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]
When to Use
| Use Aleph | Skip Aleph |
|---|---|
| Long documents (>10 pages) | Short docs (<30k tokens) |
| Need regex search | Simple lookups |
| Need computation on extracted data | Latency-critical apps |
| Want citations with line numbers | |
| Iterative analysis across turns |
MCP Tools Reference
| 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 (80+ functions available in exec_python)
Core:
peek, lines, search, chunk, cite
Extraction (auto-detect from context):
extract_numbers, extract_money, extract_percentages, extract_dates, extract_times, extract_timestamps, extract_emails, extract_urls, extract_ips, extract_phones, extract_paths, extract_env_vars, extract_versions, extract_uuids, extract_hashes, extract_hex
Code analysis:
extract_functions, extract_classes, extract_imports, extract_comments, extract_strings, extract_todos
Log analysis:
extract_log_levels, extract_exceptions, extract_json_objects
Statistics:
word_count, char_count, line_count, sentence_count, paragraph_count, unique_words, word_frequency, ngrams
Line operations (grep-like):
head, tail, grep, grep_v, grep_c, uniq, sort_lines, number_lines, strip_lines, blank_lines, non_blank_lines, columns
Text manipulation:
replace_all, split_by, between, before, after, truncate, wrap_text, indent_text, dedent_text, normalize_whitespace, remove_punctuation, to_lower, to_upper, to_title
Pattern matching:
contains, contains_any, contains_all, count_matches, find_all, first_match
Comparison:
diff, similarity, common_lines, diff_lines
Collections:
dedupe, flatten, first, last, take, drop, partition, group_by, frequency, sample_items, shuffle_items
Validation:
is_numeric, is_email, is_url, is_ip, is_uuid, is_json, is_blank
Conversion:
to_json, from_json, to_csv_row, from_csv_row, to_int, to_float, to_snake_case, to_camel_case, to_pascal_case, to_kebab_case, slugify
# Examples
emails = extract_emails() # Auto-extracts from ctx
money = extract_money() # Finds $1,234.56 patterns
errors = grep("ERROR") # Filter lines
word_frequency(top_n=10) # Most common words
Sandbox Builtins
Types: bool, int, float, str, dict, list, set, tuple, type, frozenset, bytes, bytearray, complex, slice, object
Functions: len, range, enumerate, zip, map, filter, iter, next, callable, min, max, sum, sorted, reversed, any, all, abs, round, pow, divmod, repr, ascii, chr, ord, format, hex, oct, bin, print, isinstance, issubclass, hash, id
Exceptions: Exception, ValueError, TypeError, RuntimeError, KeyError, IndexError, ZeroDivisionError, NameError, AttributeError, StopIteration, AssertionError, LookupError, ArithmeticError, UnicodeError
Imports: re, json, csv, math, statistics, collections, itertools, functools, datetime, textwrap, difflib, random, string, hashlib, base64, urllib.parse, html
Configuration
Environment Variables:
| Variable | Purpose |
|---|---|
ALEPH_MAX_ITERATIONS |
Iteration limit |
ALEPH_MAX_COST |
Cost limit in USD |
CLI Commands:
aleph-rlm install # Interactive installer
aleph-rlm install <client> # Install to specific client
aleph-rlm uninstall <client> # Remove from client
aleph-rlm doctor # Verify installation
Supported clients: claude-desktop, cursor, windsurf, vscode, claude-code
Security
The sandbox is best-effort, not hardened.
Blocked: open, os, subprocess, socket, eval, exec, dunder access, imports outside allowlist
For production: Run in a container with resource limits. Do not expose to untrusted users without additional isolation.
Development
git clone https://github.com/Hmbown/aleph.git
cd aleph
pip install -e '.[dev,mcp]'
pytest # 190 tests
Recent Changes
v0.2.0 (December 2025)
80+ new REPL helpers for document analysis:
- 16 extraction functions (emails, IPs, money, dates, phones, URLs, paths, versions, UUIDs, functions, classes, TODOs, log levels)
- 8 statistics (word/line/char count, word frequency, n-grams)
- 12 grep-like line operations (head, tail, grep, sort, uniq, columns)
- 15 text manipulation (replace, split, before/after, truncate, normalize)
- 6 pattern matching (contains, count_matches, find_all)
- 4 comparison (diff, similarity)
- 11 collection utilities (dedupe, flatten, group_by, frequency)
- 7 validators (is_email, is_url, is_ip, is_uuid, is_json)
- 11 converters (to_json, to_snake_case, slugify)
30+ new builtins: map, filter, iter, next, repr, chr, ord, pow, divmod, hash, id, callable, frozenset, bytes, slice...
6 new allowed imports: random, string, hashlib, base64, urllib.parse, html
v0.1.3 (December 2025)
- Added
typebuiltin to sandbox - Added
NameErrorandAttributeErrorexceptions
Research
Inspired by Recursive Language Models by Alex Zhang and Omar Khattab.
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.2.0.tar.gz.
File metadata
- Download URL: aleph_rlm-0.2.0.tar.gz
- Upload date:
- Size: 72.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c2a28d1cce5078e1b36de80e0a801f6b9927a8a2eeb0a5f1f76e6bf37f1550d
|
|
| MD5 |
9fe87eb3aaf872cdcfd8d6eb79bdeffb
|
|
| BLAKE2b-256 |
c75e476a063a6cbc0cdd708c68544a4503731be9d890fd58d98ca973462dca99
|
Provenance
The following attestation bundles were made for aleph_rlm-0.2.0.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.2.0.tar.gz -
Subject digest:
7c2a28d1cce5078e1b36de80e0a801f6b9927a8a2eeb0a5f1f76e6bf37f1550d - Sigstore transparency entry: 766038683
- Sigstore integration time:
-
Permalink:
Hmbown/aleph@d5cfbf730c889c59a70bee6a7fe274eedac9ff24 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Hmbown
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d5cfbf730c889c59a70bee6a7fe274eedac9ff24 -
Trigger Event:
release
-
Statement type:
File details
Details for the file aleph_rlm-0.2.0-py3-none-any.whl.
File metadata
- Download URL: aleph_rlm-0.2.0-py3-none-any.whl
- Upload date:
- Size: 62.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 |
89beb764b9878622c1c348dcf7c4dd68c01fca5d4d230b1b5bb68e911c7d9561
|
|
| MD5 |
f81bc1773cb36e8e856ce613a95383e2
|
|
| BLAKE2b-256 |
3140c1ce736f2814f774ef37516658cada9211af27d4b3f6fc433cb4fc14b846
|
Provenance
The following attestation bundles were made for aleph_rlm-0.2.0-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.2.0-py3-none-any.whl -
Subject digest:
89beb764b9878622c1c348dcf7c4dd68c01fca5d4d230b1b5bb68e911c7d9561 - Sigstore transparency entry: 766038709
- Sigstore integration time:
-
Permalink:
Hmbown/aleph@d5cfbf730c889c59a70bee6a7fe274eedac9ff24 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Hmbown
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d5cfbf730c889c59a70bee6a7fe274eedac9ff24 -
Trigger Event:
release
-
Statement type: