+Middleware Code
+func (m *Middleware) CallTool(
+ ctx context.Context,
+ name string,
+ args map[string]interface{},
+) (*ToolResult, error) {
+
+ callerCtx := m.extractCallerContext(ctx)
+
+
+ decision := m.policy.Evaluate(callerCtx, name, args)
+ if decision.Action == Deny {
+ return nil, fmt.Errorf("denied: %s", decision.Reason)
+ }
+
+
+ return m.executor.CallTool(ctx, name, args)
+}
+
+
+