Record Class McpMrtrResumeContext

java.lang.Object
java.lang.Record
org.apache.juneau.rest.server.mcp.v20260728.McpMrtrResumeContext
Record Components:
continuation - The decoded continuation, exactly as RequestStateCodec.unseal(java.lang.String, java.lang.String, java.security.Principal) produced it. Can be null if the handler paused with a null continuation. See the round-trip contract above: it is generic JSON, not the original Java type — use continuationAs(Class) to recover a typed view.
inputResponses - The client's collected answers, echoed from the follow-up request's inputResponses field. Never null (an empty map when the client sent none).

public record McpMrtrResumeContext(Object continuation, Map<String,Object> inputResponses) extends Record
Bean stashed into the BeanStore passed to a handler on a RESUME call, carrying the decoded continuation and the client's collected answers.

Absent (not stashed) on a first-round call — a handler that only ever completes in one round never has to know this type exists. A resumable handler calls ctx.getBean(McpMrtrResumeContext.class) to detect resume and retrieve both fields.

Per-round arguments are client-controlled; the continuation is not. On RESUME the handler receives its ordinary arguments from the follow-up request — the client re-sends them each round and full schema validation runs per round, but nothing about the original round's arguments is sealed or verified, so a client can alter them between rounds and the MRTR layer will accept the resume. Only continuation() (sealed by RequestStateCodec, AEAD-authenticated) is tamper-evident across rounds. Therefore any value a handler must trust across rounds must be carried in the continuation, never re-read from the per-round arguments. The client is expected to re-send the original arguments on every round; a handler that needs the exact original arguments should stash them in the continuation rather than rely on the client echoing them faithfully.

Continuation type fidelity (round-trip contract). continuation() is whatever RequestStateCodec.unseal(java.lang.String, java.lang.String, java.security.Principal) decoded from the client's echoed requestState: a generic JSON value (JsonMap/JsonList/boxed primitive/String), never the original Java type the handler threw in McpInputRequiredSignal (see the type-fidelity note on McpRequestState). Rather than force handler authors to parse that generic value by hand, continuationAs(Class) converts it back to any Juneau-marshallable target type in one call, so a handler that paused with a bean recovers a bean of the same shape ergonomically.

  • Constructor Details

  • Method Details

    • continuationAs

      public <T> T continuationAs(Class<T> type)
      Returns the continuation converted to the given type.

      Convenience for the round-trip contract documented on this record: because continuation() is a generic JSON value (not the handler's original Java type), a handler that paused with, say, a ResumeState bean would otherwise have to reconstruct it manually from a JsonMap. This converts the generic value to type via Juneau's JSON marshaller — the same mechanism the codec used to serialize it — so continuationAs(ResumeState.class) returns a fully populated ResumeState.

      Failure contract: conversion is best-effort against a generic JSON value. If the continuation's decoded shape is incompatible with type, the underlying marshaller throws (a RuntimeException); a handler that lets it propagate surfaces the -32603 internal-error fail-safe from McpRevision#dispatch. A handler that pauses and resumes with a single, consistent continuation type never hits this.

      Type Parameters:
      T - The target type.
      Parameters:
      type - The target type to convert the continuation to. Must not be null.
      Returns:
      The continuation converted to type, or null if the continuation is null.
      Throws:
      IllegalArgumentException - If type is null.
      RuntimeException - If the continuation's decoded shape cannot be converted to type.
    • continuationAsString

      Returns the continuation as a String.

      Convenience for the common case documented on continuationAs(Class): a handler that pauses with a plain String continuation can call this instead of spelling out continuationAs(String.class) at the headline pause/resume call site.

      Conversion is not lenient. continuationAs(String.class) routes through the JSON marshaller, which parses String the same as any other target type — it requires a quoted JSON string literal, so a continuation that decoded to anything else (a bare number, a JsonMap, a JsonList, a boolean) throws below rather than being stringified. Only a continuation whose decoded shape is already a String converts successfully.

      Returns:
      The continuation as a String, or null if the continuation is null.
      Throws:
      RuntimeException - If the continuation's decoded shape is not already a String.
    • 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.
    • continuation

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

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