SecureAgentToolAspect

class SecureAgentToolAspect(expressionHandler: <Error class: unknown class>)

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

DefaultActionMethodManager
org.springframework.security.access.prepost.PreAuthorize

Constructors

Link copied to clipboard
constructor(expressionHandler: <Error class: unknown class>)

Functions

Link copied to clipboard
fun enforceAgentToolSecurity(joinPoint: <Error class: unknown class>): Any?

Intercepts methods annotated with SecureAgentTool at method or class level, enforcing the declared SpEL expression before the action body executes.