Optionaloptions: PostgresTaskStoreOptionsCreate a new task. Pass taskParams.taskId to use a caller-supplied ID verbatim
(useful for compliance-controller scenarios where the runner needs deterministic
task IDs). If omitted, a random hex ID is generated. Throws if the supplied ID
is empty / longer than 128 chars, or already exists. The 128-char ceiling is an
SDK policy (matches typical request-id / session-id field lengths and keeps
the task_id index efficient) — Postgres TEXT itself imposes no limit.
The task_id namespace on this store is global (no tenant scoping in the schema
today). Callers using caller-supplied IDs are responsible for namespace isolation;
cross-tenant collisions surface as already exists. Track the schema fix
(composite key on tenant + task_id) in a future SDK migration if production paths
ever wire caller-supplied IDs.
Optional_sessionId: stringGets the current status of a task.
The task identifier
Optional_sessionId: stringThe task object, or null if it does not exist
Stores the result of a task and sets its final status.
The task identifier
The final status: 'completed' for success, 'failed' for errors
The result to store
Optional_meta?: {See MCP specification for notes on _meta usage.
OptionalprogressToken?: string | numberIf specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.
Optionalio.modelcontextprotocol/related-task?: { taskId: string }If specified, this request is related to the provided task.
Optional_sessionId: stringRetrieves the stored result of a task.
The task identifier
Optional_sessionId: stringThe stored result
Updates a task's status (e.g., to 'cancelled', 'failed', 'completed').
The task identifier
The new status
OptionalstatusMessage: stringOptional diagnostic message for failed tasks or other status information
Optional_sessionId: stringLists tasks, optionally starting from a pagination cursor.
Optionalcursor: stringOptional cursor for pagination
Optional_sessionId: stringAn object containing the tasks array and an optional nextCursor
Delete expired tasks from the table.
Call this on a schedule (e.g., every 5 minutes) to reclaim storage. Reads automatically filter expired rows, so this is purely a storage optimization — not required for correctness.
The number of deleted rows.
No-op — PostgresTaskStore has no timers or background processes. Matches the cleanup() method that InMemoryTaskStore exposes.
PostgreSQL-backed implementation of the MCP SDK TaskStore interface.
All reads filter out expired tasks (via
expires_at), so no background timer is needed — expired tasks are simply invisible. CallcleanupExpired()periodically to reclaim storage.