Matryoshka

v1.0.0Data Science & MLstable

MCP server for token-efficient large document analysis via the use of REPL state

ai-assistantdocument-analysisllmllm-toolsmcp
Share:
134
Stars
0
Downloads
0
Weekly
0/5

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

Analyze large documents token-efficiently
Use REPL state for complex tasks
Process multi-layered document structures
yogthos

Maintainer

LicenseApache-2.0
Languagetypescript
Versionv1.0.0
UpdatedMay 17, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx matryoshka

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

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
1

Install Matryoshka globally via pnpm

Install the matryoshka-rlm package globally to make the CLI tools available on your PATH.

pnpm add -g matryoshka-rlm
2

Create 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 }
}
EOF
3

Test 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.log
4

Add 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": []
    }
  }
}
5

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.log
6

Load 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.

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.

Quick Config Preview

{ "mcpServers": { "matryoshka": { "command": "npx", "args": ["-y", "matryoshka"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

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.

33,000+ ServersFree & Open SourceStep-by-Step Guides