Class McpProtectionConfig.Builder

java.lang.Object
com.soklet.McpProtectionConfig.Builder
Enclosing class:
McpProtectionConfig

@NotThreadSafe public static final class McpProtectionConfig.Builder extends Object
Single-threaded builder for immutable request-state protection settings.
Author:
Mark Allen
  • Method Details

    • maximumEncodedRequestStateSizeInBytes

      Sets the maximum encoded request-state size. The default is 65,536 bytes.

      This is a rejection ceiling, not a guaranteed continuation capacity. Built-in protection also needs envelope and encoding overhead; custom protectors may use a different amount. A particular continuation can exceed a valid configured limit when it is sealed.

      Parameters:
      maximumEncodedRequestStateSizeInBytes - positive byte limit, or null to restore the default
      Returns:
      this builder
    • maximumDecodedRequestStateSizeInBytes

      Sets the maximum decoded request-state size. The default is 49,152 bytes.

      Canonical framework metadata and application state both count toward this rejection ceiling. Builder validation cannot guarantee that a particular continuation will fit.

      Parameters:
      maximumDecodedRequestStateSizeInBytes - positive byte limit, or null to restore the default
      Returns:
      this builder
    • maximumRequestStateLifetime

      Sets the maximum request-state lifetime. The default is 15 minutes.

      The first emission starts the lifetime. Later emissions preserve the original expiry. If state expires while a valid retry's handler runs, returning more framework state fails at sealing after the handler returns; it does not roll back application side effects.

      Parameters:
      maximumRequestStateLifetime - positive finite lifetime, or null to restore the default
      Returns:
      this builder
    • maximumRequestStateRounds

      Sets the maximum request-state round count. The default is 10.

      This counts emitted continuations, starting at one, rather than handler invocations. A valid retry carrying the final allowed round may complete, but returning further framework state fails at sealing after the handler returns. The framework's round is not exposed by McpRequestContext.getFrameworkRequestState().

      Parameters:
      maximumRequestStateRounds - positive round limit, or null to restore the default
      Returns:
      this builder
    • build

      Builds the immutable protection configuration.
      Returns:
      protection configuration
      Throws:
      IllegalStateException - if the decoded-size limit exceeds the encoded-size limit