From 59b19eb549a94e8fd9189074c2786e544f4c6240 Mon Sep 17 00:00:00 2001 From: William Easton Date: Fri, 27 Mar 2026 18:31:05 -0500 Subject: [PATCH] Fix error classification using __cause__ instead of raised exception type Co-Authored-By: Claude Opus 4.6 (1M context) --- src/fastmcp/server/middleware/error_handling.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fastmcp/server/middleware/error_handling.py b/src/fastmcp/server/middleware/error_handling.py index 5b235e804..122642250 100644 --- a/src/fastmcp/server/middleware/error_handling.py +++ b/src/fastmcp/server/middleware/error_handling.py @@ -89,7 +89,7 @@ class ErrorHandlingMiddleware(Middleware): return error # Map common exceptions to appropriate MCP error codes - error_type = type(error.__cause__) if error.__cause__ else type(error) + error_type = type(error) if error_type in (ValueError, TypeError): return McpError(