ConduitMcp.Tasks (ConduitMCP v0.9.0)

Copy Markdown View Source

Task management for long-running MCP operations (experimental).

Tasks provide a durable state machine for operations that may take time to complete. Clients can poll for status, cancel in-flight operations, and receive results asynchronously.

Task Lifecycle

working  completed
working  failed
working  cancelled
working  input_required  working (after elicitation)

Usage

Tasks are stored in a pluggable store (defaults to ETS via ConduitMcp.Session.EtsStore pattern). The task registry is managed per-server.

Configuration

Enable tasks in your transport config:

{ConduitMcp.Transport.StreamableHTTP,
  server_module: MyServer,
  tasks: [enabled: true]}

Summary

Functions

Cancels a task.

Creates a new task in the ETS store.

Generates a unique task ID.

Gets a task by ID.

Lists all tasks, optionally filtered by status.

Updates a task's status and/or metadata.

Returns the list of valid task statuses.

Validates that a status transition is allowed.

Types

status()

@type status() :: :working | :input_required | :completed | :failed | :cancelled

task_id()

@type task_id() :: String.t()

Functions

cancel(task_id)

Cancels a task.

create(task_id, metadata \\ %{})

Creates a new task in the ETS store.

generate_id()

Generates a unique task ID.

get(task_id)

Gets a task by ID.

list(opts \\ [])

Lists all tasks, optionally filtered by status.

update(task_id, updates)

Updates a task's status and/or metadata.

valid_statuses()

Returns the list of valid task statuses.

valid_transition?(from, to)

Validates that a status transition is allowed.