Skip to main content

Definition

Assembly: CloudNimble.McpEssentials.Core.dll Namespace: CloudNimble.McpEssentials.Core.Tasks Inheritance: System.Object

Syntax

Summary

Persistence foundation for an MCP task. Protocol fields plus owner and expiry. Construct from McpTaskInfo, 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). Prefer McpTaskInfo) 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 object

Syntax

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 as CreatedAt + 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, or null.

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 terminal CallToolResult, 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, or null 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 with Try*; 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, or null when unlimited.

Syntax

Parameters

Returns

Type: System.Nullable<System.DateTimeOffset> createdAt + 2×timeToLive, the visibility ceiling.

ComputeExpiresAt

Returns createdAt plus timeToLive, or null when unlimited.

Syntax

Parameters

Returns

Type: System.Nullable<System.DateTimeOffset>

Equals Inherited Virtual

Inherited from object

Syntax

Parameters

Returns

Type: bool

Equals Inherited

Inherited from object

Syntax

Parameters

Returns

Type: bool

GetHashCode Inherited Virtual

Inherited from object

Syntax

Returns

Type: int

GetType Inherited

Inherited from object

Syntax

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 returns false until DateTimeOffset) is true.

IsExpired Virtual

Returns whether this task has reached StoredMcpTask.ExpiresAt (or CreatedAt + 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 object

Syntax

Returns

Type: object

NormalizeTimeToLive

Returns a positive TTL, or null when the task should be retained until deleted.

Syntax

Parameters

Returns

Type: System.Nullable<System.TimeSpan>

ParseElement

Parses JSON text into a detached JsonElement, or null 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 object

Syntax

Parameters

Returns

Type: bool

ToInputRequestsJson

Serializes an input-request map, or null when empty.

Syntax

Parameters

Returns

Type: string?

ToJson

Serializes element to JSON text, or null 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 object

Syntax

Returns

Type: string?

TryCancel Virtual

Transitions to Cancelled when the task is not finished.

Syntax

Parameters

Returns

Type: bool true when the status changed.

TryComplete Virtual

Transitions to Completed when the task is not finished.

Syntax

Parameters

Returns

Type: bool true when the status changed.

TryFail Virtual

Transitions to Failed 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 stay InputRequired; an empty map returns to Working.

Syntax

Parameters

Returns

Type: bool true when the snapshot changed.

TrySetInputRequests Virtual

Merges inputRequests and moves to InputRequired 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.