Record Class McpRequestState

java.lang.Object
java.lang.Record
org.apache.juneau.rest.server.mcp.v20260728.McpRequestState
Record Components:
continuation - The handler-opaque continuation value, exactly as thrown in McpInputRequiredSignal#getContinuation() (or, on a subsequent pause, exactly as the handler returned it a second time). Must be Juneau-marshallable (ordinary bean, Map, String, or similar). See the type-fidelity note above: it round-trips as generic JSON, not its original Java type.
method - The JSON-RPC method this state was sealed for (tools/call, prompts/get, or resources/read). Part of the AAD contract (see RequestStateCodec); also checked directly by the dispatcher against the follow-up request's own method as an extra sanity check.
round - The 1-based round counter: 1 on the first PAUSE, incremented on every subsequent PAUSE.
expiresAtMs - Absolute expiry timestamp in epoch milliseconds.
jti - A fresh, per-token random identifier minted on every PAUSE (see McpRevision#pause), used only to detect replay of THIS exact token. Opt-in: consulted by the dispatcher only when an operator has wired a ReplayCache via McpMrtrConfig.setReplayCache(org.apache.juneau.commons.concurrent.ReplayCache); otherwise it rides in the sealed plaintext unused. Not wire-visible on its own — like every other field on this record, it only ever travels inside the opaque, AEAD-sealed requestState string.
argumentsHash - A canonical hash of the original request's arguments (RFC 8785 JSON Canonicalization Scheme, then SHA-256, then base64url), captured at PAUSE time and re-verified against the RESUME request's own arguments on every subsequent round (see McpRevision#resolveMrtrContext). Always populated (unlike jti(), this check is not opt-in): a call with absent or empty arguments (for example resources/read's exact-path branch, which takes none) hashes the canonical empty object "{}" rather than leaving this field unset, so PAUSE and RESUME agree even when there is nothing to hash.

public record McpRequestState(Object continuation, String method, int round, long expiresAtMs, String jti, String argumentsHash) extends Record
The dispatcher-owned payload sealed into an opaque requestState token by RequestStateCodec.

Never wire-visible directly — InputRequiredResult.getRequestState() carries only the sealed string form. This type exists so the round counter (SEP-2322's max-rounds cap) and expiry travel *inside* the sealed token itself, per McpRevision's documented statelessness: no server-side session exists to hold them instead.

The sealed continuation is the only trusted per-round carrier. This is what makes it security-relevant: the continuation sealed here is authenticated (AEAD) and cannot be altered by the client between rounds, whereas the request arguments a handler sees on RESUME come from the follow-up request and are fully client-controlled (see McpMrtrResumeContext). Anything a handler must be able to trust across rounds — an authenticated principal, an authorization decision, a price, a resource id — must live inside this continuation, never be re-derived from the per-round arguments.

Continuation type fidelity. continuation is declared as Object because it is handler-opaque, but AeadRequestStateCodec.unseal(java.lang.String, java.lang.String, java.security.Principal) reconstructs it via generic JSON deserialization (Json.to(json, McpRequestState.class)). A handler that pauses with a Map or ordinary-bean continuation therefore gets back a generic JSON value on resume — a JsonMap/ JsonList/boxed primitive/String — never the original Java type. A handler that needs its original type back should not reconstruct it by hand: it retrieves the resume context from the BeanStore and calls McpMrtrResumeContext.continuationAs(Class), which converts the generic JSON value back to any Juneau-marshallable target type in one call.

  • Constructor Details

    • McpRequestState

      public McpRequestState(Object continuation, String method, int round, long expiresAtMs, String jti, String argumentsHash)
      Creates an instance of a McpRequestState record class.
      Parameters:
      continuation - the value for the continuation record component
      method - the value for the method record component
      round - the value for the round record component
      expiresAtMs - the value for the expiresAtMs record component
      jti - the value for the jti record component
      argumentsHash - the value for the argumentsHash record component
  • Method Details

    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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.
    • continuation

      public Object continuation()
      Returns the value of the continuation record component.
      Returns:
      the value of the continuation record component
    • method

      public String method()
      Returns the value of the method record component.
      Returns:
      the value of the method record component
    • round

      public int round()
      Returns the value of the round record component.
      Returns:
      the value of the round record component
    • expiresAtMs

      public long expiresAtMs()
      Returns the value of the expiresAtMs record component.
      Returns:
      the value of the expiresAtMs record component
    • jti

      public String jti()
      Returns the value of the jti record component.
      Returns:
      the value of the jti record component
    • argumentsHash

      Returns the value of the argumentsHash record component.
      Returns:
      the value of the argumentsHash record component