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

# SQL Server

> Native Microsoft.Data.SqlClient authenticated task store. Specified; not in this repository yet.

> [!WARNING]
>
> `McpEssentials.SqlServer` is specified and is not in this repository yet. Use [Entity Framework Core](https://si.easyaf.dev/mcpessentials/guides/stores/entity-framework-core.md) with `UseSqlServer` until it ships.

This package exists for hosts that want Azure SQL or SQL Server **without** an EF model (ADO.NET, Dapper).

> [card] When it ships
>
> The host already uses `Microsoft.Data.SqlClient` and wants `rowversion` CAS on `McpTasks` under its own migrations.

> [card] [Until then](https://si.easyaf.dev/mcpessentials/guides/stores/entity-framework-core.md)
>
> Stay on Entity Framework Core + `UseSqlServer` when you already have a `DbContext`.

Service Broker and Query Notifications are heavy; scale-out elicitation pairs Azure SQL with Service Bus as [`IMcpTaskInputSignalBus`](https://si.easyaf.dev/mcpessentials/api-reference/CloudNimble/McpEssentials/Core/Tasks/IMcpTaskInputSignalBus).

## Intended how-to

**1. Add the package**

Add `McpEssentials.SqlServer`.

**2. Create the table**

`McpTasks` with `rowversion` for compare-and-swap, indexes on `OwnerUserId` and `DiscardAfter`.

**3. Register the store**

Singleton, same current-user factory as [Authenticated tasks](https://si.easyaf.dev/mcpessentials/guides/authenticated-tasks.md).

**4. Optional bus**

Register [`IMcpTaskInputSignalBus`](https://si.easyaf.dev/mcpessentials/api-reference/CloudNimble/McpEssentials/Core/Tasks/IMcpTaskInputSignalBus) for multi-node `ElicitAsync`.

## TTL

Call `SweepExpiredAsync` from a hosted service, or `DELETE WHERE DiscardAfter <= SYSUTCDATETIME()`. `DiscardAfter` is `CreatedAt + 2×TimeToLive`, stamped at write.

## Related

> [card] [Entity Framework Core](https://si.easyaf.dev/mcpessentials/guides/stores/entity-framework-core.md)
>
> Shipped. Any EF provider, including `UseSqlServer`.

> [card] [Stores](https://si.easyaf.dev/mcpessentials/guides/stores.md)
>
> Pick a backing store by the engine you already run.


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