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

# PostgreSqlMcpTaskStore

> An [IMcpTaskStorePlus](/mcpessentials/api-reference/CloudNimble/McpEssentials/Core/Tasks/IMcpTaskStorePlus) that persists snapshots as PostgreSQL rows with `LISTEN` / `NOT...

## Definition

**Assembly:** CloudNimble.McpEssentials.PostgreSQL.dll

**Namespace:** CloudNimble.McpEssentials.PostgreSQL.Tasks

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

## Syntax

```csharp theme={"dark"}
CloudNimble.McpEssentials.PostgreSQL.Tasks.PostgreSqlMcpTaskStore
```

## Summary

An [IMcpTaskStorePlus](https://si.easyaf.dev/mcpessentials/api-reference/CloudNimble/McpEssentials/Core/Tasks/IMcpTaskStorePlus.md) that persists snapshots as PostgreSQL rows with
`LISTEN` / `NOTIFY` fan-out for resolved input.

## Remarks

Register as a singleton. The host owns `NpgsqlDataSource`.
[McpTaskStoreBase.AutoSweep](https://si.easyaf.dev/mcpessentials/api-reference/CloudNimble/McpEssentials/Core/Tasks/McpTaskStoreBase.md#autosweep) defaults to [`true`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool). Sweep is
`DELETE WHERE "DiscardAfter" &lt;= now`. Use Entity Framework Core with
`UseNpgsql` when the host already has a `DbContext`; this package exists
for Npgsql/Dapper hosts and for native notification.

## Constructors

### &#x20;.ctor

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

#### Syntax

```csharp theme={"dark"}
public PostgreSqlMcpTaskStore(Npgsql.NpgsqlDataSource dataSource, System.Func<string> getCurrentUserId)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `dataSource` | `Npgsql.NpgsqlDataSource` | The Npgsql data source. 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. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | Thrown when *dataSource* 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 PostgreSqlMcpTaskStore(Npgsql.NpgsqlDataSource dataSource, string userId)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `dataSource` | `Npgsql.NpgsqlDataSource` | The Npgsql data source. 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. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | Thrown when *dataSource* 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 PostgreSqlMcpTaskStore(Npgsql.NpgsqlDataSource dataSource, System.Func<System.Security.Claims.ClaimsPrincipal> getPrincipal)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `dataSource` | `Npgsql.NpgsqlDataSource` | The Npgsql data source. The host owns its lifetime. |
| `getPrincipal` | `System.Func<System.Security.Claims.ClaimsPrincipal?>` | Returns the principal for the current request. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | Thrown when *dataSource* 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 PostgreSqlMcpTaskStore(System.Func<Npgsql.NpgsqlDataSource> getDataSource, System.Func<string> getCurrentUserId)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `getDataSource` | `System.Func<Npgsql.NpgsqlDataSource>` | Returns the data source 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. |

#### Exceptions

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

## Properties

### &#x20;ListenChannel Virtual

Gets or sets the `LISTEN` / `NOTIFY` channel for resolved input.

#### Syntax

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

#### Property Value

Type: `string`

### &#x20;Schema Virtual

Gets or sets the schema that holds the tasks table.

#### Syntax

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

#### Property Value

Type: `string`

### &#x20;TableName Virtual

Gets or sets the tasks table name.

#### Syntax

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

#### Property Value

Type: `string`


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