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

# CosmosMcpTaskStore

> An [IMcpTaskStorePlus](/mcpessentials/api-reference/CloudNimble/McpEssentials/Core/Tasks/IMcpTaskStorePlus) that persists snapshots as Cosmos documents partitioned by owne...

## Definition

**Assembly:** CloudNimble.McpEssentials.Cosmos.dll

**Namespace:** CloudNimble.McpEssentials.Cosmos.Tasks

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

## Syntax

```csharp theme={"dark"}
CloudNimble.McpEssentials.Cosmos.Tasks.CosmosMcpTaskStore
```

## Summary

An [IMcpTaskStorePlus](https://si.easyaf.dev/mcpessentials/api-reference/CloudNimble/McpEssentials/Core/Tasks/IMcpTaskStorePlus.md) that persists snapshots as Cosmos documents partitioned
by owner, with a task-id index for server-side complete and native document TTL.

## Remarks

Register as a singleton. The host owns [CosmosClient](https://learn.microsoft.com/dotnet/api/microsoft.azure.cosmos.cosmosclient).
Native TTL is the drain; [McpTaskStoreBase.AutoSweep](https://si.easyaf.dev/mcpessentials/api-reference/CloudNimble/McpEssentials/Core/Tasks/McpTaskStoreBase.md#autosweep) defaults to
[`false`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool). Optional [IMcpTaskInputSignalBus](https://si.easyaf.dev/mcpessentials/api-reference/CloudNimble/McpEssentials/Core/Tasks/IMcpTaskInputSignalBus.md) fans
elicitation wake-ups across nodes.

## Constructors

### &#x20;.ctor

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

#### Syntax

```csharp theme={"dark"}
public CosmosMcpTaskStore(Microsoft.Azure.Cosmos.CosmosClient client, System.Func<string> getCurrentUserId, CloudNimble.McpEssentials.Core.Tasks.IMcpTaskInputSignalBus signalBus = null)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `client` | `Microsoft.Azure.Cosmos.CosmosClient` | The Cosmos client. The host owns its lifetime. |
| `getCurrentUserId` | `System.Func<string?>` | Returns the current user identifier, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) when unauthenticated. |
| `signalBus` | `CloudNimble.McpEssentials.Core.Tasks.IMcpTaskInputSignalBus?` | Optional bus that fans resolved input out to other nodes. |

#### Exceptions

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

### &#x20;.ctor

Initializes a new instance that always uses *userId*.

#### Syntax

```csharp theme={"dark"}
public CosmosMcpTaskStore(Microsoft.Azure.Cosmos.CosmosClient client, string userId, CloudNimble.McpEssentials.Core.Tasks.IMcpTaskInputSignalBus signalBus = null)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `client` | `Microsoft.Azure.Cosmos.CosmosClient` | The Cosmos client. The host owns its lifetime. |
| `userId` | `string?` | The user identifier, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to treat the process as unauthenticated. |
| `signalBus` | `CloudNimble.McpEssentials.Core.Tasks.IMcpTaskInputSignalBus?` | Optional bus that fans resolved input out to other nodes. |

#### Exceptions

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

### &#x20;.ctor

Initializes a new instance that resolves the user from a [ClaimsPrincipal](https://learn.microsoft.com/dotnet/api/system.security.claims.claimsprincipal).

#### Syntax

```csharp theme={"dark"}
public CosmosMcpTaskStore(Microsoft.Azure.Cosmos.CosmosClient client, System.Func<System.Security.Claims.ClaimsPrincipal> getPrincipal, CloudNimble.McpEssentials.Core.Tasks.IMcpTaskInputSignalBus signalBus = null)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `client` | `Microsoft.Azure.Cosmos.CosmosClient` | The Cosmos client. The host owns its lifetime. |
| `getPrincipal` | `System.Func<System.Security.Claims.ClaimsPrincipal?>` | Returns the principal for the current request. |
| `signalBus` | `CloudNimble.McpEssentials.Core.Tasks.IMcpTaskInputSignalBus?` | Optional bus that fans resolved input out to other nodes. |

#### Exceptions

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

### &#x20;.ctor

Initializes a new instance with deferred factories so the MCP server builder can
capture the store before `Build()`.

#### Syntax

```csharp theme={"dark"}
public CosmosMcpTaskStore(System.Func<Microsoft.Azure.Cosmos.CosmosClient> getClient, System.Func<string> getCurrentUserId, System.Func<CloudNimble.McpEssentials.Core.Tasks.IMcpTaskInputSignalBus> getSignalBus = null)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `getClient` | `System.Func<Microsoft.Azure.Cosmos.CosmosClient>` | Returns the Cosmos client from the built provider. |
| `getCurrentUserId` | `System.Func<string?>` | Returns the current user identifier, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) when unauthenticated. |
| `getSignalBus` | `System.Func<CloudNimble.McpEssentials.Core.Tasks.IMcpTaskInputSignalBus?>?` | Returns the optional bus from the built provider. |

#### Exceptions

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

## Properties

### &#x20;DatabaseId Virtual

Gets or sets the Cosmos database id.

#### Syntax

```csharp theme={"dark"}
public virtual string DatabaseId { get; set; }
```

#### Property Value

Type: `string`

### &#x20;IndexContainerId Virtual

Gets or sets the index container id.

#### Syntax

```csharp theme={"dark"}
public virtual string IndexContainerId { get; set; }
```

#### Property Value

Type: `string`

### &#x20;TasksContainerId Virtual

Gets or sets the tasks container id.

#### Syntax

```csharp theme={"dark"}
public virtual string TasksContainerId { get; set; }
```

#### Property Value

Type: `string`

### &#x20;Throughput Virtual

Gets or sets the RU/s used when creating containers, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null)
to create without dedicated throughput (serverless).

#### Syntax

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

#### Property Value

Type: `System.Nullable<int>`

## Methods

### &#x20;DefaultClientOptions

Client options that serialize documents with [CosmosSystemTextJsonSerializer](https://si.easyaf.dev/mcpessentials/api-reference/CloudNimble/McpEssentials/Cosmos/Tasks/CosmosSystemTextJsonSerializer.md).

#### Syntax

```csharp theme={"dark"}
public static Microsoft.Azure.Cosmos.CosmosClientOptions DefaultClientOptions()
```

#### Returns

Type: `Microsoft.Azure.Cosmos.CosmosClientOptions`
Options the host should pass to [CosmosClient](https://learn.microsoft.com/dotnet/api/microsoft.azure.cosmos.cosmosclient). The Cosmos SDK default
serializer is Newtonsoft; without these options, `JsonPropertyName` mapping
on task documents does not apply.

### &#x20;Dispose Virtual

#### Syntax

```csharp theme={"dark"}
public virtual void Dispose()
```

## Related APIs

* System.IDisposable


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