Skip to main content

Definition

Assembly: CloudNimble.McpEssentials.Core.dll Namespace: CloudNimble.McpEssentials.Core.Tasks Inheritance: CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase

Syntax

Summary

An in-memory IMcpTaskStorePlus that records the user who created each task and isolates later client-facing operations to that user.

Remarks

Storage is owned by this type: StoredMcpTask snapshots in a [ConcurrentDictionary2](https://learn.microsoft.com/dotnet/api/system.collections.concurrent.concurrentdictionary-2), compare-and-swap updates, two-window TTL, serve-and-drop on a terminal get, plus a throttled sweep. It does not wrap the SDK InMemoryMcpTaskStore`. Tasks created with a McpTaskStoreBase.DefaultTimeToLive use two clocks (as permitted by SEP-2663): a work window of CreatedAt + TimeToLive during which input and progress are accepted, and a tracking window that keeps the snapshot visible until CreatedAt + 2×TimeToLive so a late complete, fail, or cancel can still be recorded and polled. That ceiling is stamped as StoredMcpTask.DiscardAfter at write time. An owner GetTaskAsync of a terminal snapshot serves it and then drops the row. An opportunistic throttled sweep reclaims snapshots nobody collected. Tasks created without a time-to-live are retained until a terminal get by the owner or until the process exits. Client-facing operations require a current user and treat another user’s task as missing. Another user’s get does not serve-and-drop the owner’s row. Server-side completion skips the live-user check because the SDK runs those from a background DI scope after the originating HTTP request is gone. Single-process only. Register as a singleton. Subclass to change isolation, storage, or TTL. For multi-instance hosts, use a durable provider described in the authenticated task store spec.

Constructors

.ctor

Initializes a new instance of the InMemoryMcpTaskStorePlus class.

Syntax

Parameters

Exceptions

.ctor

Initializes a new instance of the InMemoryMcpTaskStorePlus class that always uses userId.

Syntax

Parameters

.ctor

Initializes a new instance of the InMemoryMcpTaskStorePlus class that resolves the user from a ClaimsPrincipal.

Syntax

Parameters

Exceptions

.ctor Inherited

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase
Initializes a new instance of the McpTaskStoreBase class.

Syntax

Parameters

Exceptions

.ctor Inherited

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase
Initializes a new instance of the McpTaskStoreBase class that always uses userId.

Syntax

Parameters

.ctor Inherited

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase
Initializes a new instance of the McpTaskStoreBase class that resolves the user from a ClaimsPrincipal.

Syntax

Parameters

Exceptions

.ctor Inherited

Inherited from object

Syntax

Properties

AutoSweep Inherited Virtual

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase
Gets or sets whether the store pulses a throttled flush after create and on get.

Syntax

Property Value

Type: bool The default is true.

Remarks

Set to false and call CancellationToken) from your own job when you want to own the schedule. The public flush handle always runs a full pass.

DefaultPollIntervalMs Inherited Virtual

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase
Gets or sets the default poll interval in milliseconds for new tasks.

Syntax

Property Value

Type: long The default is 1000 milliseconds.

DefaultTimeToLive Inherited Virtual

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase
Gets or sets the default time-to-live for new tasks, or null for unlimited.

Syntax

Property Value

Type: System.Nullable<System.TimeSpan>

Remarks

When set to a positive value, the work window ends at CreatedAt + TimeToLive and the row is discarded at CreatedAt + 2×TimeToLive (stamped as StoredMcpTask.DiscardAfter), or sooner when a terminal GetTaskAsync serves it. A null or non-positive value keeps tasks until a terminal get or until the store discards them.

GetCurrentUserId Inherited

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase
Gets the callback used by the IMcpTaskStore methods to resolve the current user.

Syntax

Property Value

Type: System.Func<string?>

LastSweepTicks Inherited

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase
Gets or sets the UTC ticks of the last automatic flush pulse. Tests reset this to race the throttle.

Syntax

Property Value

Type: long

ServeAndDrop Inherited Virtual

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase
Gets or sets whether an owner get of a terminal snapshot serves it and then drops the row.

Syntax

Property Value

Type: bool The default is true.

SweepInterval Inherited Virtual

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase
Gets or sets the minimum interval between automatic flush pulses.

Syntax

Property Value

Type: System.TimeSpan The default is 30 seconds. Zero skips the throttle.

Methods

CreateTaskAsync Inherited Virtual

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase

Syntax

Parameters

Returns

Type: System.Threading.Tasks.Task<ModelContextProtocol.Extensions.Tasks.McpTaskInfo>

CreateTaskAsync Inherited Virtual

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase

Syntax

Parameters

Returns

Type: System.Threading.Tasks.Task<ModelContextProtocol.Extensions.Tasks.McpTaskInfo>

CreateTaskCoreAsync Inherited Abstract

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase
Creates a task owned by userId.

Syntax

Parameters

Returns

Type: System.Threading.Tasks.Task<ModelContextProtocol.Extensions.Tasks.McpTaskInfo>

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

GetTaskAsync Inherited Virtual

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase

Syntax

Parameters

Returns

Type: System.Threading.Tasks.Task<ModelContextProtocol.Extensions.Tasks.McpTaskInfo?>

GetTaskAsync Inherited Virtual

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase

Syntax

Parameters

Returns

Type: System.Threading.Tasks.Task<ModelContextProtocol.Extensions.Tasks.McpTaskInfo?>

