RLM MCP Server
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 Server Load the research paper and summarize each section."
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 Server v2.0
Recursive Language Model Infrastructure Server - Enables ANY LLM to process arbitrarily long contexts through recursive decomposition.
šÆ Key Design Principle
No external LLM API required!
This server provides infrastructure only - your MCP client's LLM performs all the reasoning. This means:
ā Works with any LLM (Claude, GPT, Llama, Gemini, local models, etc.)
ā No API keys needed
ā No additional costs
ā Full control over the reasoning process
ā Cross-platform (Windows, macOS, Linux)
infographic compare-binary-horizontal-simple-fold
data
title RLM Architecture Comparison
items
- label Traditional Approach
desc Server calls external LLM API
icon mdi:server-network
- label This Server (v2.0)
desc Client LLM does all reasoning
icon mdi:brainRelated MCP server: MCP-RLM
How It Works
The RLM pattern treats long contexts as external data that the LLM interacts with programmatically:
infographic sequence-steps-simple
data
title RLM Processing Flow
items
- label 1. Load
desc Load long context into server
- label 2. Analyze
desc Get structure and statistics
- label 3. Decompose
desc Split into manageable chunks
- label 4. Process
desc LLM reasons over chunks
- label 5. Aggregate
desc Combine into final answerYour client's LLM uses the provided tools to:
Load context - Store arbitrarily long text
Analyze - Understand structure and size
Decompose - Split into chunks using various strategies
Search - Find relevant sections with regex
Execute code - Manipulate data with JavaScript
Build answer - Incrementally construct the response
Installation
# Clone or navigate to project
cd rlm-mcp-server
# Install dependencies
npm install
# Build
npm run build
# Run
npm startNo environment variables needed!
MCP Client Configuration
Claude Desktop (Windows)
Edit %APPDATA%\Claude\claude_desktop_config.json:
{
"mcpServers": {
"rlm": {
"command": "node",
"args": ["C:\\path\\to\\rlm-mcp-server\\dist\\index.js"]
}
}
}Claude Desktop (macOS/Linux)
Edit ~/.config/claude/claude_desktop_config.json:
{
"mcpServers": {
"rlm": {
"command": "node",
"args": ["/path/to/rlm-mcp-server/dist/index.js"]
}
}
}Alma
Add to your MCP server configuration:
{
"rlm-mcp-server": {
"command": "node",
"args": ["/path/to/rlm-mcp-server/dist/index.js"]
}
}Available Tools
Context Management
Tool | Description |
| Load text content into session |
| Get metadata and preview |
| Read portion by chars or lines |
Decomposition
Tool | Description |
| Split into chunks (multiple strategies) |
| Retrieve specific chunk contents |
| Get recommended chunking strategy |
Search
Tool | Description |
| Search with regex patterns |
| Find all substring occurrences |
Code Execution
Tool | Description |
| Run JavaScript in REPL |
| Store variable in session |
| Retrieve variable |
Answer Management
Tool | Description |
| Set/update answer (partial or final) |
| Get current answer state |
Session & Utilities
Tool | Description |
| Create isolated session |
| Get session details |
| Clear session data |
| Get detailed statistics |
Decomposition Strategies
Strategy | Description | Best For |
| Fixed character chunks with overlap | General use, JSON |
| Chunk by number of lines | Code, CSV, logs |
| Split on double newlines | Articles, documents |
| Split on markdown headers | Markdown docs |
| Split on custom pattern | Custom formats |
| Split into sentences | Dense text |
REPL Environment Functions
When using rlm_execute_code:
// Output
print(...args) // Print to output
// Context
getContext(id) // Get full content
getContextMetadata(id) // Get metadata
// String Operations
len(str) // Length
slice(str, start, end) // Substring
split(str, sep) // Split to array
join(arr, sep) // Join to string
trim(str), lower(str), upper(str) // String transforms
// Regex
search(pattern, text, flags) // Find matches
findAll(pattern, text) // All matches with index
replace(text, pattern, repl) // Replace
// Array
range(start, end, step) // Generate range
map(arr, fn) // Transform
filter(arr, fn) // Filter
reduce(arr, fn, init) // Reduce
sort(arr, fn) // Sort (copy)
unique(arr) // Remove duplicates
chunk(arr, size) // Split array
// Variables
setVar(name, value) // Store
getVar(name) // Retrieve
listVars() // List all
// Answer
setAnswer(content, ready) // Set answer
getAnswer() // Get answer state
// JSON
JSON.parse(str) // Parse
JSON.stringify(obj, indent) // StringifyExample Workflow
Here's how an LLM might process a very long document:
1. Load the document:
rlm_load_context(context="...", context_id="doc")
2. Analyze structure:
rlm_get_context_info(context_id="doc")
ā Returns: 500,000 chars, markdown, 12,000 lines
3. Get strategy suggestion:
rlm_suggest_strategy(context_id="doc")
ā Returns: by_sections (markdown content)
4. Decompose:
rlm_decompose_context(context_id="doc", strategy="by_sections")
ā Returns: 45 chunks (sections)
5. Search for relevant sections:
rlm_search_context(context_id="doc", pattern="climate change")
ā Returns: Matches in chunks 3, 7, 12, 23
6. Get those chunks:
rlm_get_chunks(chunk_indices=[3, 7, 12, 23])
ā Returns: Content of those sections
7. Process each chunk (LLM reasoning)
Build understanding from each section...
8. Save intermediate results:
rlm_set_variable(name="findings", value=[...])
9. Aggregate into final answer:
rlm_set_answer(content="Based on analysis...", ready=true)Use Cases
Long Document Analysis
Research paper summarization
Legal document review
Code repository understanding
Multi-Document Processing
Literature review
Comparative analysis
Information aggregation
Log Analysis
Error pattern detection
Timeline reconstruction
Anomaly identification
Data Extraction
Entity extraction from large texts
Pattern mining
Content classification
Architecture
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā MCP Client ā
ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā
ā ā Your LLM ā ā
ā ā (Claude, GPT, Llama, Gemini, etc.) ā ā
ā ā ā ā
ā ā Performs all reasoning and recursive calls ā ā
ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā
ā ā ā
ā MCP Protocol ā
ā ā ā
āāāāāāāāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā
āāāāāāāāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā RLM MCP Server (this) ā
ā ā ā
ā āāāāāāāāāāāāāāāāāāāāāāāā“āāāāāāāāāāāāāāāāāāāāāāāāāāā ā
ā ā Tools Layer ā ā
ā ā load, read, decompose, search, execute, etc. ā ā
ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā
ā ā ā
ā āāāāāāāāāāāāāāāāāāāāāāāā“āāāāāāāāāāāāāāāāāāāāāāāāāāā ā
ā ā Services Layer ā ā
ā ā āāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāāāāāāāāā ā ā
ā ā ā Session ā ā Context Processor ā ā ā
ā ā ā Manager ā ā (decompose, search) ā ā ā
ā ā āāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāāāāāāāāā ā ā
ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā
ā ā
ā No external dependencies - pure JavaScript ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāRunning Modes
Stdio (Default)
For MCP clients like Claude Desktop:
node dist/index.jsHTTP
For remote access or testing:
node dist/index.js --http --port=3000Endpoints:
POST /mcp- MCP protocolGET /health- Health checkGET /info- Server info
Why This Design?
The original RLM paper describes a system where the LLM calls sub-LLMs recursively. However, in the MCP context:
The client already has an LLM - No need for another API
Cost efficiency - No additional API calls/costs
Flexibility - Works with any LLM
Control - The client controls the reasoning
Simplicity - Pure infrastructure, no API keys
The tools in this server provide everything needed for the LLM to implement RLM patterns itself.
Contributing
Contributions welcome! Areas of interest:
Additional decomposition strategies
Performance optimizations
New REPL helper functions
Documentation improvements
License
MIT License
References
Built for the long-context AI community š
Available Tools
17 toolsrlm_clear_sessionClear SessionADestructiveIdempotent
Clear all data from a session (contexts, variables, history).
Inputs: session_id.
rlm_create_sessionCreate SessionA
Create a new isolated RLM session.
Use this when you need multiple independent processing contexts. Most use cases can use the default session.
Inputs: no named parameters.
rlm_decompose_contextDecompose ContextARead-onlyIdempotent
Split context into chunks using various strategies.
Strategies:
fixed_size: Fixed character chunks with overlap
by_lines: Chunk by number of lines
by_paragraphs: Split on double newlines
by_sections: Split on markdown headers
by_regex: Split on custom pattern
by_sentences: Split into sentences
Returns chunk metadata (indices, offsets). Use rlm_get_chunks to retrieve content.
Inputs: overlap, pattern, strategy, chunk_size, +4 more.
rlm_execute_codeExecute CodeA
Execute JavaScript code in the session's REPL environment.
Available functions:
print(...args) - Output text
getContext(id) - Get context content
getContextMetadata(id) - Get context metadata
len(str), slice(str,s,e), split(str,sep), join(arr,sep)
search(pattern,text,flags), findAll(pattern,text), replace(text,pattern,repl)
range(start,end,step), map(arr,fn), filter(arr,fn), reduce(arr,fn,init)
setVar(name,value), getVar(name), listVars()
setAnswer(content,ready), getAnswer()
JSON.parse(), JSON.stringify()
Use this for custom data manipulation and aggregation.
Inputs: code (required), session_id.
rlm_find_allFind All OccurrencesARead-onlyIdempotent
Find all occurrences of a substring (faster than regex for simple searches).
Returns character offsets of all matches.
Inputs: substring (required), context_id, session_id, case_sensitive.
rlm_get_answerGet AnswerARead-onlyIdempotent
Get the current answer state.
Returns the content and whether it's marked as ready/complete.
Inputs: session_id.
rlm_get_chunksGet Specific ChunksARead-onlyIdempotent
Retrieve content of specific chunks by index.
Use after rlm_decompose_context to get the actual content of chunks you want to process. You can request multiple chunks at once (up to 50).
Inputs: chunk_indices (required), overlap, strategy, chunk_size, +2 more.
rlm_get_context_infoGet Context InfoARead-onlyIdempotent
Get metadata and preview of a loaded context.
Returns:
Length, line count, word count
Detected structure type (json, csv, markdown, code, etc.)
Optional content preview
Use this to understand the context before deciding how to process it.
Inputs: context_id, session_id, preview_length, include_preview.
rlm_get_session_infoGet Session InfoARead-onlyIdempotent
Get information about a session including loaded contexts and variables.
Inputs: session_id.
rlm_get_statisticsGet Context StatisticsBRead-onlyIdempotent
Get detailed statistics about a context.
Returns length, line/word/sentence/paragraph counts, and averages.
Inputs: context_id, session_id.
rlm_get_variableGet VariableARead-onlyIdempotent
Retrieve a variable from the session.
Inputs: name (required), session_id.
rlm_load_contextLoad ContextAIdempotent
Load text content into the RLM session for processing.
This is typically the first step in RLM processing. Load your long context here, then use other tools to decompose, search, and analyze it.
The context is stored in the session and can be referenced by its ID in other tools.
Example workflow:
rlm_load_context - Load your document
rlm_get_context_info - Understand structure and size
rlm_decompose_context - Split into manageable chunks
rlm_search_context - Find relevant sections
rlm_read_context - Read specific portions
rlm_set_answer - Build up your response
Inputs: context (required), context_id, session_id.
rlm_read_contextRead Context PortionARead-onlyIdempotent
Read a specific portion of the context.
Modes:
chars: Read by character offsets (start, end)
lines: Read by line numbers (start, end)
Use this to examine specific sections without loading the entire context.
Inputs: end, mode, start, context_id, +1 more.
rlm_search_contextSearch ContextARead-onlyIdempotent
Search context using regex patterns.
Returns matches with surrounding context and line numbers. Use this to find relevant sections before reading in detail.
Examples:
Pattern: "error|warning" - Find all errors and warnings
Pattern: "function\s+\w+" - Find function definitions
Pattern: "TODO|FIXME" - Find code comments
Inputs: pattern (required), flags, context_id, session_id, +3 more.
rlm_set_answerSet AnswerAIdempotent
Set or update the answer for the current RLM task.
Call this to build up your answer incrementally:
ready=false: Store partial/intermediate answer
ready=true: Mark answer as complete/final
The answer can be retrieved later with rlm_get_answer.
Inputs: content (required), ready, session_id.
rlm_set_variableSet VariableAIdempotent
Store a variable in the session for later use.
Use this to save intermediate results during RLM processing.
Inputs: name (required), value, session_id.
rlm_suggest_strategySuggest Decomposition StrategyARead-onlyIdempotent
Get a suggested decomposition strategy based on the context's structure.
Analyzes the content type and size to recommend the best chunking approach.
Inputs: context_id, session_id.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogā¦
TDQS
Scored across 17 tools
Each tool has a clearly distinct purpose: loading context, retrieving metadata, reading portions, decomposing, fetching chunks, searching, executing code, managing variables, managing answers, and session management. No two tools are interchangeable, and overlapping tools like rlm_search_context and rlm_find_all are differentiated by regex vs. substring search.
All tool names follow a consistent rlm_<verb>_<noun> pattern with snake_case (e.g., rlm_load_context, rlm_get_context_info, rlm_decompose_context). Verbs and nouns are clear and predictable, making the API easy to navigate.
With 17 tools, the set is slightly above the ideal 3-15 range, but the count is justified by the comprehensive workflow: context loading, analysis, decomposition, search, code execution, variable storage, answer management, and session lifecycle management. Each tool adds meaningful functionality.
The tool surface covers the full RLM processing lifecycle: load context, inspect structure, read specific sections, decompose into chunks, retrieve chunks, search, manipulate via code, store intermediate variables, build answers incrementally, and manage sessions. There are no obvious gaps or dead ends for the stated purpose.
Maintenance
Related MCP Connectors
Memory that reasons: continual learning for stateful agents. Better context, fewer tokens.
Multi-agent coordination outside your LLM context: dedupe parallel work, per-agent budgets, handoff
Stateless agentic tools over MCP: concept extraction, long-context, knowledge graph, planning.
Memory, reflection and safety for AI agents. Hosted or local, no vector database.
Related MCP Servers
- AlicenseAqualityBmaintenanceEnables LLMs to chat with long PDFs using a reasoning-based, tree-structured document index that navigates content like a human would, without requiring vector databases or hitting context limits.10332 npm411MIT
- 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
- AlicenseAqualityDmaintenanceImplements the Recursive Language Model pattern, enabling LLMs to process arbitrarily long contexts through session-based document management, on-demand chunking, BM25 search, and artifact storage.121MIT
- FlicenseNot gradedqualityDmaintenanceProvides recursive language model capabilities to AI assistants, enabling efficient exploration of large contexts through iterative Python code execution.1-