libtmux_mcp.middleware.TailPreservingResponseLimitingMiddleware
Python
- Python
- Ruby Unavailable
- Lua Unavailable
- TypeScript Unavailable
- Rust Unavailable
- Go Unavailable
- Java Unavailable
- .NET Unavailable
- C++ Unavailable
- Swift Unavailable
- Bases:
- ResponseLimitingMiddleware
Response-limiter that keeps the tail of oversized output.
FastMCP's stock
ResponseLimitingMiddlewaretruncates the tail of the response (keeps the start, appends a suffix). That's exactly wrong for terminal scrollback, where the active shell prompt and most recent command output live at the bottom of the buffer. This subclass overrides_truncate_to_resultto drop the head instead, prefixing a single truncation-header line so callers can detect the cap fired.Used as a backstop for
libtmux_mcp.tools.pane_tools.capture_pane,libtmux_mcp.tools.pane_tools.capture_since,libtmux_mcp.tools.pane_tools.snapshot_pane, andlibtmux_mcp.tools.pane_tools.search_panes, pluslibtmux_mcp.tools.buffer_tools.show_buffer. Per-tool caps at the tool layer fire first under normal operation; this middleware catches a missed bound within that configured high-volume set.Error results keep their
is_errorflag through truncation. The stock truncation path rebuilds the result without it, which turns an oversized error (e.g. a validation message echoing a huge argument) into an apparent success — MCP clients then validate the truncated text against the tool's output schema and fail with a transport-level error instead of delivering the tool error.meta(error_type/expected/suggestion) already survives via the base class, and tail-preservation keeps the suggestion line, which sits at the end of the text.
Members
- on_call_tool ( self , context : MiddlewareContext , call_next : t.Any ) t.Any
-
Apply the size cap without dropping
is_error.