Record Class ToolErrorEvent

java.lang.Object
java.lang.Record
com.tnsai.mcp.server.event.ToolErrorEvent
Record Components:
toolName - the name of the tool that failed
category - the error category for client-side recovery decisions
message - safe, human-readable error description
timestamp - when the error occurred
requestId - the JSON-RPC request ID (if available)

public record ToolErrorEvent(String toolName, ToolErrorCategory category, String message, Instant timestamp, Long requestId) extends Record
Structured error event emitted when an MCP tool execution fails.

Contains the error category, tool name, and a safe error message (no sensitive stack traces or internal details).

  • Constructor Details

    • ToolErrorEvent

      public ToolErrorEvent(String toolName, ToolErrorCategory category, String message, Instant timestamp, Long requestId)
      Creates an instance of a ToolErrorEvent record class.
      Parameters:
      toolName - the value for the toolName record component
      category - the value for the category record component
      message - the value for the message record component
      timestamp - the value for the timestamp record component
      requestId - the value for the requestId record component
  • Method Details

    • of

      public static ToolErrorEvent of(String toolName, ToolErrorCategory category, String message)
      Creates an error event with auto-generated timestamp.
    • of

      public static ToolErrorEvent of(String toolName, ToolErrorCategory category, String message, Long requestId)
      Creates an error event with a request ID.
    • isRetriable

      public boolean isRetriable()
      Returns whether this error is typically retriable.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • toolName

      public String toolName()
      Returns the value of the toolName record component.
      Returns:
      the value of the toolName record component
    • category

      public ToolErrorCategory category()
      Returns the value of the category record component.
      Returns:
      the value of the category record component
    • message

      public String message()
      Returns the value of the message record component.
      Returns:
      the value of the message record component
    • timestamp

      public Instant timestamp()
      Returns the value of the timestamp record component.
      Returns:
      the value of the timestamp record component
    • requestId

      public Long requestId()
      Returns the value of the requestId record component.
      Returns:
      the value of the requestId record component