> ## Documentation Index
> Fetch the complete documentation index at: https://ai.easyaf.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# InMemoryMcpTaskStorePlus

> An in-memory [IMcpTaskStorePlus](/mcpessentials/api-reference/CloudNimble/McpEssentials/Core/Tasks/IMcpTaskStorePlus) that records the user who created each task and isola...

## Definition

**Assembly:** CloudNimble.McpEssentials.Core.dll

**Namespace:** CloudNimble.McpEssentials.Core.Tasks

**Inheritance:** CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase

## Syntax

```csharp theme={"dark"}
CloudNimble.McpEssentials.Core.Tasks.InMemoryMcpTaskStorePlus
```

## Summary

An in-memory [IMcpTaskStorePlus](https://ai.easyaf.dev/mcpessentials/api-reference/CloudNimble/McpEssentials/Core/Tasks/IMcpTaskStorePlus.md) 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](https://ai.easyaf.dev/mcpessentials/api-reference/CloudNimble/McpEssentials/Core/Tasks/StoredMcpTask.md) snapshots in a
\[ConcurrentDictionary`2](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](https://ai.easyaf.dev/mcpessentials/api-reference/CloudNimble/McpEssentials/Core/Tasks/McpTaskStoreBase.md#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](https://ai.easyaf.dev/mcpessentials/api-reference/CloudNimble/McpEssentials/Core/Tasks/StoredMcpTask.md#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

### &#x20;.ctor

Initializes a new instance of the [InMemoryMcpTaskStorePlus](https://ai.easyaf.dev/mcpessentials/api-reference/CloudNimble/McpEssentials/Core/Tasks/InMemoryMcpTaskStorePlus.md) class.

#### Syntax

```csharp theme={"dark"}
public InMemoryMcpTaskStorePlus(System.Func<string> getCurrentUserId)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `getCurrentUserId` | `System.Func<string?>` | Returns the current user identifier, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) when unauthenticated. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | Thrown when *getCurrentUserId* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |

### &#x20;.ctor

Initializes a new instance of the [InMemoryMcpTaskStorePlus](https://ai.easyaf.dev/mcpessentials/api-reference/CloudNimble/McpEssentials/Core/Tasks/InMemoryMcpTaskStorePlus.md) class
that always uses *userId*.

#### Syntax

```csharp theme={"dark"}
public InMemoryMcpTaskStorePlus(string userId)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `userId` | `string?` | The user identifier, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to treat the process as unauthenticated. |

### &#x20;.ctor

Initializes a new instance of the [InMemoryMcpTaskStorePlus](https://ai.easyaf.dev/mcpessentials/api-reference/CloudNimble/McpEssentials/Core/Tasks/InMemoryMcpTaskStorePlus.md) class
that resolves the user from a [ClaimsPrincipal](https://learn.microsoft.com/dotnet/api/system.security.claims.claimsprincipal).

#### Syntax

```csharp theme={"dark"}
public InMemoryMcpTaskStorePlus(System.Func<System.Security.Claims.ClaimsPrincipal> getPrincipal)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `getPrincipal` | `System.Func<System.Security.Claims.ClaimsPrincipal?>` | Returns the principal for the current request. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | Thrown when *getPrincipal* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |

### &#x20;.ctor Inherited

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

Initializes a new instance of the [McpTaskStoreBase](https://ai.easyaf.dev/mcpessentials/api-reference/CloudNimble/McpEssentials/Core/Tasks/McpTaskStoreBase.md) class.

#### Syntax

```csharp theme={"dark"}
protected McpTaskStoreBase(System.Func<string> getCurrentUserId)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `getCurrentUserId` | `System.Func<string?>` | Returns the current user identifier, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) when unauthenticated. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | Thrown when *getCurrentUserId* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |

### &#x20;.ctor Inherited

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

Initializes a new instance of the [McpTaskStoreBase](https://ai.easyaf.dev/mcpessentials/api-reference/CloudNimble/McpEssentials/Core/Tasks/McpTaskStoreBase.md) class
that always uses *userId*.

#### Syntax

```csharp theme={"dark"}
protected McpTaskStoreBase(string userId)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `userId` | `string?` | The user identifier, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to treat the process as unauthenticated. |

### &#x20;.ctor Inherited

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

Initializes a new instance of the [McpTaskStoreBase](https://ai.easyaf.dev/mcpessentials/api-reference/CloudNimble/McpEssentials/Core/Tasks/McpTaskStoreBase.md) class
that resolves the user from a [ClaimsPrincipal](https://learn.microsoft.com/dotnet/api/system.security.claims.claimsprincipal).

#### Syntax

```csharp theme={"dark"}
protected McpTaskStoreBase(System.Func<System.Security.Claims.ClaimsPrincipal> getPrincipal)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `getPrincipal` | `System.Func<System.Security.Claims.ClaimsPrincipal?>` | Returns the principal for the current request. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | Thrown when *getPrincipal* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |

### &#x20;.ctor Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public Object()
```

## Properties

### &#x20;AutoSweep Inherited Virtual

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

Gets or sets whether the store pulses a throttled flush after create and on get.

#### Syntax

```csharp theme={"dark"}
public virtual bool AutoSweep { get; set; }
```

#### Property Value

Type: `bool`
The default is [`true`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool).

#### Remarks

Set to [`false`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) and call `CancellationToken)` from your own job
when you want to own the schedule. The public flush handle always runs a full pass.

### &#x20;DefaultPollIntervalMs Inherited Virtual

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

Gets or sets the default poll interval in milliseconds for new tasks.

#### Syntax

```csharp theme={"dark"}
public virtual long DefaultPollIntervalMs { get; set; }
```

#### Property Value

Type: `long`
The default is 1000 milliseconds.

### &#x20;DefaultTimeToLive Inherited Virtual

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

Gets or sets the default time-to-live for new tasks, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) for unlimited.

#### Syntax

```csharp theme={"dark"}
public virtual System.Nullable<System.TimeSpan> DefaultTimeToLive { get; set; }
```

#### 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](https://ai.easyaf.dev/mcpessentials/api-reference/CloudNimble/McpEssentials/Core/Tasks/StoredMcpTask.md#discardafter)), or sooner when a terminal
`GetTaskAsync` serves it. A [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) or non-positive value keeps tasks
until a terminal get or until the store discards them.

### &#x20;GetCurrentUserId Inherited

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

Gets the callback used by the [IMcpTaskStore](https://ai.easyaf.dev/mcpessentials/api-reference/ModelContextProtocol/Extensions/Tasks/IMcpTaskStore.md) methods to resolve the current user.

#### Syntax

```csharp theme={"dark"}
protected System.Func<string> GetCurrentUserId { get; }
```

#### Property Value

Type: `System.Func<string?>`

### &#x20;LastSweepTicks Inherited

> [!NOTE]
>
> 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

```csharp theme={"dark"}
protected long LastSweepTicks { get; set; }
```

#### Property Value

Type: `long`

### &#x20;ServeAndDrop Inherited Virtual

> [!NOTE]
>
> 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

```csharp theme={"dark"}
public virtual bool ServeAndDrop { get; set; }
```

#### Property Value

Type: `bool`
The default is [`true`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool).

### &#x20;SweepInterval Inherited Virtual

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

Gets or sets the minimum interval between automatic flush pulses.

#### Syntax

```csharp theme={"dark"}
public virtual System.TimeSpan SweepInterval { get; set; }
```

#### Property Value

Type: `System.TimeSpan`
The default is 30 seconds. [Zero](https://learn.microsoft.com/dotnet/api/system.timespan.zero) skips the throttle.

## Methods

### &#x20;CreateTaskAsync Inherited Virtual

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

#### Syntax

```csharp theme={"dark"}
public virtual System.Threading.Tasks.Task<ModelContextProtocol.Extensions.Tasks.McpTaskInfo> CreateTaskAsync(System.Threading.CancellationToken cancellationToken = null)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `cancellationToken` | `System.Threading.CancellationToken` | - |

#### Returns

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

### &#x20;CreateTaskAsync Inherited Virtual

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

#### Syntax

```csharp theme={"dark"}
public virtual System.Threading.Tasks.Task<ModelContextProtocol.Extensions.Tasks.McpTaskInfo> CreateTaskAsync(System.Security.Claims.ClaimsPrincipal user, System.Threading.CancellationToken cancellationToken = null)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `user` | `System.Security.Claims.ClaimsPrincipal` | - |
| `cancellationToken` | `System.Threading.CancellationToken` | - |

#### Returns

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

### &#x20;CreateTaskCoreAsync Inherited Abstract

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

Creates a task owned by *userId*.

#### Syntax

```csharp theme={"dark"}
protected abstract System.Threading.Tasks.Task<ModelContextProtocol.Extensions.Tasks.McpTaskInfo> CreateTaskCoreAsync(string userId, System.Threading.CancellationToken cancellationToken)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `userId` | `string` | - |
| `cancellationToken` | `System.Threading.CancellationToken` | - |

#### Returns

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

### &#x20;Equals Inherited Virtual

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public virtual bool Equals(object obj)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `obj` | `object?` | - |

#### Returns

Type: `bool`

### &#x20;Equals Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public static bool Equals(object objA, object objB)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `objA` | `object?` | - |
| `objB` | `object?` | - |

#### Returns

Type: `bool`

### &#x20;GetHashCode Inherited Virtual

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public virtual int GetHashCode()
```

#### Returns

Type: `int`

### &#x20;GetTaskAsync Inherited Virtual

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

#### Syntax

```csharp theme={"dark"}
public virtual System.Threading.Tasks.Task<ModelContextProtocol.Extensions.Tasks.McpTaskInfo> GetTaskAsync(string taskId, System.Threading.CancellationToken cancellationToken = null)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `taskId` | `string` | - |
| `cancellationToken` | `System.Threading.CancellationToken` | - |

#### Returns

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

### &#x20;GetTaskAsync Inherited Virtual

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

#### Syntax

```csharp theme={"dark"}
public virtual System.Threading.Tasks.Task<ModelContextProtocol.Extensions.Tasks.McpTaskInfo> GetTaskAsync(string taskId, System.Security.Claims.ClaimsPrincipal user, System.Threading.CancellationToken cancellationToken = null)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `taskId` | `string` | - |
| `user` | `System.Security.Claims.ClaimsPrincipal` | - |
| `cancellationToken` | `System.Threading.CancellationToken` | - |

#### Returns

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

### &#x20;GetTaskCoreAsync Inherited Abstract

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

Returns the task when *userId* owns it; otherwise [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null).

#### Syntax

```csharp theme={"dark"}
protected abstract System.Threading.Tasks.Task<ModelContextProtocol.Extensions.Tasks.McpTaskInfo> GetTaskCoreAsync(string taskId, string userId, System.Threading.CancellationToken cancellationToken)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `taskId` | `string` | - |
| `userId` | `string` | - |
| `cancellationToken` | `System.Threading.CancellationToken` | - |

#### Returns

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

### &#x20;GetType Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public System.Type GetType()
```

#### Returns

Type: `System.Type`

### &#x20;GetUserId Inherited

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

Resolves a stable user identifier from *principal*.

#### Syntax

```csharp theme={"dark"}
public static string GetUserId(System.Security.Claims.ClaimsPrincipal principal)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `principal` | `System.Security.Claims.ClaimsPrincipal?` | The principal for the current request. |

#### Returns

Type: `string?`
The first non-whitespace claim in SDK session-identity order, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null)
when the principal is missing or unauthenticated.

#### Remarks

Claim lookup matches the MCP C# SDK session identity order:
[NameIdentifier](https://learn.microsoft.com/dotnet/api/system.security.claims.claimtypes.nameidentifier), `sub`, [Upn](https://learn.microsoft.com/dotnet/api/system.security.claims.claimtypes.upn),
[Name](https://learn.microsoft.com/dotnet/api/system.security.claims.claimtypes.name), then [Name](https://learn.microsoft.com/dotnet/api/system.security.principal.iidentity.name).
The principal must be authenticated.

### &#x20;GetUtcNow Inherited Virtual

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

Returns the current UTC timestamp used for create, update, expiry, and sweep.

#### Syntax

```csharp theme={"dark"}
protected virtual System.DateTimeOffset GetUtcNow()
```

#### Returns

Type: `System.DateTimeOffset`

### &#x20;IsOwnedBy Inherited Virtual

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

Returns whether *ownerUserId* is the same user as *currentUserId*.

#### Syntax

```csharp theme={"dark"}
protected virtual bool IsOwnedBy(string ownerUserId, string currentUserId)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `ownerUserId` | `string?` | - |
| `currentUserId` | `string?` | - |

#### Returns

Type: `bool`

### &#x20;MemberwiseClone Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
protected internal object MemberwiseClone()
```

#### Returns

Type: `object`

### &#x20;NormalizeTimeToLive Inherited Virtual

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

Returns a positive TTL, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) when tasks should be retained until discarded.

#### Syntax

```csharp theme={"dark"}
protected virtual System.Nullable<System.TimeSpan> NormalizeTimeToLive(System.Nullable<System.TimeSpan> timeToLive)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `timeToLive` | `System.Nullable<System.TimeSpan>` | - |

#### Returns

Type: `System.Nullable<System.TimeSpan>`

### &#x20;OnInputResponseReceived Inherited Virtual

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

Raises [McpTaskStoreBase.InputResponseReceived](https://ai.easyaf.dev/mcpessentials/api-reference/CloudNimble/McpEssentials/Core/Tasks/McpTaskStoreBase.md#inputresponsereceived) for a resolved input.

#### Syntax

```csharp theme={"dark"}
protected virtual void OnInputResponseReceived(string taskId, string requestId, ModelContextProtocol.Protocol.InputResponse response)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `taskId` | `string` | - |
| `requestId` | `string` | - |
| `response` | `ModelContextProtocol.Protocol.InputResponse` | - |

### &#x20;PulseSweepAsync Inherited Virtual

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

Pulses a throttled flush when [McpTaskStoreBase.AutoSweep](https://ai.easyaf.dev/mcpessentials/api-reference/CloudNimble/McpEssentials/Core/Tasks/McpTaskStoreBase.md#autosweep) is on.

#### Syntax

```csharp theme={"dark"}
protected virtual System.Threading.Tasks.Task PulseSweepAsync(System.DateTimeOffset now, System.Threading.CancellationToken cancellationToken)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `now` | `System.DateTimeOffset` | The current UTC time used for discard and throttle checks. |
| `cancellationToken` | `System.Threading.CancellationToken` | Observed during the pass. |

#### Returns

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

### &#x20;ReferenceEquals Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public static bool ReferenceEquals(object objA, object objB)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `objA` | `object?` | - |
| `objB` | `object?` | - |

#### Returns

Type: `bool`

### &#x20;RequireUserId Inherited Virtual

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

Returns the current user identifier, throwing when none is authenticated.

#### Syntax

```csharp theme={"dark"}
protected virtual string RequireUserId()
```

#### Returns

Type: `string`

#### Exceptions

| Exception | Description |
| - | - |
| `McpTaskUserRequiredException` | Thrown when the callback returns [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) or whitespace. |

### &#x20;RequireUserId Inherited Virtual

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

Returns the user identifier from *user*, throwing when the principal is missing or unauthenticated.

#### Syntax

```csharp theme={"dark"}
protected virtual string RequireUserId(System.Security.Claims.ClaimsPrincipal user)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `user` | `System.Security.Claims.ClaimsPrincipal` | The principal for the current operation. |

#### Returns

Type: `string`

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | Thrown when *user* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `McpTaskUserRequiredException` | Thrown when *user* is unauthenticated. |

### &#x20;ResolveInputRequestsAsync Inherited Virtual

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

#### Syntax

```csharp theme={"dark"}
public virtual System.Threading.Tasks.Task ResolveInputRequestsAsync(string taskId, System.Collections.Generic.IDictionary<string, ModelContextProtocol.Protocol.InputResponse> inputResponses, System.Threading.CancellationToken cancellationToken = null)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `taskId` | `string` | - |
| `inputResponses` | `System.Collections.Generic.IDictionary<string, ModelContextProtocol.Protocol.InputResponse>` | - |
| `cancellationToken` | `System.Threading.CancellationToken` | - |

#### Returns

Type: `System.Threading.Tasks.Task`

### &#x20;ResolveInputRequestsAsync Inherited Virtual

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

#### Syntax

```csharp theme={"dark"}
public virtual System.Threading.Tasks.Task ResolveInputRequestsAsync(string taskId, System.Collections.Generic.IDictionary<string, ModelContextProtocol.Protocol.InputResponse> inputResponses, System.Security.Claims.ClaimsPrincipal user, System.Threading.CancellationToken cancellationToken = null)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `taskId` | `string` | - |
| `inputResponses` | `System.Collections.Generic.IDictionary<string, ModelContextProtocol.Protocol.InputResponse>` | - |
| `user` | `System.Security.Claims.ClaimsPrincipal` | - |
| `cancellationToken` | `System.Threading.CancellationToken` | - |

#### Returns

Type: `System.Threading.Tasks.Task`

### &#x20;ResolveInputRequestsCoreAsync Inherited Abstract

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

Resolves input requests when *userId* owns the task.

#### Syntax

```csharp theme={"dark"}
protected abstract System.Threading.Tasks.Task ResolveInputRequestsCoreAsync(string taskId, System.Collections.Generic.IDictionary<string, ModelContextProtocol.Protocol.InputResponse> inputResponses, string userId, System.Threading.CancellationToken cancellationToken)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `taskId` | `string` | - |
| `inputResponses` | `System.Collections.Generic.IDictionary<string, ModelContextProtocol.Protocol.InputResponse>` | - |
| `userId` | `string` | - |
| `cancellationToken` | `System.Threading.CancellationToken` | - |

#### Returns

Type: `System.Threading.Tasks.Task`

### &#x20;SetCancelledAsync Inherited Virtual

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

#### Syntax

```csharp theme={"dark"}
public virtual System.Threading.Tasks.Task<bool> SetCancelledAsync(string taskId, System.Threading.CancellationToken cancellationToken = null)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `taskId` | `string` | - |
| `cancellationToken` | `System.Threading.CancellationToken` | - |

#### Returns

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

### &#x20;SetCancelledAsync Inherited Virtual

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

#### Syntax

```csharp theme={"dark"}
public virtual System.Threading.Tasks.Task<bool> SetCancelledAsync(string taskId, System.Security.Claims.ClaimsPrincipal user, System.Threading.CancellationToken cancellationToken = null)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `taskId` | `string` | - |
| `user` | `System.Security.Claims.ClaimsPrincipal` | - |
| `cancellationToken` | `System.Threading.CancellationToken` | - |

#### Returns

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

### &#x20;SetCancelledCoreAsync Inherited Abstract

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

Cancels the task when *userId* owns it and it is not terminal.

#### Syntax

```csharp theme={"dark"}
protected abstract System.Threading.Tasks.Task<bool> SetCancelledCoreAsync(string taskId, string userId, System.Threading.CancellationToken cancellationToken)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `taskId` | `string` | - |
| `userId` | `string` | - |
| `cancellationToken` | `System.Threading.CancellationToken` | - |

#### Returns

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

### &#x20;SetCompletedAsync Inherited Virtual

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

#### Syntax

```csharp theme={"dark"}
public virtual System.Threading.Tasks.Task SetCompletedAsync(string taskId, System.Text.Json.JsonElement result, System.Threading.CancellationToken cancellationToken = null)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `taskId` | `string` | - |
| `result` | `System.Text.Json.JsonElement` | - |
| `cancellationToken` | `System.Threading.CancellationToken` | - |

#### Returns

Type: `System.Threading.Tasks.Task`

### &#x20;SetCompletedCoreAsync Inherited Abstract

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

Completes the task. Skips the live-user check.

#### Syntax

```csharp theme={"dark"}
protected abstract System.Threading.Tasks.Task SetCompletedCoreAsync(string taskId, System.Text.Json.JsonElement result, System.Threading.CancellationToken cancellationToken)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `taskId` | `string` | - |
| `result` | `System.Text.Json.JsonElement` | - |
| `cancellationToken` | `System.Threading.CancellationToken` | - |

#### Returns

Type: `System.Threading.Tasks.Task`

### &#x20;SetFailedAsync Inherited Virtual

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

#### Syntax

```csharp theme={"dark"}
public virtual System.Threading.Tasks.Task SetFailedAsync(string taskId, System.Text.Json.JsonElement error, System.Threading.CancellationToken cancellationToken = null)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `taskId` | `string` | - |
| `error` | `System.Text.Json.JsonElement` | - |
| `cancellationToken` | `System.Threading.CancellationToken` | - |

#### Returns

Type: `System.Threading.Tasks.Task`

### &#x20;SetFailedCoreAsync Inherited Abstract

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

Fails the task. Skips the live-user check.

#### Syntax

```csharp theme={"dark"}
protected abstract System.Threading.Tasks.Task SetFailedCoreAsync(string taskId, System.Text.Json.JsonElement error, System.Threading.CancellationToken cancellationToken)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `taskId` | `string` | - |
| `error` | `System.Text.Json.JsonElement` | - |
| `cancellationToken` | `System.Threading.CancellationToken` | - |

#### Returns

Type: `System.Threading.Tasks.Task`

### &#x20;SetInputRequestsAsync Inherited Virtual

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

#### Syntax

```csharp theme={"dark"}
public virtual System.Threading.Tasks.Task SetInputRequestsAsync(string taskId, System.Collections.Generic.IDictionary<string, ModelContextProtocol.Protocol.InputRequest> inputRequests, System.Threading.CancellationToken cancellationToken = null)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `taskId` | `string` | - |
| `inputRequests` | `System.Collections.Generic.IDictionary<string, ModelContextProtocol.Protocol.InputRequest>` | - |
| `cancellationToken` | `System.Threading.CancellationToken` | - |

#### Returns

Type: `System.Threading.Tasks.Task`

### &#x20;SetInputRequestsCoreAsync Inherited Abstract

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

Merges input requests onto the task. Skips the live-user check.

#### Syntax

```csharp theme={"dark"}
protected abstract System.Threading.Tasks.Task SetInputRequestsCoreAsync(string taskId, System.Collections.Generic.IDictionary<string, ModelContextProtocol.Protocol.InputRequest> inputRequests, System.Threading.CancellationToken cancellationToken)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `taskId` | `string` | - |
| `inputRequests` | `System.Collections.Generic.IDictionary<string, ModelContextProtocol.Protocol.InputRequest>` | - |
| `cancellationToken` | `System.Threading.CancellationToken` | - |

#### Returns

Type: `System.Threading.Tasks.Task`

### &#x20;ShouldDiscard Inherited Virtual

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

Returns whether *task* should be discarded at *now*.

#### Syntax

```csharp theme={"dark"}
protected virtual bool ShouldDiscard(CloudNimble.McpEssentials.Core.Tasks.StoredMcpTask task, System.DateTimeOffset now)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `task` | `CloudNimble.McpEssentials.Core.Tasks.StoredMcpTask` | The snapshot under consideration. |
| `now` | `System.DateTimeOffset` | The current UTC time. |

#### Returns

Type: `bool`
The default is `DateTimeOffset)` (compares
[StoredMcpTask.DiscardAfter](https://ai.easyaf.dev/mcpessentials/api-reference/CloudNimble/McpEssentials/Core/Tasks/StoredMcpTask.md#discardafter)). Override for per-row Get and mutate.
Set-based drains (EF `ExecuteDelete`) use the stamp; override
`CancellationToken)` when bulk criteria must differ.

### &#x20;SweepExpiredAsync Inherited Virtual

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

#### Syntax

```csharp theme={"dark"}
public virtual System.Threading.Tasks.Task SweepExpiredAsync(System.Threading.CancellationToken cancellationToken = null)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `cancellationToken` | `System.Threading.CancellationToken` | - |

#### Returns

Type: `System.Threading.Tasks.Task`

### &#x20;SweepExpiredCoreAsync Inherited Abstract

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

Deletes rows that have passed their discard time.

#### Syntax

```csharp theme={"dark"}
protected abstract System.Threading.Tasks.Task SweepExpiredCoreAsync(System.DateTimeOffset now, System.Threading.CancellationToken cancellationToken)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `now` | `System.DateTimeOffset` | The current UTC time used for discard checks. |
| `cancellationToken` | `System.Threading.CancellationToken` | Observed during the pass so a cancelled caller does not finish the walk. |

#### Returns

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

#### Exceptions

| Exception | Description |
| - | - |
| `OperationCanceledException` | *cancellationToken* was cancelled during the pass. |

### &#x20;ToString Inherited Virtual

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public virtual string ToString()
```

#### Returns

Type: `string?`

### &#x20;TryClaimSweep Inherited Virtual

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

Claims the automatic-flush interval so only one pulse walks at a time.

#### Syntax

```csharp theme={"dark"}
protected virtual bool TryClaimSweep(System.DateTimeOffset now)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `now` | `System.DateTimeOffset` | The current UTC time. |

#### Returns

Type: `bool`
[`true`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) when this caller should run the pass.
A [McpTaskStoreBase.SweepInterval](https://ai.easyaf.dev/mcpessentials/api-reference/CloudNimble/McpEssentials/Core/Tasks/McpTaskStoreBase.md#sweepinterval) of [Zero](https://learn.microsoft.com/dotnet/api/system.timespan.zero) always claims.

## Events

### &#x20;InputResponseReceived Inherited

> [!NOTE]
>
> Inherited from `CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase`

#### Syntax

```csharp theme={"dark"}
public virtual System.Action<ModelContextProtocol.Extensions.Tasks.InputResponseReceivedEventArgs> InputResponseReceived
```

## Related APIs

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


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.