Prerelease This site documents an alpha of libtmux. Its structure, URLs and APIs are subject to change.

libtmux_mcp.middleware.TailPreservingResponseLimitingMiddleware

Python
  • Python
  • Ruby Unavailable
  • Lua Unavailable
  • TypeScript Unavailable
  • Rust Unavailable
  • Go Unavailable
  • Java Unavailable
  • .NET Unavailable
  • C++ Unavailable
  • Swift Unavailable

API reference · Markdown

class libtmux_mcp.middleware.TailPreservingResponseLimitingMiddleware
class [source]
class [source]
class libtmux_mcp.middleware.TailPreservingResponseLimitingMiddleware
Bases:
  • ResponseLimitingMiddleware

Response-limiter that keeps the tail of oversized output.

FastMCP's stock ResponseLimitingMiddleware truncates 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_result to 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 , and libtmux_mcp.tools.pane_tools.search_panes , plus libtmux_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_error flag 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

on_call_tool ( self , context : MiddlewareContext , call_next : t.Any ) → t.Any
methodasync [source]
methodasync [source]
on_call_tool

Apply the size cap without dropping is_error.

Esc

Type to search.