GetTaskCoreAsync Inherited Abstract

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase
Returns the task when userId owns it; otherwise null.

Syntax

Parameters

Returns

Type: System.Threading.Tasks.Task<ModelContextProtocol.Extensions.Tasks.McpTaskInfo?>

GetType Inherited

Inherited from object

Syntax

Returns

Type: System.Type

GetUserId Inherited

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase
Resolves a stable user identifier from principal.

Syntax

Parameters

Returns

Type: string? The first non-whitespace claim in SDK session-identity order, or null when the principal is missing or unauthenticated.

Remarks

Claim lookup matches the MCP C# SDK session identity order: NameIdentifier, sub, Upn, Name, then Name. The principal must be authenticated.

GetUtcNow Inherited Virtual

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase
Returns the current UTC timestamp used for create, update, expiry, and sweep.

Syntax

Returns

Type: System.DateTimeOffset

IsOwnedBy Inherited Virtual

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase
Returns whether ownerUserId is the same user as currentUserId.

Syntax

Parameters

Returns

Type: bool

MemberwiseClone Inherited

Inherited from object

Syntax

Returns

Type: object

NormalizeTimeToLive Inherited Virtual

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase
Returns a positive TTL, or null when tasks should be retained until discarded.

Syntax

Parameters

Returns

Type: System.Nullable<System.TimeSpan>

OnInputResponseReceived Inherited Virtual

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase
Raises McpTaskStoreBase.InputResponseReceived for a resolved input.

Syntax

Parameters

PulseSweepAsync Inherited Virtual

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase
Pulses a throttled flush when McpTaskStoreBase.AutoSweep is on.

Syntax

Parameters

Returns

Type: System.Threading.Tasks.Task A completed task when auto-sweep is off or the interval has not elapsed.

ReferenceEquals Inherited

Inherited from object

Syntax

Parameters

Returns

Type: bool

RequireUserId Inherited Virtual

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase
Returns the current user identifier, throwing when none is authenticated.

Syntax

Returns

Type: string

Exceptions

RequireUserId Inherited Virtual

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase
Returns the user identifier from user, throwing when the principal is missing or unauthenticated.

Syntax

Parameters

Returns

Type: string

Exceptions

ResolveInputRequestsAsync Inherited Virtual

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase

Syntax

Parameters

Returns

Type: System.Threading.Tasks.Task

ResolveInputRequestsAsync Inherited Virtual

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase

Syntax

Parameters

Returns

Type: System.Threading.Tasks.Task

ResolveInputRequestsCoreAsync Inherited Abstract

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase
Resolves input requests when userId owns the task.

Syntax

Parameters

Returns

Type: System.Threading.Tasks.Task

SetCancelledAsync Inherited Virtual

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase

Syntax

Parameters

Returns

Type: System.Threading.Tasks.Task<bool>

SetCancelledAsync Inherited Virtual

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase

Syntax

Parameters

Returns

Type: System.Threading.Tasks.Task<bool>

SetCancelledCoreAsync Inherited Abstract

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase
Cancels the task when userId owns it and it is not terminal.

Syntax

Parameters

Returns

Type: System.Threading.Tasks.Task<bool>

SetCompletedAsync Inherited Virtual

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase

Syntax

Parameters

Returns

Type: System.Threading.Tasks.Task

SetCompletedCoreAsync Inherited Abstract

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase
Completes the task. Skips the live-user check.

Syntax

Parameters

Returns

Type: System.Threading.Tasks.Task

SetFailedAsync Inherited Virtual

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase

Syntax

Parameters

Returns

Type: System.Threading.Tasks.Task

SetFailedCoreAsync Inherited Abstract

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase
Fails the task. Skips the live-user check.

Syntax

Parameters

Returns

Type: System.Threading.Tasks.Task

SetInputRequestsAsync Inherited Virtual

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase

Syntax

Parameters

Returns

Type: System.Threading.Tasks.Task

SetInputRequestsCoreAsync Inherited Abstract

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase
Merges input requests onto the task. Skips the live-user check.

Syntax

Parameters

Returns

Type: System.Threading.Tasks.Task

ShouldDiscard Inherited Virtual

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase
Returns whether task should be discarded at now.

Syntax

Parameters

Returns

Type: bool The default is DateTimeOffset) (compares StoredMcpTask.DiscardAfter). Override for per-row Get and mutate. Set-based drains (EF ExecuteDelete) use the stamp; override CancellationToken) when bulk criteria must differ.

SweepExpiredAsync Inherited Virtual

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase

Syntax

Parameters

Returns

Type: System.Threading.Tasks.Task

SweepExpiredCoreAsync Inherited Abstract

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase
Deletes rows that have passed their discard time.

Syntax

Parameters

Returns

Type: System.Threading.Tasks.Task A task that completes when the pass finishes.

Exceptions

ToString Inherited Virtual

Inherited from object

Syntax

Returns

Type: string?

TryClaimSweep Inherited Virtual

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase
Claims the automatic-flush interval so only one pulse walks at a time.

Syntax

Parameters

Returns

Type: bool true when this caller should run the pass. A McpTaskStoreBase.SweepInterval of Zero always claims.

Events

InputResponseReceived Inherited

Inherited from CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase

Syntax

  • CloudNimble.McpEssentials.Core.Tasks.IMcpTaskStorePlus
  • ModelContextProtocol.Extensions.Tasks.IMcpTaskStore