Exact order
Success path
- raw params arrive
onTransformcan rewrite raw params- schema parsing happens
- global
onBeforeHandleruns - tool-local
beforeruns - middleware chain runs
- handler runs
- tool-local
afterruns - global
onAfterHandleruns mapResponseruns
Failure path
If middleware or the handler throws:- tool-local
afterdoes not run - global
onErrorruns - the error is returned through the transport path
Recommended usage
onTransformfor raw argument normalization- global hooks for cross-cutting observability
- tool hooks for tool-specific side effects
- middleware for execution control