View the source code for this module on GitHub: https://github.com/mcp-use/mcp-use/blob/main/libraries/python/mcp_use/agents/middleware/tool_error_middleware.py
Agents
Tool Error Middleware
Middleware for handling tool validation and execution errors API Documentation
Middleware for handling tool validation and execution errors.
This middleware wraps tool calls to catch any exceptions (including ValidationErrors)
and returns them as formatted error messages to the LLM, enabling automatic retry.