1. Conduid
  2. AI
  3. Matryoshka
MCP server · AI

Matryoshka

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

75Good

Scored just now · breakdown

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 Code
claude mcp add matryoshka -- npx -y matryoshka-rlm
npx
npx -y matryoshka-rlm
From source
git clone https://github.com/yogthos/Matryoshka

Tools (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.
ParameterTypeDescription
filePath *stringPath to the document file to analyze
maxTurnsnumberMaximum number of exploration turns (default: 10)
query *stringThe question or task to perform on the document
timeoutMsnumberHard 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.
ParameterTypeDescription
optionsobjectOptional settings: { format: 'json' | 'text' }. Applied to all prompts.
prompts *arrayArray of prompt strings to execute in parallel
context.matchSearch context with a regular expression. Returns all matches.
ParameterTypeDescription
flagsstringRegex flags (e.g., "gi" for global case-insensitive)
pattern *stringRegex 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.
ParameterTypeDescription
end *numberEnd character index (exclusive)
start *numberStart 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).
ParameterTypeDescription
textstringText 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.
ParameterTypeDescription
limitnumberMaximum number of results to return
query *stringSingle 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.
ParameterTypeDescription
flagsstringRegex flags (g, m, i are included by default for global multiline case-insensitive search)
pattern *stringRegex pattern to search for
lattice_bindingsShow current variable bindings and memo labels
lattice_closeClose the session and free memory
lattice_expandExpand a handle to see full data (with optional limit/offset)
ParameterTypeDescription
formatstring"full" for complete objects, "lines" for readable line format
handle *stringHandle reference to expand (e.g., "$grep_error")
limitnumberMaximum number of items to return (default: all)
offsetnumberNumber of items to skip (for pagination)
lattice_helpGet Nucleus command reference
lattice_llm_batch_respondRespond to a pending `(llm_batch ...)` suspension with all N responses
ParameterTypeDescription
id *stringThe batch ID from the LLM_BATCH_REQUEST message
responses *arrayArray of responses in prompt order — must have exactly count entries
lattice_llm_respondRespond to a pending `(llm_query ...)` suspension
ParameterTypeDescription
id *stringThe query ID from the LLM_QUERY_REQUEST message
response *stringYour response to the prompt
lattice_loadLoad a document for analysis
ParameterTypeDescription
filePath *stringPath to the document to analyze
lattice_memoStore arbitrary context as a memo handle (no document required)
ParameterTypeDescription
content *stringThe text content to store (file summary, analysis, plan, etc.)
label *stringShort label describing this memo (shown in handle stub)
lattice_memo_deleteDelete a stale memo to free memory
ParameterTypeDescription
handle *stringMemo handle to delete (e.g., "$memo_auth_architecture")
lattice_queryExecute Nucleus commands on the loaded document
ParameterTypeDescription
command *stringNucleus S-expression, e.g., (grep "ERROR")
lattice_resetReset all bindings and memos but keep document loaded
lattice_statsGet statistics about the currently loaded document.
lattice_statusGet session status, document info, and memo usage
llm_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.
ParameterTypeDescription
optionsobjectOptional settings: { format: 'json' | 'text' }. Use 'json' to force structured JSON output.
prompt *stringThe 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.
ParameterTypeDescription
endnumberEnd line number (inclusive, defaults to start for single line)
start *numberStart 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)
ParameterTypeDescription
command *stringNucleus S-expression command to execute (e.g., '(grep "ERROR")')
filePath *stringPath to the document file to analyze
sessionIdstringOptional 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

v0.2.9v0.2.9
v0.2.6v0.2.6
v0.2.5v0.2.5

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
Questions

About Matryoshka

How do I install Matryoshka?

In Claude Code, run claude mcp add matryoshka -- npx -y matryoshka-rlm. Other MCP clients take the command after "--" in their server configuration.

Is Matryoshka safe to use with an AI agent?

Its trust score is 75 out of 100 (good). It passes 4 of the 6 static checks Conduid ran on the repository; it does not pass No dynamic code execution and Scoped permissions. Conduid's scan of 119 source files found that it serves MCP over stdio and makes outbound network calls (1 call). Its dependencies are pinned by pnpm-lock.yaml. It has no ConduID identity yet, so agent calls to it are not receipted.

Is Matryoshka still maintained?

The last commit was 6 months ago. That's long enough that you should check whether the maintainer is responding to issues before depending on it.

What tools does Matryoshka provide?

Conduid read 25 tools from the source: analyze_document, batch_llm_query, context.match, context.slice, count_tokens, fuzzy_search, grep, lattice_bindings and 17 more. 17 of them publish their parameters, listed under Tools above.

What license is Matryoshka released under?

The repository declares the Apache-2.0 license. That applies to the latest release, v0.2.9, as well.