
Massive Context Mcp
io.github.egoughnour由 GitHub 账号 egoughnour 发布v3.0.1更新于 Oct 24, 2026
Handles 10M+ token contexts with chunking, sub-queries, and local Ollama inference.
概览
让助手把超大文档作为外部上下文加载、分块,并用本地 Ollama 或 Claude 子查询进行分析。
- 可以做什么
- Massive Context MCP 实现递归语言模型模式:把大文档作为外部变量加载,检查并按行、字符或段落分块,对分块并行执行子查询,再汇总结果。工具包括一步式分析的 rlm_auto_analyze,以及 rlm_load_context、rlm_inspect_context、rlm_chunk_context、rlm_sub_query、rlm_sub_query_batch,还有在沙箱中针对已加载上下文执行 Python 的 rlm_exec。安装与状态工具可检查系统要求并检测或安装 Ollama。
- 适用场景
- 当文档太大、无法放入模型上下文,且需要对其做摘要、查找缺陷、提取结构、安全审计或回答自定义问题时适用。也可通过 rlm_exec 对大文件做确定性的正则或数据提取。
- 运行要求
- 以 stdio 本地运行,可从 PyPI(uvx 或 pip)或 .mcpb 包安装;仅支持桌面端。可选环境变量:OLLAMA_URL(默认 RLM_DATA_DIR。免费本地推理需要 Ollama 及 gemma3 模型,否则子查询回退到 Claude SDK。README 说明本地模型安装需要 Apple Silicon 的 macOS 和 16GB 以上内存。
安装
在 SourceWeft 中
- 打开 控制台中的 Massive Context Mcp,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
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
来源:README.md,提交 5ee4ad4
工具
0版本历史
1- v3.0.1最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分