Matryoshka
MCP server for token-efficient large document analysis via the use of REPL state
What is Matryoshka?
Matryoshka is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to mcp server for token-efficient large document analysis via the use of repl state
MCP server for token-efficient large document analysis via the use of REPL state
This server falls under the Data Science & ML category on MCPgee, the world's largest MCP server directory with 33,000+ servers.
Features
- MCP server for token-efficient large document analysis via t
Use Cases
Maintainer
Works with
Installation
Manual Installation
npx matryoshkaConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
How to Set Up and Use Matryoshka
Matryoshka is a TypeScript/Clojure MCP server that enables token-efficient analysis of large documents and codebases by maintaining a persistent REPL state (called a Lattice) across tool calls, avoiding the need to resend entire documents on every query. It exposes a rich set of MCP tools for grep, fuzzy search, BM25, semantic search, code symbol navigation, data filtering, LLM sub-queries, and recursive multi-turn analysis — making it practical to analyze log files, codebases, or large text corpora that would otherwise overflow context windows. Data scientists and engineers use it to interrogate large artifacts in Claude without hitting token limits.
Prerequisites
- Node.js 18+ and pnpm installed (npm install -g pnpm)
- A local LLM accessible via Ollama (recommended) or an API key for a cloud provider like DeepSeek
- The matryoshka-rlm package installed globally (pnpm add -g matryoshka-rlm)
- An MCP-compatible client such as Claude Desktop or Claude Code
Install Matryoshka globally via pnpm
Install the matryoshka-rlm package globally to make the CLI tools available on your PATH.
pnpm add -g matryoshka-rlmCreate the configuration file
Create ~/.config/matryoshka/config.json to configure your LLM provider. This example uses Ollama with a local model.
mkdir -p ~/.config/matryoshka
cat > ~/.config/matryoshka/config.json << 'EOF'
{
"llm": { "provider": "ollama" },
"providers": {
"ollama": {
"url": "http://localhost:11434/api/generate",
"model": "qwen3-coder:30b",
"options": { "temperature": 0.2, "num_ctx": 8192 }
}
},
"rlm": { "maxTurns": 10 }
}
EOFTest Matryoshka from the CLI
Run a quick test using the rlm CLI tool against a local file to confirm the installation works.
rlm "How many ERROR entries are there?" ./server.logAdd the lattice-mcp server to your MCP client configuration
Edit your Claude Desktop config to register the lattice-mcp server which provides the full set of Lattice MCP tools.
{
"mcpServers": {
"lattice": {
"command": "lattice-mcp",
"args": []
}
}
}Alternatively, use npx without installing
You can run Matryoshka without a global install using npx for one-off document queries.
npx matryoshka-rlm "Summarize all WARN log entries" ./application.logLoad and query a document in Claude
In Claude, use lattice_load to open a file into the REPL state, then query it with lattice_query using Nucleus expressions.
Matryoshka Examples
Client configuration
Claude Desktop configuration for the Matryoshka lattice-mcp server.
{
"mcpServers": {
"lattice": {
"command": "lattice-mcp",
"args": []
}
}
}Prompts to try
Prompts that leverage Matryoshka's token-efficient large document analysis capabilities.
- "Load /var/log/app.log into Lattice and count all ERROR entries"
- "Search the loaded document for all references to 'OutOfMemoryError' and show me the surrounding context"
- "List all function symbols defined in /path/to/project/src/main.ts"
- "Find all callers of the function processPayment in the codebase loaded into Lattice"
- "Run a BM25 search over the document for 'database connection timeout'"
- "Use rlm to analyze /path/to/large-dataset.csv and tell me the distribution of values in column 3"Troubleshooting Matryoshka
lattice-mcp command not found after installation
Ensure pnpm's global bin directory is on your PATH. Run 'pnpm bin -g' to find the directory and add it to your shell profile (e.g., export PATH="$(pnpm bin -g):$PATH" in ~/.zshrc). Restart your terminal or MCP client after updating PATH.
LLM provider connection refused or timeout
If using Ollama, ensure it is running: 'ollama serve'. Verify the model is downloaded: 'ollama pull qwen3-coder:30b'. Confirm the URL in config.json matches your Ollama instance (default: http://localhost:11434). For cloud providers, check that your API key is set via the '${ENV_VAR}' interpolation syntax in config.json.
lattice_load fails on very large files
Matryoshka is designed for large files but the underlying Nucleus engine still has memory limits. Try splitting extremely large files (>1GB) into chunks before loading. Reduce num_ctx in config.json if your local model runs out of VRAM during sub-queries.
Frequently Asked Questions about Matryoshka
What is Matryoshka?
Matryoshka is a Model Context Protocol (MCP) server that mcp server for token-efficient large document analysis via the use of repl state It connects AI assistants to external tools and data sources through a standardized interface.
How do I install Matryoshka?
Follow the installation instructions on the Matryoshka GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.
Which AI clients work with Matryoshka?
Matryoshka works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.
Is Matryoshka free to use?
Yes, Matryoshka is open source and available under the Apache-2.0 license. You can use it freely in both personal and commercial projects.
Matryoshka Alternatives — Similar Data Science & ML Servers
Looking for alternatives to Matryoshka? Here are other popular data science & ml servers you can use with Claude, Cursor, and VS Code.
Ultrarag
★ 5.6kA Low-Code MCP Framework for Building Complex and Innovative RAG Pipelines
RocketRide
★ 3.1k📇 🏠 - MCP server that exposes RocketRide AI pipelines as t
Aix Db
★ 2.1kAix-DB 基于 LangChain/LangGraph 框架,结合 MCP Skills 多智能体协作架构,实现自然语言到数据洞察的端到端转换。
NeMo Data Designer
★ 1.9k🎨 NeMo Data Designer: Generate high-quality synthetic data from scratch or from seed data.
PaperBanana
★ 1.7kOpen source implementation and extension of Google Research’s PaperBanana for automated academic figures, diagrams, and research visuals, expanded to new domains like slide generation.
MiniMax
★ 1.5kBridges MiniMax AI capabilities to the Model Context Protocol, enabling AI agents to perform image understanding, text-to-image generation, and speech synthesis. It provides a standardized interface for accessing MiniMax's core tools via JSON-RPC.
Browse More Data Science & ML MCP Servers
Explore all data science & ml servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.
Set Up Matryoshka in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
Ready to use Matryoshka?
Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.