
Massive Context Mcp
io.github.egoughnourPublished by GitHub account egoughnourv3.0.1Updated Oct 24, 2026
Handles 10M+ token contexts with chunking, sub-queries, and local Ollama inference.
Overview
Lets an assistant load very large documents as external context, chunk them, and analyze chunks with local Ollama or Claude sub-queries.
- What you can do
- Massive Context MCP implements a recursive language model pattern: it loads a large document as an external variable, inspects and chunks it by lines, characters, or paragraphs, runs sub-queries over chunks in parallel, and aggregates the results. Tools include rlm_auto_analyze for one-step analysis, rlm_load_context, rlm_inspect_context, rlm_chunk_context, rlm_sub_query and rlm_sub_query_batch, plus rlm_exec for running sandboxed Python against a loaded context. Setup and status tools check system requirements and detect or install Ollama.
- When to use it
- Use it when a document is too large to fit in the model's context and you want summarization, bug finding, structure extraction, security auditing, or custom questions answered over it. It is also useful for deterministic regex or data extraction over big files via rlm_exec.
- Requirements
- Runs locally over stdio, installed from PyPI (uvx or pip) or as a .mcpb bundle; desktop only. Optional environment variables: OLLAMA_URL (default and RLM_DATA_DIR for stored context data. Free local inference needs Ollama with a gemma3 model; otherwise sub-queries fall back to the Claude SDK. The README describes macOS with Apple Silicon and 16GB+ RAM for local model setup.
Installation
In SourceWeft
- Open Massive Context Mcp in the dashboard and add it to a workspace.
- Enable the server for the chats that should use its tools.
Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.
Other MCP clients
Follow the launch instructions in the repository.
README
Massive Context MCP
[PyPI] [MCP Registry] [Claude Desktop] [Tests] [Release] [License: MIT]
[Top Language] [Code Size] [Last Commit] [Repository Size]
Handle massive contexts (10M+ tokens) with chunking, sub-queries, and free local inference via Ollama.
Based on the Recursive Language Model pattern. Inspired by richardwhiteii/rlm.
📸 Screenshots
Core Idea
Instead of feeding massive contexts directly into the LLM:
- Load context as external variable (stays out of prompt)
- Inspect structure programmatically
- Chunk strategically (lines, chars, or paragraphs)
- Sub-query recursively on chunks
- Aggregate results for final synthesis
Quick Start
Installation
Option 1: PyPI (Recommended)
With Optional Extras:
Option 2: Claude Desktop One-Click
Download the .mcpb from Releases and double-click to install.
Option 3: From Source
Wire to Claude Code / Claude Desktop
Add to ~/.claude/.mcp.json (Claude Code) or claude_desktop_config.json (Claude Desktop):
Tools
Setup & Status Tools
Analysis Tools
Quick Analysis with rlm_auto_analyze
For most use cases, just use rlm_auto_analyze — it handles everything automatically:
What it does automatically:
- Detects content type (Python, JSON, Markdown, logs, prose, code)
- Selects optimal chunking strategy
- Adapts the query for the content type
- Runs parallel sub-queries
- Returns aggregated results
Supported goals:
Programmatic Analysis with rlm_exec
For deterministic pattern matching and data extraction, use rlm_exec to run Python code directly against a loaded context. This is closer to the paper's REPL approach and provides full control over analysis logic.
Tool: rlm_exec
Purpose: Execute arbitrary Python code against a loaded context in a sandboxed subprocess.
Parameters:
code(required): Python code to execute. Set theresultvariable to capture output.context_name(required): Name of a previously loaded context.timeout(optional, default 30): Maximum execution time in seconds.
Features:
- Context available as read-only
contextvariable - Pre-imported modules:
re,json,collections - Subprocess isolation (won't crash the server)
- Timeout enforcement
- Works on any system with Python (no Docker needed)
Example — Finding patterns in a loaded context:
Example Response:
Example — Extracting structured data:
When to use rlm_exec vs rlm_sub_query:
Tip: For large contexts, combine both — use rlm_exec to filter/extract, then rlm_sub_query for semantic analysis of filtered results.
Code Firewall Integration (Optional)
For enhanced security, integrate code-firewall-mcp to filter dangerous code patterns before execution:
When installed, rlm_exec can automatically check code against a blacklist of known dangerous patterns (e.g., os.system(), eval(), subprocess with shell=True). The firewall uses structural similarity matching — normalizing code to its skeleton and comparing against blacklisted patterns via embeddings.
How it works:
- Code is parsed to a syntax tree and normalized (identifiers →
_, strings →"S") - Normalized structure is embedded via Ollama
- Similarity is checked against blacklisted patterns in ChromaDB
- Code is blocked if similarity exceeds threshold (default: 0.85)
Configuration (environment variables):
RLM_FIREWALL_ENABLED=true— Enable firewall checks (auto-enabled when package installed)RLM_FIREWALL_MODE=warn|block— Warn or block on matches (default:warn)
Example blocked patterns:
os.system(user_input)— Command injectioneval(untrusted_data)— Code injectionsubprocess.Popen(..., shell=True)— Shell injection
Use rlm_firewall_status to check firewall availability and configuration.
Providers & Auto-Detection
RLM automatically detects and uses the best available provider:
How Auto-Detection Works
When you use provider="auto" (the default), RLM:
- Checks if Ollama is running at
OLLAMA_URL(default:http://localhost:11434) - Checks if gemma3:12b is available (or any gemma3 variant)
- Uses Ollama if available, otherwise falls back to Claude SDK
The status is cached for 60 seconds to avoid repeated network checks.
Check Ollama Status
Use rlm_ollama_status to see what's available:
Response when Ollama is ready:
Response when Ollama is not available:
Transparent Provider Selection
All sub-query responses include which provider was actually used:
Autonomous Usage
Enable Claude to use RLM tools automatically without manual invocation:
1. CLAUDE.md Integration
Copy CLAUDE.md.example content to your project's CLAUDE.md (or ~/.claude/CLAUDE.md for global) to teach Claude when to reach for RLM tools automatically.
2. Hook Installation
Copy the .claude/hooks/ directory to your project to auto-suggest RLM when reading files >10KB:
The hook provides guidance but doesn't block reads.
3. Skill Reference
Copy the .claude/skills/ directory for comprehensive RLM guidance:
With these in place, Claude will autonomously detect when to use RLM instead of reading large files directly into context.
Setting Up Ollama (Free Local Inference)
RLM can automatically install and configure Ollama on macOS with Apple Silicon. There are two installation methods with different trade-offs:
Choosing an Installation Method
Recommendation:
- Use Homebrew method if you have Homebrew and want managed updates
- Use Direct Download for automation, locked-down machines, or when you don't have admin access
Method 1: Homebrew Installation (Recommended if you have Homebrew)
What this does:
- Installs Ollama via Homebrew (
brew install ollama) - Starts Ollama as a managed background service (
brew services start ollama) - Pulls gemma3:12b model (~8GB download)
Requirements:
- macOS with Apple Silicon (M1/M2/M3/M4)
- 16GB+ RAM (gemma3:12b needs ~8GB to run)
- Homebrew installed
Method 2: Direct Download (Fully Headless, No Sudo)
What this does:
- Downloads Ollama from https://ollama.com/download/Ollama-darwin.zip
- Extracts to
~/Applications/Ollama.app(user directory, no admin needed) - Starts Ollama via
ollama serve(background process) - Pulls gemma3:12b model
Requirements:
- macOS with Apple Silicon (M1/M2/M3/M4)
- 16GB+ RAM
- No special permissions needed!
Note on PATH: After direct installation, the CLI is at:
Add to your shell config if needed:
For Systems with Less RAM
Use a smaller model on either installation method:
Manual Setup
If you prefer manual installation or are on a different platform:
-
Install Ollama from https://ollama.ai or via Homebrew:
-
Start the service:
-
Pull the model:
-
Verify it's working:
Provider Selection
RLM automatically uses Ollama when available. You can also force a specific provider:
Usage Example
Basic Pattern
Processing a 2MB Document
Tested with H.R.1 Bill (2MB):
Result: Comprehensive topic extraction at $0 cost (with Ollama) or ~$0.02 (with Claude).
Analyzing War and Peace (3.3MB)
Literary analysis of Tolstoy's epic novel from Project Gutenberg:
Result: Complete character arc across the novel — Pierre's journey from idealist to prisoner to husband, Natásha's growth, Nikolái Rostóv's journey from soldier to landowner — all for ~$0.03.
Data Storage
Contexts persist across sessions. Chunked contexts are cached for reuse.
Learning Prompts
Use these prompts with Claude Code to explore the codebase and learn RLM patterns. The code is the single source of truth.
Understanding the Tools
Understanding the Architecture
Hands-On Learning
Extending RLM
License
MIT
Source: README.md at commit 5ee4ad4
Tools
0Version history
1- v3.0.1LatestSep 16, 2026
Score
50% of the applicable checks met
How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.
- Reached in the last 30 days25 pts
Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.
- Auth declared10 pts
Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.
- Tools listed15 pts
Answer tools/list without a credential, or ship a package that starts in a sandbox without one.
- DescriptionRequired15 pts
- Logo10 pts
- Documentation15 pts
- License10 pts