Class ToolCallUnauthorizedException

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
io.openliberty.mcp.tools.ToolCallUnauthorizedException
All Implemented Interfaces:
Serializable

public class ToolCallUnauthorizedException extends RuntimeException
Indicates that the caller is not authorized to invoke a Tool method.

If a method annotated with Tool throws a ToolCallUnauthorizedException then the framework returns an HTTP 403 Forbidden response to the client, in the same way as when the framework-level authorization check (via @DenyAll, @RolesAllowed, etc.) fails. The HTTP response body will contain the exception message as plain text (Content-Type: text/plain); no JSON-RPC envelope is included.

This allows application code to perform fine-grained authorization checks inside a @Tool method body and signal an authorization failure using the standard HTTP 403 status code.

See Also:
  • Constructor Details

    • ToolCallUnauthorizedException

      public ToolCallUnauthorizedException(String message)
      Creates a new ToolCallUnauthorizedException with the given message.
      Parameters:
      message - a description of why authorization failed
    • ToolCallUnauthorizedException

      public ToolCallUnauthorizedException(String message, Throwable cause)
      Creates a new ToolCallUnauthorizedException with the given message and cause.
      Parameters:
      message - a description of why authorization failed
      cause - the underlying cause
    • ToolCallUnauthorizedException

      public ToolCallUnauthorizedException(Throwable cause)
      Creates a new ToolCallUnauthorizedException with the given cause.
      Parameters:
      cause - the underlying cause