Install
$ agentstack add mcp-egoughnour-massive-context-mcp Open-source listing — not yet scanned by AgentStack. Follow the source repository for install instructions.
Security review
⚠ Flagged1 finding(s); flagged for manual review. · v0.1.0 How review works →
- • Prompt-injection patterns
- • Secret / credential exfiltration
- • Dangerous shell & filesystem operations
- • Untrusted network calls
- • Known-malicious package signatures
- high Dangerous shell/eval execution.
What it can access
- ● Network access Used
- ✓ Filesystem access No
- ● Shell / process execution Used
- ✓ Environment & secrets No
- ● Dynamic code execution Used
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
About
Massive Context MCP
[](https://pypi.org/project/massive-context-mcp/) [](https://registry.mcp.so/servers/io.github.egoughnour/massive-context-mcp) [](https://github.com/egoughnour/massive-context-mcp/releases/latest/download/massive-context-mcp.mcpb) [](https://github.com/egoughnour/massive-context-mcp/actions/workflows/test.yml) [](https://github.com/egoughnour/massive-context-mcp/actions/workflows/release.yml) [](https://opensource.org/licenses/MIT)
[](https://github.com/egoughnour/massive-context-mcp/languages) [](https://github.com/egoughnour/massive-context-mcp) [](https://github.com/egoughnour/massive-context-mcp/commits/main) [](https://github.com/egoughnour/massive-context-mcp)
Handle massive contexts (10M+ tokens) with chunking, sub-queries, and free local inference via Ollama.
flowchart TD
A[Claude Code] --> B[RLM MCP Server]
B --> C{rlm_ollama_status}
C -->|cached 60s| D{provider = auto}
D -->|Ollama running| E[🦙 Ollamagemma3:12b]
D -->|Ollama unavailable| F[☁️ Claude SDKclaude-haiku-4-5]
E --> G[["💰 $0Free local inference"]]
F --> H[["💰 ~$0.80/1MCloud inference"]]
style A fill:#ff922b,color:#fff
style B fill:#339af0,color:#fff
style E fill:#51cf66,color:#fff
style F fill:#748ffc,color:#fff
style G fill:#51cf66,color:#fff
style H fill:#748ffc,color:#fff
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)
uvx massive-context-mcp
# or
pip install massive-context-mcp
With Optional Extras:
# With Code Firewall integration (security filter for rlm_exec)
pip install massive-context-mcp[firewall]
# With Claude Agent SDK (for programmatic Claude API access)
pip install massive-context-mcp[claude]
# With all extras
pip install massive-context-mcp[firewall,claude]
Option 2: Claude Desktop One-Click
Download the .mcpb from Releases and double-click to install.
Option 3: From Source
git clone https://github.com/egoughnour/massive-context-mcp.git
cd massive-context-mcp
uv sync
Wire to Claude Code / Claude Desktop
Add to ~/.claude/.mcp.json (Claude Code) or claude_desktop_config.json (Claude Desktop):
{
"mcpServers": {
"massive-context": {
"command": "uvx",
"args": ["massive-context-mcp"],
"env": {
"RLM_DATA_DIR": "~/.rlm-data",
"OLLAMA_URL": "http://localhost:11434"
}
}
}
}
Tools
Setup & Status Tools
| Tool | Purpose | |------|---------| | rlm_system_check | Check system requirements — verify macOS, Apple Silicon, 16GB+ RAM, Homebrew | | rlm_setup_ollama | Install via Homebrew — managed service, auto-updates, requires Homebrew | | rlm_setup_ollama_direct | Install via direct download — no sudo, fully headless, works on locked-down machines | | rlm_ollama_status | Check Ollama availability — detect if free local inference is available |
Analysis Tools
| Tool | Purpose | |------|---------| | rlm_auto_analyze | One-step analysis — auto-detects type, chunks, and queries | | rlm_load_context | Load context as external variable | | rlm_inspect_context | Get structure info without loading into prompt | | rlm_chunk_context | Chunk by lines/chars/paragraphs | | rlm_get_chunk | Retrieve specific chunk | | rlm_filter_context | Filter with regex (keep/remove matching lines) | | rlm_exec | Execute Python code against loaded context (sandboxed) | | rlm_sub_query | Make sub-LLM call on chunk | | rlm_sub_query_batch | Process multiple chunks in parallel | | rlm_store_result | Store sub-call result for aggregation | | rlm_get_results | Retrieve stored results | | rlm_list_contexts | List all loaded contexts |
Quick Analysis with rlm_auto_analyze
For most use cases, just use rlm_auto_analyze — it handles everything automatically:
rlm_auto_analyze(
name="my_file",
content=file_content,
goal="find_bugs" # or: summarize, extract_structure, security_audit, answer:
)
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:
| Goal | Description | |------|-------------| | summarize | Summarize content purpose and key points | | find_bugs | Identify errors, issues, potential problems | | extract_structure | List functions, classes, schema, headings | | security_audit | Find vulnerabilities and security issues | | answer: | Answer a custom question about the content |
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:
# After loading a context
rlm_exec(
code="""
import re
amounts = re.findall(r'\$[\d,]+', context)
result = {'count': len(amounts), 'sample': amounts[:5]}
""",
context_name="bill"
)
Example Response:
{
"result": {
"count": 1247,
"sample": ["$500", "$1,000", "$250,000", "$100,000", "$50"]
},
"stdout": "",
"stderr": "",
"return_code": 0,
"timed_out": false
}
Example — Extracting structured data:
rlm_exec(
code="""
import re
import json
# Find all email addresses
emails = re.findall(r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b', context)
# Count by domain
from collections import Counter
domains = [e.split('@')[1] for e in emails]
domain_counts = Counter(domains)
result = {
'total_emails': len(emails),
'unique_domains': len(domain_counts),
'top_domains': domain_counts.most_common(5)
}
""",
context_name="dataset",
timeout=60
)
When to use rlm_exec vs rlm_sub_query:
| Use Case | Tool | Why | |----------|------|-----| | Extract all dates, IDs, amounts | rlm_exec | Regex is deterministic and fast | | Find security vulnerabilities | rlm_sub_query | Requires reasoning and context | | Parse JSON/XML structure | rlm_exec | Standard libraries work perfectly | | Summarize themes or tone | rlm_sub_query | Natural language understanding needed | | Count word frequencies | rlm_exec | Simple computation, no AI needed | | Answer "Why did X happen?" | rlm_sub_query | Requires inference and reasoning |
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:
pip install massive-context-mcp[firewall]
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:
| Provider | Default Model | Cost | Use Case | |----------|--------------|------|----------| | auto | (best available) | $0 or ~$0.80/1M | Default — prefers Ollama if available | | ollama | gemma3:12b | $0 | Local inference, requires Ollama | | claude-sdk | claude-haiku-4-5 | ~$0.80/1M input | Cloud inference, always available |
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:
rlm_ollama_status()
Response when Ollama is ready:
{
"running": true,
"models": ["gemma3:12b", "llama3:8b"],
"default_model_available": true,
"best_provider": "ollama",
"recommendation": "Ollama is ready! Sub-queries will use free local inference by default."
}
Response when Ollama is not available:
{
"running": false,
"error": "connection_refused",
"best_provider": "claude-sdk",
"recommendation": "Ollama not available. Sub-queries will use Claude API. To enable free local inference, install Ollama and run: ollama serve"
}
Transparent Provider Selection
All sub-query responses include which provider was actually used:
{
"provider": "ollama",
"model": "gemma3:12b",
"requested_provider": "auto",
"response": "..."
}
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:
cp -r .claude/hooks/ /Users/your_username/your-project/.claude/hooks/
The hook provides guidance but doesn't block reads.
3. Skill Reference Copy the .claude/skills/ directory for comprehensive RLM guidance:
cp -r .claude/skills/ /Users/your_username/your-project/.claude/skills/
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
| Aspect | rlm_setup_ollama (Homebrew) | rlm_setup_ollama_direct (Direct Download) | |--------|------------------------------|---------------------------------------------| | Sudo required | Only if Homebrew not installed | ❌ Never | | Homebrew required | ✅ Yes | ❌ No | | Auto-updates | ✅ Yes (brew upgrade) | ❌ Manual | | Service management | ✅ brew services (launchd) | ⚠️ ollama serve (foreground) | | Install location | /opt/homebrew/ | ~/Applications/ | | Locked-down machines | ⚠️ May fail | ✅ Works | | Fully headless | ⚠️ May prompt for sudo | ✅ Yes |
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)
# 1. Check if your system meets requirements
rlm_system_check()
# 2. Install via Homebrew
rlm_setup_ollama(install=True, start_service=True, pull_model=True)
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)
# 1. Check system (Homebrew NOT required for this method)
rlm_system_check()
# 2. Install via direct download - no sudo, no Homebrew
rlm_setup_ollama_direct(install=True, start_service=True, pull_model=True)
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:
~/Applications/Ollama.app/Contents/Resources/ollama
Add to your shell config if needed:
export PATH="$HOME/Applications/Ollama.app/Contents/Resources:$PATH"
For Systems with Less RAM
Use a smaller model on either installation method:
rlm_setup_ollama(install=True, start_service=True, pull_model=True, model="gemma3:4b")
# or
rlm_setup_ollama_direct(install=True, start_service=True, pull_model=True, model="gemma3:4b")
Manual Setup
If you prefer manual installation or are on a different platform:
- Install Ollama from https://ollama.ai or via Homebrew:
``bash brew install ollama ``
- Start the service:
``bash brew services start ollama # or: ollama serve ``
- Pull the model:
``bash ollama pull gemma3:12b ``
- Verify it's working:
``python rlm_ollama_status() ``
Provider Selection
RLM automatically uses Ollama when available. You can also force a specific provider:
# Auto-detection (default) - uses Ollama if available
rlm_sub_query(query="Summarize", context_name="doc")
# Explicitly use Ollama
rlm_sub_query(query="Summarize", context_name="doc", provider="ollama")
# Explicitly use Claude SDK
rlm_sub_query(query="Summarize", context_name="doc", provider="claude-sdk")
Usage Example
Basic Pattern
# 0. (Optional) First-time setup on macOS - choose ONE method:
# Option A: Homebrew (if you have it)
rlm_system_check()
rlm_setup_ollama(install=True, start_service=True, pull_model=True)
# Option B: Direct download (no sudo, fully headless)
rlm_system_check()
rlm_setup_ollama_direct(install=True, start_service=True, pull_model=True)
# 0b. (Optional) Check if Ollama is available for free inference
rlm_ollama_status()
# 1. Load a large document
rlm_load_context(name="report", content=)
# 2. Inspect structure
rlm_inspect_context(name="report", preview_chars=500)
# 3. Chunk into manageable pieces
rlm_chunk_context(name="report", strategy
…
## Source & license
This open-source MCP server is cataloged on AgentStack and links to its original source — we do not rehost the code.
- **Author:** [egoughnour](https://github.com/egoughnour)
- **Source:** [egoughnour/massive-context-mcp](https://github.com/egoughnour/massive-context-mcp)
- **License:** MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet — be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.