Secure Agent Tool Aspect
AOP aspect that enforces SecureAgentTool security expressions on Embabel agent action methods.
When an @Action method annotated with SecureAgentTool is invoked by Embabel's DefaultActionMethodManager, this aspect intercepts the call and evaluates the SpEL expression in SecureAgentTool.value against the current org.springframework.security.core.Authentication using Spring Security's org.springframework.security.access.expression.method.MethodSecurityExpressionHandler — the same engine that powers org.springframework.security.access.prepost.PreAuthorize.
Invocation proceeds only if the expression evaluates to true. Otherwise an org.springframework.security.access.AccessDeniedException is thrown, resulting in a 403 at the MCP transport layer.
Invocation order
MCP Client request
→ Spring Security FilterChain (transport-level, rejects unauthenticated)
→ Embabel GOAP planner (selects goal/action)
→ DefaultActionMethodManager (resolves and invokes the @Action method)
→ SecureAgentToolAspect (evaluates @SecureAgentTool SpEL — this class)
→ @Action method body (executes only if SpEL passes)Thread safety
This aspect is stateless. org.springframework.security.core.context.SecurityContextHolder provides per-request authentication via its default ThreadLocal strategy, so concurrent invocations are isolated.
See also
Functions
Intercepts methods annotated with SecureAgentTool at method or class level, enforcing the declared SpEL expression before the action body executes.