flatten-mcp
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| ANTHROPIC_API_KEY | No | If set, token savings are counted exactly via Anthropic's free count_tokens endpoint instead of estimated locally. | |
| FLATTEN_COUNT_MODEL | No | Model id used for the exact token count. | claude-haiku-4-5-20251001 |
Capabilities
Features and capabilities supported by this server
| Capability | Details |
|---|---|
| tools | {
"listChanged": true
} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| list_sessionsB | List Claude Code sessions for a project with metadata (sessionId, branch, message count, file size, first user message). |
| search_sessionsA | Search past sessions by keyword, date range, or git branch. Scans prose, tool I/O, and flatten sidecars; returns matching sessions with a match count and a text preview. |
| flatten_sessionA | Flatten a session: move bulky tool results (large text output and base64 image/screenshot blocks) out of the session JSONL into a sidecar file, leaving a lightweight [FLATTENED ...] marker in their place. The conversation reads identically — every prompt and event stays verbatim — but resumes with far fewer context tokens. Crash-safe (atomic rewrite + idempotent sidecar) and fully reversible via unflatten_session. Reports diskBytesSaved (file shrink, affects --resume parse speed) and contextTokensSaved out of contextTokensTotal (the number that matters for compaction); token savings are estimated locally, or exact when ANTHROPIC_API_KEY is set. Accepts a UUID, "last", "last N", or "current". Refuses to rewrite a session edited in the last 10s (likely live) unless force=true. |
| retrieve_flattenedA | Retrieve original tool result content from a flattened session. When you see [FLATTENED id=XXX tool=Read ... | text NNNB/NNL | session=YYY | ...] in the conversation, call this with the value after "id=" as tool_use_id and the value after "session=" as session_id. Returns the original text output, or — for flattened screenshots — the actual image so you can view it again. |
| unflatten_sessionA | Reverse a flatten: re-inline every flattened tool result (text and images) back into the session JSONL from its sidecar, restoring the session to its pre-flatten state. Snapshots the flattened file to .preunflatten.bak first. |
| prune_flatten_artifactsA | Reclaim disk by deleting leftover flatten artifacts (.bak, .preunflatten.bak, and stale .tmp- files) for a project. By default keeps .flat.jsonl sidecars (retrieve_flattened needs them) and runs dry. Set include_sidecars=true only when you no longer need to retrieve/unflatten those sessions. |
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
No prompts | |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
No resources | |
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/shayaShav/flatten-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server