Class McpTaskOrigin
Soklet makes an invocation-scoped McpTaskCreationContext available before
invoking a task-capable handler and derives this value only if application
code requests it or the invocation produces a task handle. The persisted
state is versioned framework data that lets a later request, potentially
handled by another process or deployment generation, recover the original
endpoint, operation, validated arguments, and output contract. It is
intentionally opaque so later Tasks revisions can add origin data without
widening this Java API.
An application that returns a task handle must store this complete value
atomically with its durable work description. Its configured
McpTaskManager must return a semantically equal origin with every
snapshot of that task. Persist the exact text returned by
toPersistedString() byte-for-byte in an opaque text or binary field
and restore it with fromPersistedString(String). Do not route it
through a database JSON type or another parse-and-render cycle that may
normalize or discard representation details. The parser accepts
insignificant whitespace, member reordering, and equivalent decimal scales,
but exact storage is the forward-compatible durability boundary. Soklet
compares the origin before returning the task handle and uses it to apply the
original tool's output protections when the task completes.
Origin state may contain tool arguments or other sensitive application data. Store it with the same confidentiality and integrity protections as the task itself, do not log it, and do not expose it to clients. It is not an authorization decision or task-ownership binding; the task manager must independently bind and authorize each task using the admitted request.
- Author:
- Mark Allen
-
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic @NonNull McpTaskOriginfromPersistedState(@NonNull McpJsonObject persistedState) Reconstructs an origin from framework state previously supplied by Soklet.static @NonNull McpTaskOriginfromPersistedString(@NonNull String persistedString) Reconstructs an origin from its bounded durable JSON representation.Returns the complete opaque state that must be durably preserved.inthashCode()Returns the bounded canonical JSON form for durable storage.toString()
-
Method Details
-
fromPersistedState
Reconstructs an origin from framework state previously supplied by Soklet.Applications must preserve every member and value. Soklet canonicalizes object-member order and decimal scale for durable equality, then validates the supported version and semantics when the origin is used; construction establishes an immutable copy boundary.
- Parameters:
persistedState- complete persisted origin state- Returns:
- immutable task origin
- Throws:
NullPointerException- ifpersistedStateis nullIllegalArgumentException- if the value cannot be represented by the bounded canonical origin codec
-
fromPersistedString
Reconstructs an origin from its bounded durable JSON representation.Store the exact representation as an opaque, non-normalizing text or binary value. Parsing accepts equivalent JSON object representations, including insignificant whitespace, member reordering, and numerically equivalent decimal scales, but
toPersistedString()always returns Soklet's canonical form.- Parameters:
persistedString- persisted origin JSON- Returns:
- immutable task origin
- Throws:
NullPointerException- ifpersistedStringis nullIllegalArgumentException- if the value is not a bounded JSON object
-
getPersistedState
Returns the complete opaque state that must be durably preserved.The returned object may contain sensitive operation arguments. It is not MCP response metadata and must never be sent to a client.
- Returns:
- immutable persisted origin state
-
toPersistedString
Returns the bounded canonical JSON form for durable storage.The returned text may contain sensitive operation arguments. Store its exact UTF-8 representation in a non-normalizing text or binary field with the same confidentiality and integrity protections as the task. Do not parse and re-emit it, log it, or expose it to clients.
- Returns:
- canonical persisted origin JSON
-
equals
-
hashCode
-
toString
-