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

    Experimental task features for low-level MCP servers.

    Access via server.experimental.tasks:

    const stream = server.experimental.tasks.requestStream(request, schema, options);
    

    For high-level server usage with task-based tools, use McpServer.experimental.tasks instead.

    Index

    Constructors

    Methods

    • Experimental

      Cancels a running task.

      Parameters

      • taskId: string

        The task identifier

      • Optionaloptions: RequestOptions

        Optional request options

      Returns Promise<
          {
              _meta?: {
                  "io.modelcontextprotocol/related-task"?: { taskId: string };
                  progressToken?: string | number;
                  [key: string]: unknown;
              };
              createdAt: string;
              lastUpdatedAt: string;
              pollInterval?: number;
              status: | "working"
              | "input_required"
              | "completed"
              | "failed"
              | "cancelled";
              statusMessage?: string;
              taskId: string;
              ttl: number
              | null;
          },
      >

    • Experimental

      Sends a sampling request and returns an AsyncGenerator that yields response messages. The generator is guaranteed to end with either a 'result' or 'error' message.

      For task-augmented requests, yields 'taskCreated' and 'taskStatus' messages before the final result.

      Parameters

      • params: {
            _meta?: {
                "io.modelcontextprotocol/related-task"?: { taskId: string };
                progressToken?: string | number;
                [key: string]: unknown;
            };
            includeContext?: "none"
            | "thisServer"
            | "allServers";
            maxTokens: number;
            messages: {
                _meta?: { [key: string]: unknown };
                content:
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ("user" | "assistant")[];
                            lastModified?: string;
                            priority?: number;
                        };
                        text: string;
                        type: "text";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ("user" | "assistant")[];
                            lastModified?: string;
                            priority?: number;
                        };
                        data: string;
                        mimeType: string;
                        type: "image";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ("user" | "assistant")[];
                            lastModified?: string;
                            priority?: number;
                        };
                        data: string;
                        mimeType: string;
                        type: "audio";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        id: string;
                        input: { [key: string]: unknown };
                        name: string;
                        type: "tool_use";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        content: (
                            | {
                                _meta?: { [key: string]: unknown };
                                annotations?: {
                                    audience?: (...) | (...);
                                    lastModified?: (...) | (...);
                                    priority?: (...) | (...);
                                };
                                text: string;
                                type: "text";
                            }
                            | {
                                _meta?: { [key: string]: unknown };
                                annotations?: {
                                    audience?: (...) | (...);
                                    lastModified?: (...) | (...);
                                    priority?: (...) | (...);
                                };
                                data: string;
                                mimeType: string;
                                type: "image";
                            }
                            | {
                                _meta?: { [key: string]: unknown };
                                annotations?: {
                                    audience?: (...) | (...);
                                    lastModified?: (...) | (...);
                                    priority?: (...) | (...);
                                };
                                data: string;
                                mimeType: string;
                                type: "audio";
                            }
                            | {
                                _meta?: { [key: string]: unknown };
                                annotations?: {
                                    audience?: (...) | (...);
                                    lastModified?: (...) | (...);
                                    priority?: (...) | (...);
                                };
                                resource: | {
                                    _meta?: (...)
                                    | (...);
                                    mimeType?: (...) | (...);
                                    text: string;
                                    uri: string;
                                }
                                | {
                                    _meta?: (...)
                                    | (...);
                                    blob: string;
                                    mimeType?: (...) | (...);
                                    uri: string;
                                };
                                type: "resource";
                            }
                            | {
                                _meta?: { [key: string]: unknown };
                                annotations?: {
                                    audience?: (...) | (...);
                                    lastModified?: (...) | (...);
                                    priority?: (...) | (...);
                                };
                                description?: string;
                                icons?: { mimeType?: ...; sizes?: ...; src: ...; theme?: ... }[];
                                mimeType?: string;
                                name: string;
                                title?: string;
                                type: "resource_link";
                                uri: string;
                            }
                        )[];
                        isError?: boolean;
                        structuredContent?: { [key: string]: unknown };
                        toolUseId: string;
                        type: "tool_result";
                    }
                    | (
                        | {
                            _meta?: { [key: string]: unknown };
                            annotations?: {
                                audience?: (...)[];
                                lastModified?: string;
                                priority?: number;
                            };
                            text: string;
                            type: "text";
                        }
                        | {
                            _meta?: { [key: string]: unknown };
                            annotations?: {
                                audience?: (...)[];
                                lastModified?: string;
                                priority?: number;
                            };
                            data: string;
                            mimeType: string;
                            type: "image";
                        }
                        | {
                            _meta?: { [key: string]: unknown };
                            annotations?: {
                                audience?: (...)[];
                                lastModified?: string;
                                priority?: number;
                            };
                            data: string;
                            mimeType: string;
                            type: "audio";
                        }
                        | {
                            _meta?: { [key: string]: unknown };
                            id: string;
                            input: { [key: string]: unknown };
                            name: string;
                            type: "tool_use";
                        }
                        | {
                            _meta?: { [key: string]: unknown };
                            content: (
                                | {
                                    _meta?: (...)
                                    | (...);
                                    annotations?: (...) | (...);
                                    text: string;
                                    type: "text";
                                }
                                | {
                                    _meta?: (...)
                                    | (...);
                                    annotations?: (...) | (...);
                                    data: string;
                                    mimeType: string;
                                    type: "image";
                                }
                                | {
                                    _meta?: (...)
                                    | (...);
                                    annotations?: (...) | (...);
                                    data: string;
                                    mimeType: string;
                                    type: "audio";
                                }
                                | {
                                    _meta?: (...)
                                    | (...);
                                    annotations?: (...) | (...);
                                    resource: (...) | (...);
                                    type: "resource";
                                }
                                | {
                                    _meta?: (...)
                                    | (...);
                                    annotations?: (...) | (...);
                                    description?: (...) | (...);
                                    icons?: (...) | (...);
                                    mimeType?: (...) | (...);
                                    name: string;
                                    title?: (...) | (...);
                                    type: "resource_link";
                                    uri: string;
                                }
                            )[];
                            isError?: boolean;
                            structuredContent?: { [key: string]: unknown };
                            toolUseId: string;
                            type: "tool_result";
                        }
                    )[];
                role: "user"
                | "assistant";
            }[];
            metadata?: object;
            modelPreferences?: {
                costPriority?: number;
                hints?: { name?: string }[];
                intelligencePriority?: number;
                speedPriority?: number;
            };
            stopSequences?: string[];
            systemPrompt?: string;
            task?: { ttl?: number };
            temperature?: number;
            toolChoice?: { mode?: "required" | "auto" | "none" };
            tools?: {
                _meta?: { [key: string]: unknown };
                annotations?: {
                    destructiveHint?: boolean;
                    idempotentHint?: boolean;
                    openWorldHint?: boolean;
                    readOnlyHint?: boolean;
                    title?: string;
                };
                description?: string;
                execution?: { taskSupport?: "optional"
                | "required"
                | "forbidden" };
                icons?: {
                    mimeType?: string;
                    sizes?: string[];
                    src: string;
                    theme?: "light" | "dark";
                }[];
                inputSchema: {
                    properties?: { [key: string]: object };
                    required?: string[];
                    type: "object";
                    [key: string]: unknown;
                };
                name: string;
                outputSchema?: {
                    properties?: { [key: string]: object };
                    required?: string[];
                    type: "object";
                    [key: string]: unknown;
                };
                title?: string;
            }[];
        }

        The sampling request parameters

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

          See General fields: _meta 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.

        • OptionalincludeContext?: "none" | "thisServer" | "allServers"

          A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. The client MAY ignore this request.

          Default is "none". Values "thisServer" and "allServers" are soft-deprecated. Servers SHOULD only use these values if the client declares ClientCapabilities.sampling.context. These values may be removed in future spec releases.

        • maxTokens: number

          The requested maximum number of tokens to sample (to prevent runaway completions).

          The client MAY choose to sample fewer tokens than the requested maximum.

        • messages: {
              _meta?: { [key: string]: unknown };
              content:
                  | {
                      _meta?: { [key: string]: unknown };
                      annotations?: {
                          audience?: ("user" | "assistant")[];
                          lastModified?: string;
                          priority?: number;
                      };
                      text: string;
                      type: "text";
                  }
                  | {
                      _meta?: { [key: string]: unknown };
                      annotations?: {
                          audience?: ("user" | "assistant")[];
                          lastModified?: string;
                          priority?: number;
                      };
                      data: string;
                      mimeType: string;
                      type: "image";
                  }
                  | {
                      _meta?: { [key: string]: unknown };
                      annotations?: {
                          audience?: ("user" | "assistant")[];
                          lastModified?: string;
                          priority?: number;
                      };
                      data: string;
                      mimeType: string;
                      type: "audio";
                  }
                  | {
                      _meta?: { [key: string]: unknown };
                      id: string;
                      input: { [key: string]: unknown };
                      name: string;
                      type: "tool_use";
                  }
                  | {
                      _meta?: { [key: string]: unknown };
                      content: (
                          | {
                              _meta?: { [key: string]: unknown };
                              annotations?: {
                                  audience?: (...) | (...);
                                  lastModified?: (...) | (...);
                                  priority?: (...) | (...);
                              };
                              text: string;
                              type: "text";
                          }
                          | {
                              _meta?: { [key: string]: unknown };
                              annotations?: {
                                  audience?: (...) | (...);
                                  lastModified?: (...) | (...);
                                  priority?: (...) | (...);
                              };
                              data: string;
                              mimeType: string;
                              type: "image";
                          }
                          | {
                              _meta?: { [key: string]: unknown };
                              annotations?: {
                                  audience?: (...) | (...);
                                  lastModified?: (...) | (...);
                                  priority?: (...) | (...);
                              };
                              data: string;
                              mimeType: string;
                              type: "audio";
                          }
                          | {
                              _meta?: { [key: string]: unknown };
                              annotations?: {
                                  audience?: (...) | (...);
                                  lastModified?: (...) | (...);
                                  priority?: (...) | (...);
                              };
                              resource: | {
                                  _meta?: (...)
                                  | (...);
                                  mimeType?: (...) | (...);
                                  text: string;
                                  uri: string;
                              }
                              | {
                                  _meta?: (...)
                                  | (...);
                                  blob: string;
                                  mimeType?: (...) | (...);
                                  uri: string;
                              };
                              type: "resource";
                          }
                          | {
                              _meta?: { [key: string]: unknown };
                              annotations?: {
                                  audience?: (...) | (...);
                                  lastModified?: (...) | (...);
                                  priority?: (...) | (...);
                              };
                              description?: string;
                              icons?: { mimeType?: ...; sizes?: ...; src: ...; theme?: ... }[];
                              mimeType?: string;
                              name: string;
                              title?: string;
                              type: "resource_link";
                              uri: string;
                          }
                      )[];
                      isError?: boolean;
                      structuredContent?: { [key: string]: unknown };
                      toolUseId: string;
                      type: "tool_result";
                  }
                  | (
                      | {
                          _meta?: { [key: string]: unknown };
                          annotations?: {
                              audience?: (...)[];
                              lastModified?: string;
                              priority?: number;
                          };
                          text: string;
                          type: "text";
                      }
                      | {
                          _meta?: { [key: string]: unknown };
                          annotations?: {
                              audience?: (...)[];
                              lastModified?: string;
                              priority?: number;
                          };
                          data: string;
                          mimeType: string;
                          type: "image";
                      }
                      | {
                          _meta?: { [key: string]: unknown };
                          annotations?: {
                              audience?: (...)[];
                              lastModified?: string;
                              priority?: number;
                          };
                          data: string;
                          mimeType: string;
                          type: "audio";
                      }
                      | {
                          _meta?: { [key: string]: unknown };
                          id: string;
                          input: { [key: string]: unknown };
                          name: string;
                          type: "tool_use";
                      }
                      | {
                          _meta?: { [key: string]: unknown };
                          content: (
                              | {
                                  _meta?: (...)
                                  | (...);
                                  annotations?: (...) | (...);
                                  text: string;
                                  type: "text";
                              }
                              | {
                                  _meta?: (...)
                                  | (...);
                                  annotations?: (...) | (...);
                                  data: string;
                                  mimeType: string;
                                  type: "image";
                              }
                              | {
                                  _meta?: (...)
                                  | (...);
                                  annotations?: (...) | (...);
                                  data: string;
                                  mimeType: string;
                                  type: "audio";
                              }
                              | {
                                  _meta?: (...)
                                  | (...);
                                  annotations?: (...) | (...);
                                  resource: (...) | (...);
                                  type: "resource";
                              }
                              | {
                                  _meta?: (...)
                                  | (...);
                                  annotations?: (...) | (...);
                                  description?: (...) | (...);
                                  icons?: (...) | (...);
                                  mimeType?: (...) | (...);
                                  name: string;
                                  title?: (...) | (...);
                                  type: "resource_link";
                                  uri: string;
                              }
                          )[];
                          isError?: boolean;
                          structuredContent?: { [key: string]: unknown };
                          toolUseId: string;
                          type: "tool_result";
                      }
                  )[];
              role: "user"
              | "assistant";
          }[]
        • Optionalmetadata?: object

          Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific.

        • OptionalmodelPreferences?: {
              costPriority?: number;
              hints?: { name?: string }[];
              intelligencePriority?: number;
              speedPriority?: number;
          }

          The server's preferences for which model to select. The client MAY modify or omit this request.

          • OptionalcostPriority?: number

            How much to prioritize cost when selecting a model.

          • Optionalhints?: { name?: string }[]

            Optional hints to use for model selection.

          • OptionalintelligencePriority?: number

            How much to prioritize intelligence and capabilities when selecting a model.

          • OptionalspeedPriority?: number

            How much to prioritize sampling speed (latency) when selecting a model.

        • OptionalstopSequences?: string[]
        • OptionalsystemPrompt?: string

          An optional system prompt the server wants to use for sampling. The client MAY modify or omit this prompt.

        • Optionaltask?: { ttl?: number }

          If specified, the caller is requesting task-augmented execution for this request. The request will return a CreateTaskResult immediately, and the actual result can be retrieved later via tasks/result.

          Task augmentation is subject to capability negotiation - receivers MUST declare support for task augmentation of specific request types in their capabilities.

        • Optionaltemperature?: number
        • OptionaltoolChoice?: { mode?: "required" | "auto" | "none" }

          Controls how the model uses tools. The client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared. Default is { mode: "auto" }.

          • Optionalmode?: "required" | "auto" | "none"

            Controls when tools are used:

            • "auto": Model decides whether to use tools (default)
            • "required": Model MUST use at least one tool before completing
            • "none": Model MUST NOT use any tools
        • Optionaltools?: {
              _meta?: { [key: string]: unknown };
              annotations?: {
                  destructiveHint?: boolean;
                  idempotentHint?: boolean;
                  openWorldHint?: boolean;
                  readOnlyHint?: boolean;
                  title?: string;
              };
              description?: string;
              execution?: { taskSupport?: "optional"
              | "required"
              | "forbidden" };
              icons?: {
                  mimeType?: string;
                  sizes?: string[];
                  src: string;
                  theme?: "light" | "dark";
              }[];
              inputSchema: {
                  properties?: { [key: string]: object };
                  required?: string[];
                  type: "object";
                  [key: string]: unknown;
              };
              name: string;
              outputSchema?: {
                  properties?: { [key: string]: object };
                  required?: string[];
                  type: "object";
                  [key: string]: unknown;
              };
              title?: string;
          }[]

          Tools that the model may use during generation. The client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared.

      • Optionaloptions: RequestOptions

        Optional request options (timeout, signal, task creation params, onprogress, etc.)

      Returns AsyncGenerator<
          ResponseMessage<
              {
                  _meta?: {
                      "io.modelcontextprotocol/related-task"?: { taskId: string };
                      progressToken?: string | number;
                      [key: string]: unknown;
                  };
                  content: | {
                      _meta?: { [key: string]: unknown };
                      annotations?: {
                          audience?: ("user" | "assistant")[];
                          lastModified?: string;
                          priority?: number;
                      };
                      text: string;
                      type: "text";
                  }
                  | {
                      _meta?: { [key: string]: unknown };
                      annotations?: {
                          audience?: ("user" | "assistant")[];
                          lastModified?: string;
                          priority?: number;
                      };
                      data: string;
                      mimeType: string;
                      type: "image";
                  }
                  | {
                      _meta?: { [key: string]: unknown };
                      annotations?: {
                          audience?: ("user" | "assistant")[];
                          lastModified?: string;
                          priority?: number;
                      };
                      data: string;
                      mimeType: string;
                      type: "audio";
                  };
                  model: string;
                  role: "user"
                  | "assistant";
                  stopReason?: string;
                  [key: string]: unknown;
              },
          >,
          void,
          void,
      >

      AsyncGenerator that yields ResponseMessage objects

      const stream = server.experimental.tasks.createMessageStream({
      messages: [{ role: 'user', content: { type: 'text', text: 'Hello' } }],
      maxTokens: 100
      }, {
      onprogress: (progress) => {
      // Handle streaming tokens via progress notifications
      console.log('Progress:', progress.message);
      }
      });

      for await (const message of stream) {
      switch (message.type) {
      case 'taskCreated':
      console.log('Task created:', message.task.taskId);
      break;
      case 'taskStatus':
      console.log('Task status:', message.task.status);
      break;
      case 'result':
      console.log('Final result:', message.result);
      break;
      case 'error':
      console.error('Error:', message.error);
      break;
      }
      }
    • Experimental

      Sends an elicitation request and returns an AsyncGenerator that yields response messages. The generator is guaranteed to end with either a 'result' or 'error' message.

      For task-augmented requests (especially URL-based elicitation), yields 'taskCreated' and 'taskStatus' messages before the final result.

      Parameters

      • params:
            | {
                _meta?: {
                    "io.modelcontextprotocol/related-task"?: { taskId: string };
                    progressToken?: string | number;
                    [key: string]: unknown;
                };
                elicitationId: string;
                message: string;
                mode: "url";
                task?: { ttl?: number };
                url: string;
            }
            | {
                _meta?: {
                    "io.modelcontextprotocol/related-task"?: { taskId: string };
                    progressToken?: string | number;
                    [key: string]: unknown;
                };
                message: string;
                mode?: "form";
                requestedSchema: {
                    properties: {
                        [key: string]: | {
                            default?: boolean;
                            description?: string;
                            title?: string;
                            type: "boolean";
                        }
                        | {
                            default?: string;
                            description?: string;
                            format?: "email"
                            | "date"
                            | "uri"
                            | "date-time";
                            maxLength?: number;
                            minLength?: number;
                            title?: string;
                            type: "string";
                        }
                        | {
                            default?: number;
                            description?: string;
                            maximum?: number;
                            minimum?: number;
                            title?: string;
                            type: "number"
                            | "integer";
                        }
                        | {
                            default?: string;
                            description?: string;
                            enum: string[];
                            enumNames?: string[];
                            title?: string;
                            type: "string";
                        }
                        | {
                            default?: string;
                            description?: string;
                            enum: string[];
                            title?: string;
                            type: "string";
                        }
                        | {
                            default?: string;
                            description?: string;
                            oneOf: { const: string; title: string }[];
                            title?: string;
                            type: "string";
                        }
                        | {
                            default?: string[];
                            description?: string;
                            items: { enum: string[]; type: "string" };
                            maxItems?: number;
                            minItems?: number;
                            title?: string;
                            type: "array";
                        }
                        | {
                            default?: string[];
                            description?: string;
                            items: { anyOf: { const: string; title: string }[] };
                            maxItems?: number;
                            minItems?: number;
                            title?: string;
                            type: "array";
                        };
                    };
                    required?: string[];
                    type: "object";
                };
                task?: { ttl?: number };
            }

        The elicitation request parameters

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

            See General fields: _meta 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.

          • elicitationId: string

            The ID of the elicitation, which must be unique within the context of the server. The client MUST treat this ID as an opaque value.

          • message: string

            The message to present to the user explaining why the interaction is needed.

          • mode: "url"

            The elicitation mode.

          • Optionaltask?: { ttl?: number }

            If specified, the caller is requesting task-augmented execution for this request. The request will return a CreateTaskResult immediately, and the actual result can be retrieved later via tasks/result.

            Task augmentation is subject to capability negotiation - receivers MUST declare support for task augmentation of specific request types in their capabilities.

          • url: string

            The URL that the user should navigate to.

        • {
              _meta?: {
                  "io.modelcontextprotocol/related-task"?: { taskId: string };
                  progressToken?: string | number;
                  [key: string]: unknown;
              };
              message: string;
              mode?: "form";
              requestedSchema: {
                  properties: {
                      [key: string]: | {
                          default?: boolean;
                          description?: string;
                          title?: string;
                          type: "boolean";
                      }
                      | {
                          default?: string;
                          description?: string;
                          format?: "email"
                          | "date"
                          | "uri"
                          | "date-time";
                          maxLength?: number;
                          minLength?: number;
                          title?: string;
                          type: "string";
                      }
                      | {
                          default?: number;
                          description?: string;
                          maximum?: number;
                          minimum?: number;
                          title?: string;
                          type: "number"
                          | "integer";
                      }
                      | {
                          default?: string;
                          description?: string;
                          enum: string[];
                          enumNames?: string[];
                          title?: string;
                          type: "string";
                      }
                      | {
                          default?: string;
                          description?: string;
                          enum: string[];
                          title?: string;
                          type: "string";
                      }
                      | {
                          default?: string;
                          description?: string;
                          oneOf: { const: string; title: string }[];
                          title?: string;
                          type: "string";
                      }
                      | {
                          default?: string[];
                          description?: string;
                          items: { enum: string[]; type: "string" };
                          maxItems?: number;
                          minItems?: number;
                          title?: string;
                          type: "array";
                      }
                      | {
                          default?: string[];
                          description?: string;
                          items: { anyOf: { const: string; title: string }[] };
                          maxItems?: number;
                          minItems?: number;
                          title?: string;
                          type: "array";
                      };
                  };
                  required?: string[];
                  type: "object";
              };
              task?: { ttl?: number };
          }
          • Optional_meta?: {
                "io.modelcontextprotocol/related-task"?: { taskId: string };
                progressToken?: string | number;
                [key: string]: unknown;
            }

            See General fields: _meta 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.

          • message: string

            The message to present to the user describing what information is being requested.

          • Optionalmode?: "form"

            The elicitation mode.

            Optional for backward compatibility. Clients MUST treat missing mode as "form".

          • requestedSchema: {
                properties: {
                    [key: string]:
                        | {
                            default?: boolean;
                            description?: string;
                            title?: string;
                            type: "boolean";
                        }
                        | {
                            default?: string;
                            description?: string;
                            format?: "email"
                            | "date"
                            | "uri"
                            | "date-time";
                            maxLength?: number;
                            minLength?: number;
                            title?: string;
                            type: "string";
                        }
                        | {
                            default?: number;
                            description?: string;
                            maximum?: number;
                            minimum?: number;
                            title?: string;
                            type: "number"
                            | "integer";
                        }
                        | {
                            default?: string;
                            description?: string;
                            enum: string[];
                            enumNames?: string[];
                            title?: string;
                            type: "string";
                        }
                        | {
                            default?: string;
                            description?: string;
                            enum: string[];
                            title?: string;
                            type: "string";
                        }
                        | {
                            default?: string;
                            description?: string;
                            oneOf: { const: string; title: string }[];
                            title?: string;
                            type: "string";
                        }
                        | {
                            default?: string[];
                            description?: string;
                            items: { enum: string[]; type: "string" };
                            maxItems?: number;
                            minItems?: number;
                            title?: string;
                            type: "array";
                        }
                        | {
                            default?: string[];
                            description?: string;
                            items: { anyOf: { const: string; title: string }[] };
                            maxItems?: number;
                            minItems?: number;
                            title?: string;
                            type: "array";
                        };
                };
                required?: string[];
                type: "object";
            }

            A restricted subset of JSON Schema. Only top-level properties are allowed, without nesting.

          • Optionaltask?: { ttl?: number }

            If specified, the caller is requesting task-augmented execution for this request. The request will return a CreateTaskResult immediately, and the actual result can be retrieved later via tasks/result.

            Task augmentation is subject to capability negotiation - receivers MUST declare support for task augmentation of specific request types in their capabilities.

      • Optionaloptions: RequestOptions

        Optional request options (timeout, signal, task creation params, etc.)

      Returns AsyncGenerator<
          ResponseMessage<
              {
                  _meta?: {
                      "io.modelcontextprotocol/related-task"?: { taskId: string };
                      progressToken?: string | number;
                      [key: string]: unknown;
                  };
                  action: "cancel"
                  | "accept"
                  | "decline";
                  content?: { [key: string]: string | number | boolean | string[] };
                  [key: string]: unknown;
              },
          >,
          void,
          void,
      >

      AsyncGenerator that yields ResponseMessage objects

      const stream = server.experimental.tasks.elicitInputStream({
      mode: 'url',
      message: 'Please authenticate',
      elicitationId: 'auth-123',
      url: 'https://example.com/auth'
      }, {
      task: { ttl: 300000 } // Task-augmented for long-running auth flow
      });

      for await (const message of stream) {
      switch (message.type) {
      case 'taskCreated':
      console.log('Task created:', message.task.taskId);
      break;
      case 'taskStatus':
      console.log('Task status:', message.task.status);
      break;
      case 'result':
      console.log('User action:', message.result.action);
      break;
      case 'error':
      console.error('Error:', message.error);
      break;
      }
      }
    • Experimental

      Gets the current status of a task.

      Parameters

      • taskId: string

        The task identifier

      • Optionaloptions: RequestOptions

        Optional request options

      Returns Promise<
          {
              _meta?: {
                  "io.modelcontextprotocol/related-task"?: { taskId: string };
                  progressToken?: string | number;
                  [key: string]: unknown;
              };
              createdAt: string;
              lastUpdatedAt: string;
              pollInterval?: number;
              status: | "working"
              | "input_required"
              | "completed"
              | "failed"
              | "cancelled";
              statusMessage?: string;
              taskId: string;
              ttl: number
              | null;
          },
      >

      The task status

    • Experimental

      Lists tasks with optional pagination.

      Parameters

      • Optionalcursor: string

        Optional pagination cursor

      • Optionaloptions: RequestOptions

        Optional request options

      Returns Promise<
          {
              _meta?: {
                  "io.modelcontextprotocol/related-task"?: { taskId: string };
                  progressToken?: string | number;
                  [key: string]: unknown;
              };
              nextCursor?: string;
              tasks: {
                  createdAt: string;
                  lastUpdatedAt: string;
                  pollInterval?: number;
                  status: | "working"
                  | "input_required"
                  | "completed"
                  | "failed"
                  | "cancelled";
                  statusMessage?: string;
                  taskId: string;
                  ttl: number
                  | null;
              }[];
              [key: string]: unknown;
          },
      >

      List of tasks with optional next cursor

    • Experimental

      Sends a request and returns an AsyncGenerator that yields response messages. The generator is guaranteed to end with either a 'result' or 'error' message.

      This method provides streaming access to request processing, allowing you to observe intermediate task status updates for task-augmented requests.

      Type Parameters

      Parameters

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

        The request to send

      • resultSchema: T

        Zod schema for validating the result

      • Optionaloptions: RequestOptions

        Optional request options (timeout, signal, task creation params, etc.)

      Returns AsyncGenerator<
          ResponseMessage<
              SchemaOutput<T> & {
                  _meta?: {
                      "io.modelcontextprotocol/related-task"?: { taskId: string };
                      progressToken?: string | number;
                      [key: string]: unknown;
                  };
                  [key: string]: unknown;
              },
          >,
          void,
          void,
      >

      AsyncGenerator that yields ResponseMessage objects