# Matryoshka

> Analyze large documents with constrained symbolic commands and compact results.

- **URL**: https://followmcp.com/en/servers/matryoshka
- **Category**: Dev Tools
- **Origin**: Community
- **Stars**: 151
- **FMRS Score**: 51/100 (Grade D)
- **Source**: https://github.com/yogthos/Matryoshka
- **Transports**: stdio (local process)
- **Runtimes**: Node.js
- **Auth**: No credential needed

## Overview
Matryoshka provides MCP document analysis using the Nucleus symbolic language and the Lattice engine. Query results can be stored server-side and returned as compact handles. The README also describes memos, code-symbol extraction, and approximate code relationship graphs.

## Best for
- Users analyzing text that exceeds a model's context window.
- Developers who want constrained document operations through Nucleus commands.
- Agent workflows that store context in session memos and expand it later.

## Not for
- Workflows that require the entire document to be read directly into model context.
- Users needing precise, language-server-grade code relationship analysis; the README describes the graph results as heuristic approximations.
- Users requiring MCP multi-document loading or concurrent recursive batches; the README says multi-document loading is not exposed in MCP and recursive batches run sequentially.

## Required permissions
- The stdio client configuration must be able to launch lattice-mcp.
- Loading a document requires access to the supplied document path; exact file permissions depend on the runtime environment.
- Using an external LLM provider requires its URL and model configuration, and may require an API key.

## Risks
- Nucleus commands are parsed and type-checked, and the README says only known operations are executed; loaded documents may still contain misleading or malicious text.
- The MCP service keeps session memory and document data; close the session when finished.
- The code relationship graph uses line-based heuristics and may miss or misidentify relationships.
- External LLM provider settings may send prompts and related content to the configured service.

## Client config (JSON)
```json
{"mcp":{"lattice":{"type":"stdio","command":"lattice-mcp"}}}
```

## Tools (12)
- `lattice_load`: Load a document for analysis.
- `lattice_query`: Run Nucleus commands against the loaded document.
- `lattice_expand`: Expand a handle to view its data, with optional limit and offset.
- `lattice_memo`: Store context as a memo handle without requiring a loaded document.
- `lattice_memo_delete`: Delete a stale memo to free memory.
- `lattice_close`: Close the session and free memory.
- `lattice_status`: Get session status, document information, and memo usage.
- `lattice_bindings`: Show current variable bindings and memo labels.
- `lattice_reset`: Reset bindings and memos while keeping the loaded document.
- `lattice_llm_respond`: Respond to a pending llm_query suspension.
- `lattice_llm_batch_respond`: Submit all responses for a pending llm_batch request.
- `lattice_help`: Get the Nucleus command reference.
