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

# McpTaskStoreBase

> Base type for authenticated MCP task stores. Wires the current-user callback, fail-closed identity, [McpTaskStoreBase.InputResponseReceived](/mcpessentials/api-reference/C...

## Definition

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

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

**Inheritance:** System.Object

## Syntax

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

## Summary

Base type for authenticated MCP task stores. Wires the current-user callback, fail-closed
identity, [McpTaskStoreBase.InputResponseReceived](https://si.easyaf.dev/api-reference/CloudNimble/McpEssentials/Core/Tasks/McpTaskStoreBase#inputresponsereceived), flush pulses, and the mapping from
[IMcpTaskStore](https://si.easyaf.dev/mcpessentials/api-reference/ModelContextProtocol/Extensions/Tasks/IMcpTaskStore.md) / [IMcpTaskStorePlus](https://si.easyaf.dev/mcpessentials/api-reference/CloudNimble/McpEssentials/Core/Tasks/IMcpTaskStorePlus.md) into per-user core methods.

## Remarks

Subclass and implement the `Core` methods plus `CancellationToken)` to
persist snapshots. Create inserts then pulses a throttled flush; get pulses then reads.
Set [McpTaskStoreBase.AutoSweep](https://si.easyaf.dev/mcpessentials/api-reference/CloudNimble/McpEssentials/Core/Tasks/McpTaskStoreBase.md#autosweep) to [`false`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) and call `CancellationToken)`
from your own job to own the schedule. Override `DateTimeOffset)` to change keep
rules. Do not wrap the SDK `InMemoryMcpTaskStore`; each provider owns its storage.

## Constructors

### &#x20;.ctor Inherited

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

#### Syntax

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

## Properties

### &#x20;AutoSweep Virtual

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 Virtual

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 Virtual

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://si.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;ServeAndDrop Virtual

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 Virtual

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 Virtual

#### 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 Virtual

#### 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;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 Virtual

#### 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 Virtual

#### 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;GetType Inherited

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

#### Syntax

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

#### Returns

Type: `System.Type`

### &#x20;GetUserId

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;MemberwiseClone Inherited

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

#### Syntax

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

#### Returns

Type: `object`

### &#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;ResolveInputRequestsAsync Virtual

#### 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 Virtual

#### 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;SetCancelledAsync Virtual

#### 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 Virtual

#### 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;SetCompletedAsync Virtual

#### 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;SetFailedAsync Virtual

#### 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;SetInputRequestsAsync Virtual

#### 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;SweepExpiredAsync Virtual

#### 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;ToString Inherited Virtual

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

#### Syntax

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

#### Returns

Type: `string?`

## Events

### &#x20;InputResponseReceived

#### 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.