mcpField
F
flatten-mcp

flatten-mcp

Local
github.com/shayaShavAI & Agents0

About 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

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

mcp.json · Universal config
{
"mcpServers": {
"flatten": {
"command": "npx",
"args": [
"-y",
"flatten-mcp"
]
}
}
}
Run commandnpx -y flatten-mcp

Local servers need a runtime on your machine (e.g. Node.js 18+). Config file locations differ by client; see your client’s docs.

Packages
npmflatten-mcp

Tools

3

Saved tool list · updated 3w ago

ParameterTypeRequiredDescription
session_idstringNoSession UUID, "last", "last N", or "current". Omit to flatten the current live session (claude); under codex "current" falls back to "last".
sessionIdstringNocamelCase alias for session_id (accepted so a camelCase call does not fail validation).
agentenumNoWhich agent's session store to target: "claude" (default) or "codex".claude | codex
project_dirstringNoAbsolute path to project. Default: the project the CLI runs in (cwd). Under codex, scopes "last"/"last N"/keyword to rollouts whose cwd equals this dir.
claude_dirstringNoAbsolute path (or ~/...) to the Claude config dir whose sessions to target — the dir holding projects/. Default: $CLAUDE_CONFIG_DIR if set, else ~/.claude. Applies to agent "claude" only.
codex_homestringNoAbsolute path (or ~/...) to the Codex home whose sessions to target — the dir holding sessions/. Default: $CODEX_HOME if set, else ~/.codex. Applies to agent "codex" only.
min_sizenumberNoOnly flatten tool results larger than N bytes
dry_runbooleanNoReport what would be flattened without modifying files
include_tool_use_resultbooleanNoAlso flatten the top-level toolUseResult mirror Claude Code keeps per result line (roughly doubles disk savings; lossless & restorable). Set false to only touch message.content.
breakdownanyNoInclude the per-tool/resource breakdown of what was flattened. false, true, or "summary" = the aggregated adaptive rows plus byKind/bySlot groupings; "deep" ALSO lists every individual block under its row (tool + arg summary + bytes + per-block token estimate), groups sorted by context tokens then blocks by bytes. Dry runs always include at least the summary; set true/"summary"/"deep" to also get it on a real flatten.

Details

The maintainer has not added details yet. Check the README in the repository.

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.