From ec3afdc1d8be469e5fcb5086286a20f5e4fd1a84 Mon Sep 17 00:00:00 2001 From: Jeremiah Lowin <153965+jlowin@users.noreply.github.com> Date: Fri, 6 Feb 2026 18:10:18 -0500 Subject: [PATCH] Add note about output_schema incongruity when responses are truncated --- docs/servers/middleware.mdx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/servers/middleware.mdx b/docs/servers/middleware.mdx index ddf283fb9..cea5d3c27 100644 --- a/docs/servers/middleware.mdx +++ b/docs/servers/middleware.mdx @@ -585,6 +585,10 @@ def search(query: str) -> str: When a response exceeds the limit, the middleware extracts all text content, joins it together, truncates to fit within the limit, and returns a single `TextContent` block. For non-text responses, the serialized JSON is used as the text source. + +If a tool defines an `output_schema`, truncated responses will no longer conform to that schema — the client will receive a plain `TextContent` block instead of the expected structured output. Keep this in mind when setting size limits for tools with structured responses. + + ```python # Limit only specific tools mcp.add_middleware(ResponseLimitingMiddleware(