mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-10-14 08:53:20 +02:00
`ResponseLimitingMiddleware` rebuilt an oversized result as a fresh `ToolResult` that kept `meta` but not `is_error`, so truncating a failed tool's output reported the call as a success. The truncated result now carries the original `is_error`, so truncation only changes the size of the result, not whether it succeeded.
```python
mcp.add_middleware(ResponseLimitingMiddleware(max_size=500))
@mcp.tool
def fetch() -> ToolResult:
return ToolResult(content="upstream failed: " + "x" * 1000, is_error=True)
# before: result.is_error is False once truncated
# after: result.is_error is True
```
This touches the same `_truncate_to_result` as #5286, so whichever lands second needs a small rebase.
Fixes #5304.
Co-authored-by: asemabdallah <asasem547@gmail.com>
|
||
|---|---|---|
| .. | ||
| __init__.py | ||
| test_caching.py | ||
| test_caching_guards.py | ||
| test_dereference.py | ||
| test_discovery_middleware.py | ||
| test_error_handling.py | ||
| test_initialization_middleware.py | ||
| test_logging.py | ||
| test_message_visibility.py | ||
| test_middleware.py | ||
| test_middleware_nested.py | ||
| test_ping.py | ||
| test_rate_limiting.py | ||
| test_response_limiting.py | ||
| test_timing.py | ||
| test_tool_injection.py | ||
| test_versioned_caching.py | ||