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

# IServiceCollection

> Extension methods for IServiceCollection from Microsoft.Extensions.DependencyInjection.Abstractions

## Definition

**Assembly:** Microsoft.Extensions.DependencyInjection.Abstractions.dll

**Namespace:** Microsoft.Extensions.DependencyInjection

## Syntax

```csharp theme={null}
Microsoft.Extensions.DependencyInjection.IServiceCollection
```

## Summary

This type is defined in Microsoft.Extensions.DependencyInjection.Abstractions.

## Remarks

See [Microsoft documentation](https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection) for more information about the rest of the API.

## Methods

### &#x20;AddInMemoryAuthenticatedTaskStore Extension

> [!NOTE]
>
> Extension method from `Microsoft.Extensions.DependencyInjection.McpEssentials_Core_ServiceCollectionExtensions`

#### Syntax

```csharp theme={null}
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddInMemoryAuthenticatedTaskStore(Microsoft.Extensions.DependencyInjection.IServiceCollection services, string userId, System.Action<CloudNimble.McpEssentials.Core.Tasks.AuthenticatedMcpTaskStoreOptions> configure = null)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `services` | `Microsoft.Extensions.DependencyInjection.IServiceCollection` | - |
| `userId` | `string` | - |
| `configure` | `System.Action<CloudNimble.McpEssentials.Core.Tasks.AuthenticatedMcpTaskStoreOptions>?` | - |

#### Returns

Type: `Microsoft.Extensions.DependencyInjection.IServiceCollection`

### &#x20;AddInMemoryAuthenticatedTaskStore Extension

> [!NOTE]
>
> Extension method from `Microsoft.Extensions.DependencyInjection.McpEssentials_Core_ServiceCollectionExtensions`

#### Syntax

```csharp theme={null}
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddInMemoryAuthenticatedTaskStore(Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Func<string> getCurrentUserId, System.Action<CloudNimble.McpEssentials.Core.Tasks.AuthenticatedMcpTaskStoreOptions> configure = null)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `services` | `Microsoft.Extensions.DependencyInjection.IServiceCollection` | - |
| `getCurrentUserId` | `System.Func<string?>` | - |
| `configure` | `System.Action<CloudNimble.McpEssentials.Core.Tasks.AuthenticatedMcpTaskStoreOptions>?` | - |

#### Returns

Type: `Microsoft.Extensions.DependencyInjection.IServiceCollection`

### &#x20;AddInMemoryAuthenticatedTaskStore Extension

> [!NOTE]
>
> Extension method from `Microsoft.Extensions.DependencyInjection.McpEssentials_Core_ServiceCollectionExtensions`

#### Syntax

```csharp theme={null}
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddInMemoryAuthenticatedTaskStore(Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Func<System.IServiceProvider, System.Security.Claims.ClaimsPrincipal> getPrincipal, System.Action<CloudNimble.McpEssentials.Core.Tasks.AuthenticatedMcpTaskStoreOptions> configure = null)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `services` | `Microsoft.Extensions.DependencyInjection.IServiceCollection` | - |
| `getPrincipal` | `System.Func<System.IServiceProvider, System.Security.Claims.ClaimsPrincipal?>` | - |
| `configure` | `System.Action<CloudNimble.McpEssentials.Core.Tasks.AuthenticatedMcpTaskStoreOptions>?` | - |

#### Returns

Type: `Microsoft.Extensions.DependencyInjection.IServiceCollection`

### &#x20;AddMcpEssentialsEntityFrameworkTasks Extension

> [!NOTE]
>
> Extension method from `Microsoft.Extensions.DependencyInjection.McpEssentials_EntityFrameworkCore_ServiceCollectionExtensions`

Registers `EntityFrameworkAuthenticatedTaskStore`1`as the singleton`IMcpTaskStore\` and [IPerUserMcpTaskStore](https://ai.easyaf.dev/mcpessentials/api-reference/CloudNimble/McpEssentials/Core/Tasks/IPerUserMcpTaskStore.md) for a single user.

#### Syntax

```csharp theme={null}
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddMcpEssentialsEntityFrameworkTasks<TContext>(Microsoft.Extensions.DependencyInjection.IServiceCollection services, string userId, System.Action<CloudNimble.McpEssentials.Core.Tasks.AuthenticatedMcpTaskStoreOptions> configure = null) where TContext : Microsoft.EntityFrameworkCore.DbContext
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `services` | `Microsoft.Extensions.DependencyInjection.IServiceCollection` | The service collection. |
| `userId` | `string` | The owner stamped on every task this process creates. |
| `configure` | `System.Action<CloudNimble.McpEssentials.Core.Tasks.AuthenticatedMcpTaskStoreOptions>?` | Optional store options (TTL, poll interval). |

