Class McpProtectionConfig.Builder
- Enclosing class:
McpProtectionConfig
- Author:
- Mark Allen
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the immutable protection configuration.maximumDecodedRequestStateSizeInBytes(@Nullable Integer maximumDecodedRequestStateSizeInBytes) Sets the maximum decoded request-state size.maximumEncodedRequestStateSizeInBytes(@Nullable Integer maximumEncodedRequestStateSizeInBytes) Sets the maximum encoded request-state size.maximumRequestStateLifetime(@Nullable Duration maximumRequestStateLifetime) Sets the maximum request-state lifetime.maximumRequestStateRounds(@Nullable Integer maximumRequestStateRounds) Sets the maximum request-state round count.
-
Method Details
-
maximumEncodedRequestStateSizeInBytes
public @NonNull McpProtectionConfig.Builder maximumEncodedRequestStateSizeInBytes(@Nullable Integer 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, ornullto restore the default- Returns:
- this builder
-
maximumDecodedRequestStateSizeInBytes
public @NonNull McpProtectionConfig.Builder maximumDecodedRequestStateSizeInBytes(@Nullable Integer 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, ornullto restore the default- Returns:
- this builder
-
maximumRequestStateLifetime
public @NonNull McpProtectionConfig.Builder maximumRequestStateLifetime(@Nullable Duration 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, ornullto restore the default- Returns:
- this builder
-
maximumRequestStateRounds
public @NonNull McpProtectionConfig.Builder maximumRequestStateRounds(@Nullable Integer maximumRequestStateRounds) Sets the maximum request-state round count. The default is10.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, ornullto 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
-