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

# Stores

> Pick an authenticated MCP task store by the engine you already run: database, distributed cache, or eventing.

Every durable store implements the same contract as the in-memory store in [Authenticated tasks](https://ai.easyaf.dev/mcpessentials/guides/authenticated-tasks.md): stamp the owner on create, isolate client-facing get/cancel/resolve to that user, let the SDK complete work after the HTTP request is gone.

Pick the package that matches the engine already in your host. The identity factory stays the same when you swap.

The design lives in [`specs/authenticated-task-stores.md`](https://github.com/CloudNimble/McpEssentials/blob/main/specs/authenticated-task-stores.md).

## In-process

| Package | How-to | When |
| - | - | - |
| `McpEssentials.Core` | [Authenticated tasks](https://ai.easyaf.dev/mcpessentials/guides/authenticated-tasks.md) | Tests, local MCP, a single process |

`InMemoryMcpTaskStorePlus` keeps snapshots in a `ConcurrentDictionary`. Fan-out is an in-process event. Tasks die with the process.

## Database

Relational and document engines. Entity Framework Core is the default durable package: **one implementation, any EF Core provider**.

| Package | How-to | Engine | Status |
| - | - | - | - |
| `McpEssentials.EntityFrameworkCore` | [Entity Framework Core](https://ai.easyaf.dev/mcpessentials/guides/stores/entity-framework-core.md) | SQL Server, SQLite, PostgreSQL, MySQL, Cosmos via EF, and any other EF Core provider | Shipped |
| `McpEssentials.PostgreSQL` | [PostgreSQL](https://ai.easyaf.dev/mcpessentials/guides/stores/postgresql.md) | Npgsql, no EF | Specified |
| `McpEssentials.SqlServer` | [SQL Server](https://ai.easyaf.dev/mcpessentials/guides/stores/sql-server.md) | `Microsoft.Data.SqlClient`, no EF | Specified |
| `McpEssentials.Cosmos` | [Cosmos DB](https://ai.easyaf.dev/mcpessentials/guides/stores/cosmos.md) | Azure Cosmos DB for NoSQL | Specified |
| `McpEssentials.MongoDB` | [MongoDB](https://ai.easyaf.dev/mcpessentials/guides/stores/mongodb.md) | MongoDB | Specified |
| `McpEssentials.AzureTables` | [Azure Tables](https://ai.easyaf.dev/mcpessentials/guides/stores/azure-tables.md) | Azure Table Storage | Specified |

Use EF Core when the host already has a `DbContext`. Native PostgreSQL and SQL Server packages exist for hosts that want ADO.NET (and, for Postgres, `LISTEN` / `NOTIFY`) without an EF model.

## Distributed cache

Low-latency handles with native or host-owned expiry.

| Package | How-to | Engine | Status |
| - | - | - | - |
| `McpEssentials.Redis` | [Redis](https://ai.easyaf.dev/mcpessentials/guides/stores/redis.md) | StackExchange.Redis, `EXPIRE` plus pub/sub | Specified |
| `McpEssentials.DistributedCache` | [IDistributedCache](https://ai.easyaf.dev/mcpessentials/guides/stores/distributed-cache.md) | Whatever you already registered as `IDistributedCache` | Specified |

Prefer Redis when you need pub/sub for elicitation across nodes. Use `IDistributedCache` when that abstraction is already in DI and a host-supplied bus covers fan-out.

## Eventing

Stores whose native bus is the reason the package exists.

| Package | How-to | Engine | Status |
| - | - | - | - |
| `McpEssentials.Nats` | [NATS](https://ai.easyaf.dev/mcpessentials/guides/stores/nats.md) | JetStream KV for the row, Core NATS for signals | Specified |

Providers without a native bus (EF Core, `IDistributedCache`, Azure Tables) take an optional [`IMcpTaskInputSignalBus`](https://ai.easyaf.dev/mcpessentials/api-reference/CloudNimble/McpEssentials/Core/Tasks/IMcpTaskInputSignalBus). Missing bus plus multiple nodes means `ElicitAsync` waits until timeout.

## Shared row

`StoredMcpTask` is the persistence foundation. Durable entities subclass it (EF adds `RowVersion`). Keep these rows on their own table; tasks expire in minutes.

| Field | Role |
| - | - |
| `TaskId` | Primary key |
| `OwnerUserId` | Isolation key |
| `Status` | `Working` / `InputRequired` / `Completed` / `Cancelled` / `Failed` |
| `CreatedAt` / `LastUpdatedAt` | UTC |
| `TimeToLive` / `ExpiresAt` | Work window (`CreatedAt + TimeToLive`) |
| `DiscardAfter` | Visibility ceiling (`CreatedAt + 2×TimeToLive`), stamped at write |
| `ResultJson` / `ErrorJson` / `InputRequestsJson` | Payloads |

## Swap in production

HTTP identity stays on the platform accessor. Development uses Core. Production registers a durable store with the same factory.

```csharp theme={null}
builder.Services.AddHttpContextAccessor();

Func<IServiceProvider, ClaimsPrincipal?> currentUser =
    sp => sp.GetRequiredService<IHttpContextAccessor>().HttpContext?.User;

// Development
builder.Services.AddMcpServer()
    .WithHttpTransport(o => o.Stateless = true)
    .WithTasksPlus(currentUser, o => o.DefaultTimeToLive = TimeSpan.FromMinutes(5));

// Production (any EF Core provider on AppDbContext)
builder.Services.AddDbContext<AppDbContext>(o => o.UseSqlServer(connectionString));
builder.Services.AddMcpServer()
    .WithHttpTransport(o => o.Stateless = true)
    .WithTasksPlus<AppDbContext>(currentUser, o => o.DefaultTimeToLive = TimeSpan.FromMinutes(5));
```

Map `McpTasks` with `AddMcpTasksTable`. See [Entity Framework Core](https://ai.easyaf.dev/mcpessentials/guides/stores/entity-framework-core.md) for which overload to call (`OnModelCreating` vs `AddDbContext`).

Isolation helpers stay in Core. Provider packages depend on `McpEssentials.Core`, not on each other.


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