MCP TypeScript SDK (V2)
    Preparing search index...

    Request-scoped TaskStore interface.

    interface RequestTaskStore {
        createTask(
            taskParams: CreateTaskOptions,
        ): Promise<
            {
                createdAt: string;
                lastUpdatedAt: string;
                pollInterval?: number;
                status: | "working"
                | "input_required"
                | "completed"
                | "failed"
                | "cancelled";
                statusMessage?: string;
                taskId: string;
                ttl: number
                | null;
            },
        >;
        getTask(
            taskId: string,
        ): Promise<
            {
                createdAt: string;
                lastUpdatedAt: string;
                pollInterval?: number;
                status: | "working"
                | "input_required"
                | "completed"
                | "failed"
                | "cancelled";
                statusMessage?: string;
                taskId: string;
                ttl: number
                | null;
            },
        >;
        getTaskResult(
            taskId: string,
        ): Promise<
            {
                _meta?: {
                    "io.modelcontextprotocol/related-task"?: { taskId: string };
                    progressToken?: string | number;
                    [key: string]: unknown;
                };
                [key: string]: unknown;
            },
        >;
        listTasks(
            cursor?: string,
        ): Promise<
            {
                nextCursor?: string;
                tasks: {
                    createdAt: string;
                    lastUpdatedAt: string;
                    pollInterval?: number;
                    status: | "working"
                    | "input_required"
                    | "completed"
                    | "failed"
                    | "cancelled";
                    statusMessage?: string;
                    taskId: string;
                    ttl: number
                    | null;
                }[];
            },
        >;
        storeTaskResult(
            taskId: string,
            status: "completed" | "failed",
            result: {
                _meta?: {
                    "io.modelcontextprotocol/related-task"?: { taskId: string };
                    progressToken?: string | number;
                    [key: string]: unknown;
                };
                [key: string]: unknown;
            },
        ): Promise<void>;
        updateTaskStatus(
            taskId: string,
            status:
                | "working"
                | "input_required"
                | "completed"
                | "failed"
                | "cancelled",
            statusMessage?: string,
        ): Promise<void>;
    }
    Index

    Methods

    • Creates a new task with the given creation parameters. The implementation generates a unique taskId and createdAt timestamp.

      Parameters

      Returns Promise<
          {
              createdAt: string;
              lastUpdatedAt: string;
              pollInterval?: number;
              status: | "working"
              | "input_required"
              | "completed"
              | "failed"
              | "cancelled";
              statusMessage?: string;
              taskId: string;
              ttl: number
              | null;
          },
      >

      The created Task object

    • Gets the current status of a task.

      Parameters

      • taskId: string

        The task identifier

      Returns Promise<
          {
              createdAt: string;
              lastUpdatedAt: string;
              pollInterval?: number;
              status: | "working"
              | "input_required"
              | "completed"
              | "failed"
              | "cancelled";
              statusMessage?: string;
              taskId: string;
              ttl: number
              | null;
          },
      >

      The Task object

      If the task does not exist

    • Retrieves the stored result of a task.

      Parameters

      • taskId: string

        The task identifier

      Returns Promise<
          {
              _meta?: {
                  "io.modelcontextprotocol/related-task"?: { taskId: string };
                  progressToken?: string | number;
                  [key: string]: unknown;
              };
              [key: string]: unknown;
          },
      >

      The stored result

    • Lists tasks, optionally starting from a pagination cursor.

      Parameters

      • Optionalcursor: string

        Optional cursor for pagination

      Returns Promise<
          {
              nextCursor?: string;
              tasks: {
                  createdAt: string;
                  lastUpdatedAt: string;
                  pollInterval?: number;
                  status: | "working"
                  | "input_required"
                  | "completed"
                  | "failed"
                  | "cancelled";
                  statusMessage?: string;
                  taskId: string;
                  ttl: number
                  | null;
              }[];
          },
      >

      An object containing the tasks array and an optional nextCursor

    • Stores the result of a task and sets its final status.

      Parameters

      • taskId: string

        The task identifier

      • status: "completed" | "failed"

        The final status: 'completed' for success, 'failed' for errors

      • result: {
            _meta?: {
                "io.modelcontextprotocol/related-task"?: { taskId: string };
                progressToken?: string | number;
                [key: string]: unknown;
            };
            [key: string]: unknown;
        }

        The result to store

        • [key: string]: unknown
        • Optional_meta?: {
              "io.modelcontextprotocol/related-task"?: { taskId: string };
              progressToken?: string | number;
              [key: string]: unknown;
          }

          See MCP specification for notes on _meta usage.

          • Optionalio.modelcontextprotocol/related-task?: { taskId: string }

            If specified, this request is related to the provided task.

          • OptionalprogressToken?: string | number

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

      Returns Promise<void>

    • Updates a task's status (e.g., to 'cancelled', 'failed', 'completed').

      Parameters

      • taskId: string

        The task identifier

      • status: "working" | "input_required" | "completed" | "failed" | "cancelled"

        The new status

      • OptionalstatusMessage: string

        Optional diagnostic message for failed tasks or other status information

      Returns Promise<void>