
flatten-mcp
@shayaShav
关于 flatten-mcp
An MCP server that flattens Claude Code sessions — keeping every prompt and event verbatim while reclaiming context tokens, so you resume the exact same raw conversation at a lower token count instead of compacting it into a lossy summary. It moves bulky tool output (large file r
基本信息
配置
使用下面的配置,将此服务器添加到你的 MCP 客户端。
{
"mcpServers": {
"flatten": {
"command": "npx",
"args": [
"-y",
"flatten-mcp@latest"
]
}
}
}工具
6Move bulky tool results into a sidecar, leaving `[FLATTENED …]` markers. Crash-safe and reversible. Supports `dry_run`, `min_size`, `force`, and `include_tool_use_result`.
Fetch one original block back by its id — returns the original text, or re-renders a flattened screenshot as a real image.
Reverse a flatten completely: re-inline every block from the sidecar, restoring each flattened result to its exact original value.
Reclaim disk by deleting leftover `.bak` / `.tmp` files (and, opt-in, sidecars). Defaults to a safe dry run.
List a project's sessions with branch, message count, size, and first prompt.
Keyword / branch / date search across past sessions — scans prose, tool I/O, **and** flatten sidecars so nothing goes dark after flattening.
概览
What is flatten-mcp?
flatten-mcp is a Model Context Protocol server for Claude Code that reduces a session's token footprint by moving bulky tool output (large file reads, command logs, base64 screenshots) into a sidecar file, leaving a lightweight retrievable reference in its place. It preserves the exact chronological flow and all user prompts verbatim.
How to use flatten-mcp?
Requires Node.js ≥ 18 and Claude Code. Install user-wide via claude mcp add flatten -s user -- npx -y flatten-mcp@latest. To flatten a session, exit it with Ctrl‑C, then in a new Claude Code window use the /flatten latest or /flatten <session-id> command, or ask the model directly. Resume the original session afterward. Dry runs and unflatten are supported.
Key features of flatten-mcp
- Lossless and reversible – unflatten restores every block to its exact original value
- Idempotent – re‑running skips already‑flattened blocks
- Crash‑safe – originals are persisted to sidecar before removal, with atomic file writes
- Reports both disk bytes saved and context tokens saved
- Provides compact
[FLATTENED …]markers with retrieval instructions - Includes tools for preview, retrieval, unflatten, and artifact cleanup
Use cases of flatten-mcp
- Reclaim context window space in token‑heavy sessions (around 200k–300k tokens)
- Preserve verbatim conversation history without lossy compaction
- Retrieve original block content on demand via
retrieve_flattened - Run a dedicated inexpensive model window as a flatten‑only station
FAQ from flatten-mcp
How does flatten differ from compaction?
Compaction rewrites the entire history into a lossy summary. Flatten instead moves only the bulky tool output to a sidecar while keeping every user and assistant message untouched, making it lossless.
Is flatten reversible?
Yes. unflatten_session re‑inlines every block from the sidecar, restoring each flattened result to its exact original value.
What are the system requirements?
Node.js ≥ 18 and Claude Code. The server is installed from npm and registered as a Claude Code MCP server.
Does flatten work with agents other than Claude Code?
No. flatten-mcp reads Claude Code’s session store at ~/.claude/projects/*.jsonl and is tested exclusively with Claude Code. The paths and JSONL schema are specific to it.
How does the server handle interruptions or crashes?
The session file is rewritten atomically via temp‑file‑and‑rename, and originals are written to the sidecar before removal from the session. An interrupted run never leaves a half‑written session file.
AI 与智能体 分类下的更多 MCP 服务器
Shell and Coding agent for Claude and other mcp clients
rusiaamanShell and coding agent on mcp clients
欢迎来到 智言平台
Shy2593666979AgentChat 是一个基于 LLM 的智能体交流平台,内置默认 Agent 并支持用户自定义 Agent。通过多轮对话和任务协作,Agent 可以理解并协助完成复杂任务。项目集成 LangChain、Function Call、MCP 协议、RAG、Memory、HITL、Skill、Milvus 和 ElasticSearch 等技术,实现高效的知识检索与工具调用,使用 FastAPI 构建高性能后端服务。
Unreal Engine Generative AI Support Plugin
prajwalshettydevUnreal Engine plugin for LLM/GenAI models & MCP UE5 server. OpenAI GPT-5, Deepseek R1, Claude Opus/Sonnet, Gemini 3, Grok 4, Alibaba Qwen, Kimi, ElevenLabs TTS, Inworld, OpenRouter, Groq, GLM, Ollama, Local, Meshy, Tripo, Hunyuan3D, Rodin, fal, Dashscope, Seedream. NPC AI, agenti
MCP Claude Code
SDGLBLMCP implementation of Claude Code capabilities and more
Solon Ai
opensolonJava AI application development framework (supports LLM-tool,skill; RAG; MCP; Agent-ReAct,Team-Agent). Compatible with java8 ~ java25. It can also be embedded in SpringBoot, jFinal, Vert.x, Quarkus, and other frameworks.
评论