#### Returns

Type: `Microsoft.Extensions.DependencyInjection.IServiceCollection`
The service collection.

#### Type Parameters

* `TContext` - The host [DbContext](https://learn.microsoft.com/dotnet/api/microsoft.entityframeworkcore.dbcontext) that maps [McpTaskEntity](https://ai.easyaf.dev/mcpessentials/api-reference/CloudNimble/McpEssentials/EntityFrameworkCore/Tasks/McpTaskEntity.md).

#### Exceptions

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

### &#x20;AddMcpEssentialsEntityFrameworkTasks Extension

> [!NOTE]
>
> Extension method from `Microsoft.Extensions.DependencyInjection.McpEssentials_EntityFrameworkCore_ServiceCollectionExtensions`

Registers `EntityFrameworkAuthenticatedTaskStore`1`as the singleton`IMcpTaskStore\` and [IPerUserMcpTaskStore](https://ai.easyaf.dev/mcpessentials/api-reference/CloudNimble/McpEssentials/Core/Tasks/IPerUserMcpTaskStore.md).

#### Syntax

```csharp theme={null}
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddMcpEssentialsEntityFrameworkTasks<TContext>(Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Func<string> getCurrentUserId, System.Action<CloudNimble.McpEssentials.Core.Tasks.AuthenticatedMcpTaskStoreOptions> configure = null) where TContext : Microsoft.EntityFrameworkCore.DbContext
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `services` | `Microsoft.Extensions.DependencyInjection.IServiceCollection` | The service collection. |
| `getCurrentUserId` | `System.Func<string?>` | Returns the current user identifier, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) when unauthenticated. |
| `configure` | `System.Action<CloudNimble.McpEssentials.Core.Tasks.AuthenticatedMcpTaskStoreOptions>?` | Optional store options (TTL, poll interval). |

#### Returns

Type: `Microsoft.Extensions.DependencyInjection.IServiceCollection`
The service collection.

#### Type Parameters

* `TContext` - The host [DbContext](https://learn.microsoft.com/dotnet/api/microsoft.entityframeworkcore.dbcontext) that maps [McpTaskEntity](https://ai.easyaf.dev/mcpessentials/api-reference/CloudNimble/McpEssentials/EntityFrameworkCore/Tasks/McpTaskEntity.md).

#### Exceptions

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

### &#x20;AddMcpEssentialsEntityFrameworkTasks Extension

> [!NOTE]
>
> Extension method from `Microsoft.Extensions.DependencyInjection.McpEssentials_EntityFrameworkCore_ServiceCollectionExtensions`

Registers `EntityFrameworkAuthenticatedTaskStore`1\` using a
[ClaimsPrincipal](https://learn.microsoft.com/dotnet/api/system.security.claims.claimsprincipal) factory resolved from the built provider.

#### Syntax

```csharp theme={null}
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddMcpEssentialsEntityFrameworkTasks<TContext>(Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Func<System.IServiceProvider, System.Security.Claims.ClaimsPrincipal> getPrincipal, System.Action<CloudNimble.McpEssentials.Core.Tasks.AuthenticatedMcpTaskStoreOptions> configure = null) where TContext : Microsoft.EntityFrameworkCore.DbContext
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `services` | `Microsoft.Extensions.DependencyInjection.IServiceCollection` | The service collection. |
| `getPrincipal` | `System.Func<System.IServiceProvider, System.Security.Claims.ClaimsPrincipal?>` | Returns the principal for the current request. Hosts typically pass |
| `sp =&gt; sp.GetRequiredService&lt;IHttpContextAccessor&gt;().HttpContext?.User`. | | |
| `configure` | `System.Action<CloudNimble.McpEssentials.Core.Tasks.AuthenticatedMcpTaskStoreOptions>?` | Optional store options (TTL, poll interval). |

#### Returns

Type: `Microsoft.Extensions.DependencyInjection.IServiceCollection`
The service collection.

#### Type Parameters

* `TContext` - The host [DbContext](https://learn.microsoft.com/dotnet/api/microsoft.entityframeworkcore.dbcontext) that maps [McpTaskEntity](https://ai.easyaf.dev/mcpessentials/api-reference/CloudNimble/McpEssentials/EntityFrameworkCore/Tasks/McpTaskEntity.md).

#### Exceptions

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


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