flatten-mcp
Server Details
Cut a Claude Code session's context tokens losslessly — the reversible alternative to /compact.
- Status
- Healthy
- Last Tested
- Transport
- Streamable HTTP
- URL
Glama MCP Gateway
Connect through Glama MCP Gateway for full control over tool access and complete visibility into every call.
Full call logging
Every tool call is logged with complete inputs and outputs, so you can debug issues and audit what your agents are doing.
Tool access control
Enable or disable individual tools per connector, so you decide what your agents can and cannot do.
Managed credentials
Glama handles OAuth flows, token storage, and automatic rotation, so credentials never expire on your clients.
Usage analytics
See which tools your agents call, how often, and when, so you can understand usage patterns and catch anomalies.
Tool Definition Quality
Average 4.7/5 across 2 of 2 tools scored.
The two tools have completely distinct roles: one flattens messages, the other restores them. No overlap or ambiguity.
Both tools follow a consistent verb_noun pattern (flatten_messages, unflatten_messages), making their purpose clear.
Two tools is minimal but perfectly scoped for a single compression/decompression pair, though slightly on the low end.
The pair provides a complete cycle for flattening and unflattening tool results; no missing operations for the defined purpose.
Available Tools
2 toolsflatten_messagesFlatten messages[] (in memory)ARead-onlyIdempotentInspect
Flatten a raw Anthropic Messages API messages[] array in memory: every bulky tool_result block (large text or base64 image) larger than min_size bytes is swapped for a compact [FLATTENED id=...] marker, and the originals are returned in "extracted". Persist "extracted" yourself — you are the store — and feed it back to unflatten_messages to restore the conversation byte-for-byte. Purely functional: no session file, no disk, no network; the input is never mutated. This is the same engine as the flatten-mcp library export; for production use inside your own process, prefer importing the library so the conversation does not travel over a transport.
| Name | Required | Description | Default |
|---|---|---|---|
| messages | Yes | The raw Messages API messages[] array ({ role, content } objects, verbatim). | |
| min_size | No | Only flatten tool_result blocks larger than N serialized bytes. |
Output Schema
| Name | Required | Description |
|---|---|---|
| messages | Yes | The flattened messages[] array — safe to send — with every bulky tool_result replaced by a compact [FLATTENED id=...] marker. Deep-copied; the input is never mutated. |
| extracted | Yes | The originals removed from the conversation. Persist this array yourself and pass it back to unflatten_messages to restore byte-for-byte. |
| flattenedCount | Yes | How many tool_result blocks were flattened. |
| contextTokensExact | Yes | Always false here — the in-memory tool never makes a network call; use the library flattenMessagesExact for an exact count. |
| contextTokensSaved | Yes | Estimated context tokens removed from the conversation. |
| imageBlocksFlattened | Yes | How many image blocks were among the flattened results. |
Tool Definition Quality
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already declare readOnlyHint and idempotentHint. The description adds valuable context: 'purely functional: no session file, no disk, no network; the input is never mutated', and explains the output format including the 'extracted' array. Does not contradict annotations.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Single paragraph with dense, front-loaded information. Every sentence adds value, though slightly verbose with the library export detail. Still efficient for the included depth.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
With output schema present, no need to detail return values. The description covers the process, persistence expectation, and relationship to sibling tool. No gaps given the tool's complexity.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100%, so baseline is 3. The description adds meaning by characterizing 'messages' as 'verbatim raw API' and explaining the 'min_size' threshold for flattening. This additional context justifies a 4.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description uses a specific verb ('Flatten') and resource ('raw Anthropic Messages API messages[] array'), clearly differentiates from sibling 'unflatten_messages', and explains the mechanism (replacing bulky tool_result blocks with markers).
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Explicitly states when to use (in-memory flattening for transport), what to do with the extracted data ('Persist "extracted" yourself'), and mentions the alternative library import for production. Also references the complementary sibling 'unflatten_messages'.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
unflatten_messagesUnflatten messages[] (in memory)ARead-onlyIdempotentInspect
Restore a conversation flattened by flatten_messages: re-inlines every tool_result whose content is a [FLATTENED id=...] marker from the matching entry in "extracted", byte-for-byte. Markers with no matching entry are left in place. Purely functional — no disk, no network, input never mutated.
| Name | Required | Description | Default |
|---|---|---|---|
| messages | Yes | The flattened messages[] array (the "messages" field of a flatten_messages result). | |
| extracted | Yes | The "extracted" array returned by flatten_messages for this conversation. |
Output Schema
| Name | Required | Description |
|---|---|---|
| messages | Yes | The restored messages[] array, byte-for-byte identical to the pre-flatten conversation. Any [FLATTENED id=...] marker with no matching extracted entry is left in place. |
Tool Definition Quality
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already provide readOnlyHint=true and idempotentHint=true. The description adds valuable behavioral context: byte-for-byte restoration, handling of missing markers (left in place), and pure functional nature (no mutation). No contradictions with annotations.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is two sentences, each earning its place. The main action is front-loaded, and no extraneous information is included.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The description is complete for the tool's complexity. Annotations and the presence of an output schema (not shown but indicated) reduce the need for extensive return value details. The description covers behavior, edge cases (missing markers), and safety (purely functional).
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the schema already documents the parameters. The description adds context by specifying that messages is the output of flatten_messages and extracted is the corresponding array, which provides semantic meaning beyond the generic schema descriptions.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb 'restore' and the resource 'conversation flattened by flatten_messages', with specific details about re-inlining markers byte-for-byte. It effectively distinguishes from the sibling tool 'flatten_messages' by describing the inverse operation.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description notes that the tool is 'purely functional — no disk, no network', implying when it is safe and appropriate to use. It does not explicitly provide when-not-to-use scenarios, but the context is clear as the counterpart to flatten_messages.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Claim this connector by publishing a /.well-known/glama.json file on your server's domain with the following structure:
{
"$schema": "https://glama.ai/mcp/schemas/connector.json",
"maintainers": [{ "email": "your-email@example.com" }]
}The email address must match the email associated with your Glama account. Once published, Glama will automatically detect and verify the file within a few minutes.
Control your server's listing on Glama, including description and metadata
Access analytics and receive server usage reports
Get monitoring and health status updates for your server
Feature your server to boost visibility and reach more users
For users:
Full audit trail – every tool call is logged with inputs and outputs for compliance and debugging
Granular tool control – enable or disable individual tools per connector to limit what your AI agents can do
Centralized credential management – store and rotate API keys and OAuth tokens in one place
Change alerts – get notified when a connector changes its schema, adds or removes tools, or updates tool definitions, so nothing breaks silently
For server owners:
Proven adoption – public usage metrics on your listing show real-world traction and build trust with prospective users
Tool-level analytics – see which tools are being used most, helping you prioritize development and documentation
Direct user feedback – users can report issues and suggest improvements through the listing, giving you a channel you would not have otherwise
The connector status is unhealthy when Glama is unable to successfully connect to the server. This can happen for several reasons:
The server is experiencing an outage
The URL of the server is wrong
Credentials required to access the server are missing or invalid
If you are the owner of this MCP connector and would like to make modifications to the listing, including providing test credentials for accessing the server, please contact support@glama.ai.
Discussions
No comments yet. Be the first to start the discussion!