Definition
Assembly: CloudNimble.McpEssentials.Core.dll Namespace: CloudNimble.McpEssentials.Core.Tasks Inheritance: System.ObjectSyntax
Summary
Persistence foundation for an MCP task. Protocol fields plus owner and expiry. Construct fromMcpTaskInfo, mutate with Try*, and emit the SDK record
with InputRequest}). Durable providers subclass this type (for example
McpTaskEntity) and add only engine-specific columns.
Constructors
.ctor
Initializes an empty instance. Used by materializers (EF Core). PreferMcpTaskInfo) when the owner and snapshot are known.
Syntax
.ctor
Initializes a new instance of the StoredMcpTask class from a protocol snapshot.Syntax
Parameters
Exceptions
.ctor
Initializes a new working task owned by ownerUserId.Syntax
Parameters
.ctor Inherited
Inherited from
objectSyntax
Properties
CreatedAt
Gets or sets when the task was created, UTC.Syntax
Property Value
Type:System.DateTimeOffset
DiscardAfter
Gets or sets when the row should be discarded. Stamped at write time asCreatedAt + 2×TimeToLive. null when unlimited.
Syntax
Property Value
Type:System.Nullable<System.DateTimeOffset>
Remarks
Two windows is the visibility ceiling, including late complete, fail, or cancel. The stamp does not move when the task finishes.DateTimeOffset) compares
the current time to this value.
Error
Gets or sets the JSON-RPC error, ornull.
Syntax
Property Value
Type:System.Nullable<System.Text.Json.JsonElement>
ExpiresAt
Gets or sets the work-window end (CreatedAt + TimeToLive).
null when unlimited. Discard uses StoredMcpTask.DiscardAfter.
Syntax
Property Value
Type:System.Nullable<System.DateTimeOffset>
Info
Gets the cached protocol snapshot. Allocates once per mutation.Syntax
Property Value
Type:ModelContextProtocol.Extensions.Tasks.McpTaskInfo
InputRequests
Gets or sets the outstanding input-request map. Empty when none are pending.Syntax
Property Value
Type:System.Collections.Generic.IReadOnlyDictionary<string, ModelContextProtocol.Protocol.InputRequest>
IsFinished Virtual
Gets whether StoredMcpTask.Status is completed, cancelled, or failed.Syntax
Property Value
Type:bool
LastUpdatedAt
Gets or sets when the task last changed, UTC.Syntax
Property Value
Type:System.DateTimeOffset
OwnerUserId
Gets or sets the user recorded when the task was created. Isolation key.Syntax
Property Value
Type:string
PollIntervalMs
Gets or sets the client poll interval in milliseconds.Syntax
Property Value
Type:System.Nullable<long>
Result
Gets or sets the terminalCallToolResult, or null.
Syntax
Property Value
Type:System.Nullable<System.Text.Json.JsonElement>
Status
Gets or sets the protocol status.Syntax
Property Value
Type:ModelContextProtocol.Extensions.Tasks.McpTaskStatus
StatusMessage
Gets or sets an optional status message.Syntax
Property Value
Type:string?
TaskId
Gets or sets the opaque task identifier. Primary key. Do not embed the user id.Syntax
Property Value
Type:string
TimeToLive
Gets or sets the time-to-live from StoredMcpTask.CreatedAt, ornull for unlimited.
Syntax
Property Value
Type:System.Nullable<System.TimeSpan>
Methods
Apply Virtual
Copies protocol fields from info, recomputes StoredMcpTask.ExpiresAt and StoredMcpTask.DiscardAfter, and caches the snapshot. Leaves StoredMcpTask.OwnerUserId alone.Syntax
Parameters
Exceptions
Clone Virtual
Returns a shallow copy for compare-and-swap updates. Mutate the copy withTry*;
the original stays unchanged. Subclasses with extra mutable reference fields should override.
Syntax
Returns
Type:CloudNimble.McpEssentials.Core.Tasks.StoredMcpTask
ComputeDiscardAfter
Returns when the row should be discarded, ornull when unlimited.
Syntax
Parameters
Returns
Type:System.Nullable<System.DateTimeOffset>
createdAt + 2×timeToLive, the visibility ceiling.
ComputeExpiresAt
Returns createdAt plus timeToLive, ornull when unlimited.
Syntax
Parameters
Returns
Type:System.Nullable<System.DateTimeOffset>
Equals Inherited Virtual
Inherited from
objectSyntax
Parameters
Returns
Type:bool
Equals Inherited
Inherited from
objectSyntax
Parameters
Returns
Type:bool
GetHashCode Inherited Virtual
Inherited from
objectSyntax
Returns
Type:int
GetType Inherited
Inherited from
objectSyntax
Returns
Type:System.Type
HasExpired Virtual
Returns whether the snapshot has no remaining reads and should be discarded.Syntax
Parameters
Returns
Type:bool
true when StoredMcpTask.DiscardAfter is set and
now is at or past it.
IsActive Virtual
Returns whether the task is still in its work window and may accept input or progress.Syntax
Parameters
Returns
Type:bool
false when the task is finished. Otherwise true when
the task has no positive time-to-live, or when now is still earlier
than CreatedAt + TimeToLive.
Remarks
Uses StoredMcpTask.TimeToLive, not StoredMcpTask.ExpiresAt. Settle (complete, fail, cancel) is still allowed after this returnsfalse until
DateTimeOffset) is true.
IsExpired Virtual
Returns whether this task has reached StoredMcpTask.ExpiresAt (orCreatedAt + TimeToLive when StoredMcpTask.ExpiresAt is unset).
Syntax
Parameters
Returns
Type:bool
true when now is at or past the work-window end.
Work-window helper. Discard uses DateTimeOffset) / StoredMcpTask.DiscardAfter.
IsOwnedBy Virtual
Returns whether userId is the recorded owner.Syntax
Parameters
Returns
Type:bool
MemberwiseClone Inherited
Inherited from
objectSyntax
Returns
Type:object
NormalizeTimeToLive
Returns a positive TTL, ornull when the task should be retained until deleted.
Syntax
Parameters
Returns
Type:System.Nullable<System.TimeSpan>
ParseElement
Parses JSON text into a detached JsonElement, ornull when empty.
Syntax
Parameters
Returns
Type:System.Nullable<System.Text.Json.JsonElement?>?
ParseInputRequests
Parses an input-request map. Empty or missing JSON returns StoredMcpTask.EmptyInputRequests.Syntax
Parameters
Returns
Type:System.Collections.Generic.IReadOnlyDictionary<string, ModelContextProtocol.Protocol.InputRequest>
ReferenceEquals Inherited
Inherited from
objectSyntax
Parameters
Returns
Type:bool
ToInputRequestsJson
Serializes an input-request map, ornull when empty.
Syntax
Parameters
Returns
Type:string?
ToJson
Serializes element to JSON text, ornull when absent.
Syntax
Parameters
Returns
Type:string?
ToMcpTaskInfo Virtual
Returns the protocol snapshot. Optional overrides allocate a new record and leave the cache alone.Syntax
Parameters
Returns
Type:ModelContextProtocol.Extensions.Tasks.McpTaskInfo
ToString Inherited Virtual
Inherited from
objectSyntax
Returns
Type:string?
TryCancel Virtual
Transitions toCancelled when the task is not finished.
Syntax
Parameters
Returns
Type:bool
true when the status changed.
TryComplete Virtual
Transitions toCompleted when the task is not finished.
Syntax
Parameters
Returns
Type:bool
true when the status changed.
TryFail Virtual
Transitions toFailed when the task is not finished.
Syntax
Parameters
Returns
Type:bool
true when the status changed.
TryResolveInputRequests Virtual
Removes resolved ids from the outstanding map. Remaining requests stayInputRequired; an empty map returns to Working.
Syntax
Parameters
Returns
Type:bool
true when the snapshot changed.
TrySetInputRequests Virtual
Merges inputRequests and moves toInputRequired
when the task is not finished.
Syntax
Parameters
Returns
Type:bool
true when the snapshot changed.
With Virtual
Returns a snapshot with the same owner and a new StoredMcpTask.Info.Syntax
Parameters
Returns
Type:CloudNimble.McpEssentials.Core.Tasks.StoredMcpTask
A new snapshot with the same StoredMcpTask.OwnerUserId.