About Matryoshka
Matryoshka is an MCP server published by yogthos in the AI category: mCP server for token-efficient large document analysis via the use of REPL state. Conduid read 25 tools from its source: analyze_document, batch_llm_query, context.match, context.slice, count_tokens, fuzzy_search and 19 more. It is published to npm as matryoshka-rlm and starts with npx.
The repository has 152 stars and 20 forks, is licensed Apache-2.0, and its last commit was on 17 May 2026. The latest release is v0.2.9. It follows v0.2.6, and the 3 most recent releases go back to v0.2.5. It passes 4 of the 6 static checks Conduid ran on the repository; it does not pass No dynamic code execution and Scoped permissions. Its topics include document-analysis.
Install
claude mcp add matryoshka -- npx -y matryoshka-rlmnpx -y matryoshka-rlmgit clone https://github.com/yogthos/MatryoshkaTools (25)
analyze_documentAnalyze a document using the Recursive Language Model (RLM). The RLM can process documents larger than the context window by iteratively exploring the content with code execution. Use this for complex, open-ended queries that need LLM reasoning.| Parameter | Type | Description |
|---|---|---|
| filePath * | string | Path to the document file to analyze |
| maxTurns | number | Maximum number of exploration turns (default: 10) |
| query * | string | The question or task to perform on the document |
| timeoutMs | number | Hard outer timeout for the entire FSM run, in milliseconds. Default 900000 (15 min). Raise this for slow models or large documents where 10+ turns take longer than the default cap. |
batch_llm_queryExecute multiple LLM queries in parallel. Much faster than sequential llm_query calls when you need to process multiple chunks or sections. All prompts are sent simultaneously.| Parameter | Type | Description |
|---|---|---|
| options | object | Optional settings: { format: 'json' | 'text' }. Applied to all prompts. |
| prompts * | array | Array of prompt strings to execute in parallel |
context.matchSearch context with a regular expression. Returns all matches.| Parameter | Type | Description |
|---|---|---|
| flags | string | Regex flags (e.g., "gi" for global case-insensitive) |
| pattern * | string | Regex pattern as string (e.g., "keyword" or "\\d+" for digits) |
context.sliceGet a portion of the context by character indices. Use sparingly - prefer fuzzy_search to find relevant sections first.| Parameter | Type | Description |
|---|---|---|
| end * | number | End character index (exclusive) |
| start * | number | Start character index (0-based) |
count_tokensEstimate the token count of text. Useful for checking if a section will fit in an LLM call. Uses word-based heuristics (most words = 1 token).| Parameter | Type | Description |
|---|---|---|
| text | string | Text to count tokens for (defaults to full context if omitted) |
fuzzy_searchFind approximate keyword matches using fuzzy string matching. Returns matching lines with line numbers and match scores (lower score = better match). NOTE: Takes a single search term, NOT regex. For regex patterns use grep() instead.| Parameter | Type | Description |
|---|---|---|
| limit | number | Maximum number of results to return |
| query * | string | Single search term (NOT regex - use grep for patterns). Example: 'total' not 'total|sum' |
grepFast regex search with line numbers. More efficient than context.match for finding specific patterns. Returns matches with line numbers and character indices.| Parameter | Type | Description |
|---|---|---|
| flags | string | Regex flags (g, m, i are included by default for global multiline case-insensitive search) |
| pattern * | string | Regex pattern to search for |
lattice_bindingsShow current variable bindings and memo labelslattice_closeClose the session and free memorylattice_expandExpand a handle to see full data (with optional limit/offset)| Parameter | Type | Description |
|---|---|---|
| format | string | "full" for complete objects, "lines" for readable line format |
| handle * | string | Handle reference to expand (e.g., "$grep_error") |
| limit | number | Maximum number of items to return (default: all) |
| offset | number | Number of items to skip (for pagination) |
lattice_helpGet Nucleus command referencelattice_llm_batch_respondRespond to a pending `(llm_batch ...)` suspension with all N responses| Parameter | Type | Description |
|---|---|---|
| id * | string | The batch ID from the LLM_BATCH_REQUEST message |
| responses * | array | Array of responses in prompt order — must have exactly count entries |
lattice_llm_respondRespond to a pending `(llm_query ...)` suspension| Parameter | Type | Description |
|---|---|---|
| id * | string | The query ID from the LLM_QUERY_REQUEST message |
| response * | string | Your response to the prompt |
lattice_loadLoad a document for analysis| Parameter | Type | Description |
|---|---|---|
| filePath * | string | Path to the document to analyze |
lattice_memoStore arbitrary context as a memo handle (no document required)| Parameter | Type | Description |
|---|---|---|
| content * | string | The text content to store (file summary, analysis, plan, etc.) |
| label * | string | Short label describing this memo (shown in handle stub) |
lattice_memo_deleteDelete a stale memo to free memory| Parameter | Type | Description |
|---|---|---|
| handle * | string | Memo handle to delete (e.g., "$memo_auth_architecture") |
lattice_queryExecute Nucleus commands on the loaded document| Parameter | Type | Description |
|---|---|---|
| command * | string | Nucleus S-expression, e.g., (grep "ERROR") |
lattice_resetReset all bindings and memos but keep document loadedlattice_statsGet statistics about the currently loaded document.lattice_statusGet session status, document info, and memo usagellm_queryQuery a sub-LLM to process a chunk of text. Expensive operation - batch related information when possible to minimize calls. Use format: 'json' for structured data extraction.| Parameter | Type | Description |
|---|---|---|
| options | object | Optional settings: { format: 'json' | 'text' }. Use 'json' to force structured JSON output. |
| prompt * | string | The prompt to send to the sub-LLM for processing |
locate_lineExtract lines by line number (1-based). More precise than slice() for line-based navigation. Supports negative indices to count from end.| Parameter | Type | Description |
|---|---|---|
| end | number | End line number (inclusive, defaults to start for single line) |
| start * | number | Start line number (1-based, or negative to count from end) |
nucleus_commandsGet reference documentation for available Nucleus commands. Call this to see all available commands, their syntax, and examples.nucleus_executeExecute Nucleus commands directly on a document without LLM orchestration. Use this for precise, programmatic document analysis when you know exactly what commands to run. Commands use S-expression syntax. Examples: (grep "pattern"), (filter RESULTS (lambda (x) (match x "error" 0))), (count RESULTS)| Parameter | Type | Description |
|---|---|---|
| command * | string | Nucleus S-expression command to execute (e.g., '(grep "ERROR")') |
| filePath * | string | Path to the document file to analyze |
| sessionId | string | Optional session ID for maintaining state across multiple commands |
text_statsGet document metadata WITHOUT reading tokens: length, line count, and 5-line samples from start/middle/end. Use this first to understand document structure.Security checks
Static checks derived from the repository 10 days ago. Heuristics on the source, not an audit.
- ✓README presentThe repository's README runs to about 3.7K words.
- ✓License declaredThe repository declares the Apache-2.0 license.
- ✓Tests presentA test suite exists in the repository.
- ✓Dependencies pinnedDependency versions are pinned by pnpm-lock.yaml.
- !No dynamic code executionScanned 119 source files and found 8 calls to eval or shell execution, in src/constraints/verifier.ts:359, src/logic/synthesis-integrator.ts:814 and src/persistence/predicate-compiler.ts:191 among others. Review how tool inputs reach them before granting credentials.
- !Scoped permissionsDoesn't declare a permission scope. Assume it can do anything its process can.
What the source scan found
- Transport
- stdiosrc/lattice-mcp-server.ts:26
- Starts other programs
- No calls that start other programs
- Outbound network calls
- 1 callsrc/llm/retry.ts:50
- Writes or deletes files
- No file writes or deletes
- Lockfile
- pnpm-lock.yaml
Pattern matches on the source text of 119 files: places to read, not proof of what the code does at run time.
Releases
README
The repository's README runs to about 3.7K words, fetched a month ago. The original in the repository is authoritative.
Read full README