
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 分