RLM-MCP
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@RLM-MCP Load project docs and search for 'recursive language model'"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
RLM-MCP: Recursive Language Model Server for Claude Code
Status: ✅ v0.2.2 - Production-Ready for Team Environments
A Model Context Protocol (MCP) server implementing the Recursive Language Model pattern from Zhang et al. (2025), enabling LLMs to process arbitrarily long contexts by treating prompts as external environment objects.
What's New in v0.2.x:
v0.2.2: Exact BM25 doc_ids filtering • Highlight bounds clamping • Server config defaults • Budget exemption for session.close
v0.2.1: Atomic budget enforcement • chunk_index persistence • Truncation warnings • Error message improvements
v0.2.0: Persistent indexes • Concurrent session safety • Structured logging • Batch document loading (2-3x faster)
Key Insight
Long prompts should not be fed into the neural network directly but should instead be treated as part of the environment that the LLM can symbolically interact with.
Related MCP server: MCP-RLM
Features
Core Capabilities
Session-based document management — Load files, directories, or inline content with batch processing
On-demand chunking — Fixed, line-based, or delimiter-based strategies with intelligent caching
BM25 search — Lazy-built, persistently cached, survives server restarts
Artifact storage — Store derived results with complete span provenance
Production Features (v0.2.0)
Persistent indexes — BM25 indexes saved to disk with atomic writes and corruption recovery
Concurrent session safety — Per-session locks prevent race conditions in multi-user environments
Structured logging — JSON output with correlation IDs for production observability
Batch document loading — Concurrent file loading with memory-bounded semaphores (2-3x faster)
Status & Validation
v0.2.2 production-ready validation:
✅ 103/103 tests passing (100% functionality + production features)
✅ All 13 core tools implemented with canonical naming
✅ MCP protocol integration confirmed with real clients
✅ Large corpus tested — 1M+ chars loaded and indexed
✅ Performance validated — Sub-second searches, <100ms index loads from disk
✅ Concurrency tested — 50 concurrent operations, no race conditions
✅ Memory safety — Bounded semaphores prevent OOM on large batches
✅ Production logging — JSON structured logs with correlation tracking
Test Coverage
Error handling: 13 tests
Concurrency safety: 9 tests
Index persistence: 10 tests
Integration workflows: 14 tests
Large corpus performance: 5 tests
Structured logging: 13 tests
Batch loading: 7 tests
Provenance tracking: 8 tests
Storage layer: 11 tests
v0.2.2 bug fixes: 13 tests
See MIGRATION_v0.1_to_v0.2.md for upgrade guide.
Installation
pip install rlm-mcpOr with development dependencies:
pip install rlm-mcp[dev]Quick Start
from rlm_mcp import run_server
# Start the MCP server
run_server()Tools
All tools use canonical naming: rlm.<category>.<action>
Category | Tools |
|
|
|
|
|
|
|
|
|
|
|
|
Workflow Pattern
Initialize:
rlm.session.createwith configLoad:
rlm.docs.loaddocumentsProbe:
rlm.docs.peekat structureSearch:
rlm.search.queryto find relevant sectionsChunk:
rlm.chunk.createwith appropriate strategyProcess:
rlm.span.get+ client subcallsStore:
rlm.artifact.storeresults with provenanceClose:
rlm.session.close
Configuration
Configuration file: ~/.rlm-mcp/config.yaml
# Data storage
data_dir: ~/.rlm-mcp
# Session limits (per-session overridable)
default_max_tool_calls: 500
default_max_chars_per_response: 50000
default_max_chars_per_peek: 10000
# Batch loading (v0.2.0)
max_concurrent_loads: 20 # Max concurrent file loads (memory safety)
max_file_size_mb: 100 # Reject files larger than this
# Logging (v0.2.0)
log_level: "INFO" # DEBUG, INFO, WARNING, ERROR
structured_logging: true # JSON format (true) vs human-readable (false)
log_file: null # Optional: "/var/log/rlm-mcp.log"
# Tool naming: strict by default (fails if SDK doesn't support canonical names)
# Only set to true for experimentation with older MCP SDKs
allow_noncanonical_tool_names: falseTool Naming (Strict vs Compat Mode)
By default, RLM-MCP requires an MCP SDK that supports explicit tool naming (e.g., FastMCP). This ensures tools are discoverable as rlm.session.create, not rlm_session_create.
Strict mode (default): Server fails to start if SDK doesn't support
tool(name=...)Compat mode: Falls back to function names with a warning. Use only for experimentation.
# ~/.rlm-mcp/config.yaml
allow_noncanonical_tool_names: true # Enable compat mode (not recommended)Logging (v0.2.0)
RLM-MCP produces structured JSON logs for production observability. Each operation gets a unique correlation ID for tracing related events.
JSON Log Format
{
"timestamp": "2026-01-15T10:30:45.123456Z",
"level": "INFO",
"logger": "rlm_mcp.server",
"message": "Completed rlm.session.create",
"correlation_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"session_id": "session-123",
"operation": "rlm.session.create",
"duration_ms": 42,
"success": true
}Filtering Logs
# Filter by session
cat /var/log/rlm-mcp.log | jq 'select(.session_id == "session-123")'
# Filter by operation
cat /var/log/rlm-mcp.log | jq 'select(.operation == "rlm.search.query")'
# Track operation with correlation ID
cat /var/log/rlm-mcp.log | jq 'select(.correlation_id == "a1b2c3d4...")'
# Only errors
cat /var/log/rlm-mcp.log | jq 'select(.level == "ERROR")'See docs/LOGGING.md for detailed logging guide.
Session Config
{
"max_tool_calls": 500, # Budget enforcement
"max_chars_per_response": 50000, # DOS protection
"max_chars_per_peek": 10000, # DOS protection
"chunk_cache_enabled": True,
"model_hints": { # Advisory for client
"root_model": "claude-opus-4-5-20251101",
"subcall_model": "claude-sonnet-4-5-20250929",
"bulk_model": "claude-haiku-4-5-20251001"
}
}Architecture
┌─────────────────────────────────────────┐
│ Claude Skills (policy layer) │
├─────────────────────────────────────────┤
│ MCP Server (RLM Runtime) │
│ • Session management + concurrency │
│ • Document/span operations │
│ • BM25 search (lazy, persisted) │
│ • Batch loading with semaphores │
│ • Response size caps │
├─────────────────────────────────────────┤
│ Local Persistence (v0.2.0) │
│ • SQLite: sessions, docs, spans │
│ • Blob store: content-addressed │
│ • Index cache: persistent BM25 │
│ • Structured logs: JSON + correlation │
└─────────────────────────────────────────┘Design Principles
Local-first — All reads/writes hit local storage
Client-managed subcalls — MCP is the "world", client makes LLM calls
Immutable documents — Content-addressed, never modified
On-demand chunking — Chunk at query time, cache results
DOS protection — Hard caps on response sizes
Development
# Clone and install with uv (recommended)
git clone https://github.com/yourorg/rlm-mcp.git
cd rlm-mcp
uv sync --extra dev
# Run tests
uv run pytest
# Or with pip (editable install required for tests)
pip install -e ".[dev]"
pytest
# Type checking
uv run mypy src/
# Linting
uv run ruff check src/Smoke Test with MCP Inspector
To validate tool discovery and schemas from a real client:
# Start server
uv run rlm-mcp
# In another terminal, use MCP Inspector
npx @anthropic/mcp-inspectorVerify:
Tool names appear as
rlm.session.create, notrlm_session_createSchemas match expected input/output structures
truncatedandindex_builtfields appear in responses
License
MIT
References
Zhang, A. L., Kraska, T., & Khattab, O. (2025). Recursive Language Models. arXiv:2512.24601
Available Tools
12 toolsrlm.artifact.getB
Retrieve artifact content.
Args: session_id: Session containing artifact artifact_id: Artifact ID to retrieve
Inputs: session_id (required), artifact_id (required). Returns: object
rlm.artifact.listA
List artifacts for a session or span.
Args: session_id: Session to query span_id: Optional span ID filter type: Optional type filter
Inputs: session_id (required), span_id, type. Returns: object
rlm.artifact.storeA
Store a derived artifact with provenance.
Args: session_id: Session to store artifact in type: Artifact type (summary, extraction, classification, custom) content: Artifact content span_id: Optional span ID for provenance span: Optional span reference (doc_id, start, end) - creates span if needed provenance: Optional provenance metadata (model, prompt_hash)
Inputs: session_id (required), type (required), content (required), span_id, +2 more. Returns: object
rlm.chunk.createB
Chunk a document using a specified strategy.
Args: session_id: Session containing document doc_id: Document ID to chunk strategy: Chunking strategy (type, chunk_size, line_count, delimiter, overlap)
Inputs: session_id (required), doc_id (required), strategy (required). Returns: object
rlm.docs.listC
List documents in session.
Args: session_id: Session to query limit: Max documents to return offset: Pagination offset
Inputs: session_id (required), limit, offset. Returns: object
rlm.docs.loadC
Load documents into the session context.
Args: session_id: Session to load into sources: List of source specs (type, path, content, etc.)
Inputs: session_id (required), sources (required). Returns: object
rlm.docs.peekA
View a portion of a document. Enforces max_chars_per_peek.
Args: session_id: Session containing document doc_id: Document ID to peek start: Start offset (inclusive) end: End offset (exclusive), -1 for end of doc
Inputs: session_id (required), doc_id (required), start, end. Returns: object
rlm.search.queryC
Search documents. BM25 index is lazy-built on first use.
Args: session_id: Session to search query: Search query string method: Search method (bm25, regex, literal) doc_ids: Optional list of doc IDs to limit search limit: Max matches to return context_chars: Characters of context around each match
Inputs: session_id (required), query (required), method, doc_ids, +2 more. Returns: object
rlm.session.closeB
Mark session complete and persist index metadata.
Args: session_id: Session ID to close
Inputs: session_id (required). Returns: object
rlm.session.createB
Create a new RLM session for processing large contexts.
Args: name: Human-readable session name config: Session configuration (max_tool_calls, max_chars_per_response, etc.)
Inputs: name, config. Returns: object
rlm.session.infoB
Get session statistics and configuration.
Args: session_id: Session ID to query
Inputs: session_id (required). Returns: object
rlm.span.getC
Retrieve the content of one or more spans. Enforces max_chars_per_response.
Args: session_id: Session containing spans span_ids: List of span IDs to retrieve
Inputs: session_id (required), span_ids (required). Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 12 tools
Each tool targets a distinct resource (artifact, chunk, doc, session, span) and action, with clear descriptions. No ambiguity between tools.
All tools follow a consistent `rlm.<resource>.<action>` dot-separated pattern, improving predictability for agents.
12 tools cover the necessary operations for a document processing server without being excessive or insufficient.
The tool set covers core lifecycle operations (session creation/close, document loading/peeking, artifact storage/retrieval, search), but lacks delete or update operations for several resources, which may be intentional but limits completeness.
Maintenance
Related MCP Connectors
Ingest, manage, and retrieve documents for RAG-powered AI applications
Universal persistent memory and knowledge retrieval layer for AI agents and LLMs.
Intelligent context infrastructure for AI teams: knowledge graph, sessions, tasks, documents.
Persistent memory for AI agents. Search, store, and recall across sessions.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to analyze documents larger than their context window by loading files into RAM and querying them via search, navigation, and Python execution tools. Supports recursive reasoning to process massive datasets in chunks using sub-agents.220MIT
- AlicenseNot gradedqualityDmaintenanceAn implementation of the Recursive Language Models architecture that enables AI agents to process massive documents by programmatically decomposing them into sub-queries. It allows for cost-effective and accurate reasoning across millions of tokens by treating long-form data as an external environment for root and worker models.11MIT
- AlicenseAqualityDmaintenanceEnables any LLM to process arbitrarily long contexts through recursive decomposition, without requiring external LLM APIs.1720 npm15MIT
- FlicenseNot gradedqualityDmaintenanceProvides recursive language model capabilities to AI assistants, enabling efficient exploration of large contexts through iterative Python code execution.1-