This is the documentation for v1.x — looking for the v2 documentation?
Skip to content

MCP TypeScript SDK / experimental

experimental ​

Classes ​

ExperimentalClientTasks ​

Defined in: src/experimental/tasks/client.ts:42

Experimental

Experimental task features for MCP clients.

Access via client.experimental.tasks:

typescript
const stream = client.experimental.tasks.callToolStream({ name: 'tool', arguments: {} });
const task = await client.experimental.tasks.getTask(taskId);

Type Parameters ​

RequestT ​

RequestT extends Request = Request

NotificationT ​

NotificationT extends Notification = Notification

ResultT ​

ResultT extends Result = Result

Constructors ​

Constructor ​

new ExperimentalClientTasks<RequestT, NotificationT, ResultT>(_client): ExperimentalClientTasks<RequestT, NotificationT, ResultT>

Defined in: src/experimental/tasks/client.ts:47

Experimental

Parameters ​
_client ​

Client<RequestT, NotificationT, ResultT>

Returns ​

ExperimentalClientTasks<RequestT, NotificationT, ResultT>

Methods ​

callToolStream() ​

callToolStream<T>(params, resultSchema?, options?): AsyncGenerator<ResponseMessage<SchemaOutput<T>>, void, void>

Defined in: src/experimental/tasks/client.ts:85

Experimental

Calls a tool 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 tool execution, allowing you to observe intermediate task status updates for long-running tool calls. Automatically validates structured output if the tool has an outputSchema.

Type Parameters ​
T ​

T extends ZodObject<{ _meta: ZodOptional<ZodObject<{ io.modelcontextprotocol/related-task: ZodOptional<ZodObject<{ taskId: ZodString; }, $strip>>; progressToken: ZodOptional<ZodUnion<readonly [ZodString, ZodNumber]>>; }, $loose>>; content: ZodDefault<ZodArray<ZodUnion<readonly [ZodObject<{ _meta: ZodOptional<ZodRecord<..., ...>>; annotations: ZodOptional<ZodObject<..., ...>>; text: ZodString; type: ZodLiteral<"text">; }, $strip>, ZodObject<{ _meta: ZodOptional<ZodRecord<..., ...>>; annotations: ZodOptional<ZodObject<..., ...>>; data: ZodString; mimeType: ZodString; type: ZodLiteral<"image">; }, $strip>, ZodObject<{ _meta: ZodOptional<ZodRecord<..., ...>>; annotations: ZodOptional<ZodObject<..., ...>>; data: ZodString; mimeType: ZodString; type: ZodLiteral<"audio">; }, $strip>, ZodObject<{ _meta: ZodOptional<ZodObject<..., ...>>; annotations: ZodOptional<ZodObject<..., ...>>; description: ZodOptional<ZodString>; icons: ZodOptional<ZodArray<...>>; mimeType: ZodOptional<ZodString>; name: ZodString; size: ZodOptional<ZodNumber>; title: ZodOptional<ZodString>; type: ZodLiteral<"resource_link">; uri: ZodString; }, $strip>, ZodObject<{ _meta: ZodOptional<ZodRecord<..., ...>>; annotations: ZodOptional<ZodObject<..., ...>>; resource: ZodUnion<readonly [..., ...]>; type: ZodLiteral<"resource">; }, $strip>]>>>; isError: ZodOptional<ZodBoolean>; structuredContent: ZodOptional<ZodRecord<ZodString, ZodUnknown>>; }, $loose> | ZodUnion<[ZodObject<{ _meta: ZodOptional<ZodObject<{ io.modelcontextprotocol/related-task: ZodOptional<ZodObject<{ taskId: ...; }, $strip>>; progressToken: ZodOptional<ZodUnion<readonly [..., ...]>>; }, $loose>>; content: ZodDefault<ZodArray<ZodUnion<readonly [ZodObject<{ _meta: ...; annotations: ...; text: ...; type: ...; }, $strip>, ZodObject<{ _meta: ...; annotations: ...; data: ...; mimeType: ...; type: ...; }, $strip>, ZodObject<{ _meta: ...; annotations: ...; data: ...; mimeType: ...; type: ...; }, $strip>, ZodObject<{ _meta: ...; annotations: ...; description: ...; icons: ...; mimeType: ...; name: ...; size: ...; title: ...; type: ...; uri: ...; }, $strip>, ZodObject<{ _meta: ...; annotations: ...; resource: ...; type: ...; }, $strip>]>>>; isError: ZodOptional<ZodBoolean>; structuredContent: ZodOptional<ZodRecord<ZodString, ZodUnknown>>; }, $loose>, ZodObject<{ _meta: ZodOptional<ZodObject<{ io.modelcontextprotocol/related-task: ZodOptional<ZodObject<{ taskId: ...; }, $strip>>; progressToken: ZodOptional<ZodUnion<readonly [..., ...]>>; }, $loose>>; toolResult: ZodUnknown; }, $loose>]>

Parameters ​
params ​

Tool call parameters (name and arguments)

_meta? ​

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

See General fields: _meta for notes on _meta usage.

{ taskId: string; } = ...

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

string = ...

_meta.progressToken? ​

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.

arguments? ​

{[key: string]: unknown; } = ...

Arguments to pass to the tool.

name ​

string = ...

The name of the tool to call.

task? ​

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

task.ttl? ​

number = ...

resultSchema? ​

T = ...

Zod schema for validating the result (defaults to CallToolResultSchema)

options? ​

RequestOptions

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

Returns ​

AsyncGenerator<ResponseMessage<SchemaOutput<T>>, void, void>

AsyncGenerator that yields ResponseMessage objects

Example ​
typescript
const stream = client.experimental.tasks.callToolStream({ name: 'myTool', arguments: {} });
for await (const message of stream) {
  switch (message.type) {
    case 'taskCreated':
      console.log('Tool execution started:', message.task.taskId);
      break;
    case 'taskStatus':
      console.log('Tool status:', message.task.status);
      break;
    case 'result':
      console.log('Tool result:', message.result);
      break;
    case 'error':
      console.error('Tool error:', message.error);
      break;
  }
}
cancelTask() ​

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

Defined in: src/experimental/tasks/client.ts:226

Experimental

Cancels a running task.

Parameters ​
taskId ​

string

The task identifier

options? ​

RequestOptions

Optional request options

Returns ​

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

getTask() ​

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

Defined in: src/experimental/tasks/client.ts:171

Experimental

Gets the current status of a task.

Parameters ​
taskId ​

string

The task identifier

options? ​

RequestOptions

Optional request options

Returns ​

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

The task status

getTaskResult() ​

getTaskResult<T>(taskId, resultSchema?, options?): Promise<SchemaOutput<T>>

Defined in: src/experimental/tasks/client.ts:187

Experimental

Retrieves the result of a completed task.

Type Parameters ​
T ​

T extends AnyObjectSchema

Parameters ​
taskId ​

string

The task identifier

resultSchema? ​

T

Zod schema for validating the result

options? ​

RequestOptions

Optional request options

Returns ​

Promise<SchemaOutput<T>>

The task result

listTasks() ​

listTasks(cursor?, options?): Promise<{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; nextCursor?: string; tasks: object[]; }>

Defined in: src/experimental/tasks/client.ts:209

Experimental

Lists tasks with optional pagination.

Parameters ​
cursor? ​

string

Optional pagination cursor

options? ​

RequestOptions

Optional request options

Returns ​

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

List of tasks with optional next cursor

requestStream() ​

requestStream<T>(request, resultSchema, options?): AsyncGenerator<ResponseMessage<SchemaOutput<T>>, void, void>

Defined in: src/experimental/tasks/client.ts:249

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 ​
T ​

T extends AnyObjectSchema

Parameters ​
request ​

ClientRequest | RequestT

The request to send

resultSchema ​

T

Zod schema for validating the result

options? ​

RequestOptions

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

Returns ​

AsyncGenerator<ResponseMessage<SchemaOutput<T>>, void, void>

AsyncGenerator that yields ResponseMessage objects


ExperimentalMcpServerTasks ​

Defined in: src/experimental/tasks/mcp-server.ts:41

Experimental

Experimental task features for McpServer.

Access via server.experimental.tasks:

typescript
server.experimental.tasks.registerToolTask('long-running', config, handler);

Constructors ​

Constructor ​

new ExperimentalMcpServerTasks(_mcpServer): ExperimentalMcpServerTasks

Defined in: src/experimental/tasks/mcp-server.ts:42

Experimental

Parameters ​
_mcpServer ​

McpServer

Returns ​

ExperimentalMcpServerTasks

Methods ​

registerToolTask() ​
Call Signature ​

registerToolTask<OutputArgs>(name, config, handler): RegisteredTool

Defined in: src/experimental/tasks/mcp-server.ts:79

Experimental

Registers a task-based tool with a config object and handler.

Task-based tools support long-running operations that can be polled for status and results. The handler must implement createTask, getTask, and getTaskResult methods.

Type Parameters ​
OutputArgs ​

OutputArgs extends AnySchema | ZodRawShapeCompat | undefined

Parameters ​
name ​

string

The tool name

config ​

Tool configuration (description, schemas, etc.)

_meta? ​

Record<string, unknown>

annotations? ​

{ destructiveHint?: boolean; idempotentHint?: boolean; openWorldHint?: boolean; readOnlyHint?: boolean; title?: string; }

annotations.destructiveHint? ​

boolean = ...

If true, the tool may perform destructive updates to its environment. If false, the tool performs only additive updates.

(This property is meaningful only when readOnlyHint == false)

Default: true

annotations.idempotentHint? ​

boolean = ...

If true, calling the tool repeatedly with the same arguments will have no additional effect on the its environment.

(This property is meaningful only when readOnlyHint == false)

Default: false

annotations.openWorldHint? ​

boolean = ...

If true, this tool may interact with an "open world" of external entities. If false, the tool's domain of interaction is closed. For example, the world of a web search tool is open, whereas that of a memory tool is not.

Default: true

annotations.readOnlyHint? ​

boolean = ...

If true, the tool does not modify its environment.

Default: false

annotations.title? ​

string = ...

A human-readable title for the tool.

description? ​

string

execution? ​

TaskToolExecution

outputSchema? ​

OutputArgs

title? ​

string

handler ​

ToolTaskHandler<undefined>

Task handler with createTask, getTask, getTaskResult methods

Returns ​

RegisteredTool

RegisteredTool for managing the tool's lifecycle

Example ​
typescript
server.experimental.tasks.registerToolTask('long-computation', {
  description: 'Performs a long computation',
  inputSchema: { input: z.string() },
  execution: { taskSupport: 'required' }
}, {
  createTask: async (args, extra) => {
    const task = await extra.taskStore.createTask({ ttl: 300000 });
    startBackgroundWork(task.taskId, args);
    return { task };
  },
  getTask: async (args, extra) => {
    return extra.taskStore.getTask(extra.taskId);
  },
  getTaskResult: async (args, extra) => {
    return extra.taskStore.getTaskResult(extra.taskId);
  }
});
Call Signature ​

registerToolTask<InputArgs, OutputArgs>(name, config, handler): RegisteredTool

Defined in: src/experimental/tasks/mcp-server.ts:92

Experimental

Registers a task-based tool with a config object and handler.

Task-based tools support long-running operations that can be polled for status and results. The handler must implement createTask, getTask, and getTaskResult methods.

Type Parameters ​
InputArgs ​

InputArgs extends AnySchema | ZodRawShapeCompat

OutputArgs ​

OutputArgs extends AnySchema | ZodRawShapeCompat | undefined

Parameters ​
name ​

string

The tool name

config ​

Tool configuration (description, schemas, etc.)

_meta? ​

Record<string, unknown>

annotations? ​

{ destructiveHint?: boolean; idempotentHint?: boolean; openWorldHint?: boolean; readOnlyHint?: boolean; title?: string; }

annotations.destructiveHint? ​

boolean = ...

If true, the tool may perform destructive updates to its environment. If false, the tool performs only additive updates.

(This property is meaningful only when readOnlyHint == false)

Default: true

annotations.idempotentHint? ​

boolean = ...

If true, calling the tool repeatedly with the same arguments will have no additional effect on the its environment.

(This property is meaningful only when readOnlyHint == false)

Default: false

annotations.openWorldHint? ​

boolean = ...

If true, this tool may interact with an "open world" of external entities. If false, the tool's domain of interaction is closed. For example, the world of a web search tool is open, whereas that of a memory tool is not.

Default: true

annotations.readOnlyHint? ​

boolean = ...

If true, the tool does not modify its environment.

Default: false

annotations.title? ​

string = ...

A human-readable title for the tool.

description? ​

string

execution? ​

TaskToolExecution

inputSchema ​

InputArgs

outputSchema? ​

OutputArgs

title? ​

string

handler ​

ToolTaskHandler<InputArgs>

Task handler with createTask, getTask, getTaskResult methods

Returns ​

RegisteredTool

RegisteredTool for managing the tool's lifecycle

Example ​
typescript
server.experimental.tasks.registerToolTask('long-computation', {
  description: 'Performs a long computation',
  inputSchema: { input: z.string() },
  execution: { taskSupport: 'required' }
}, {
  createTask: async (args, extra) => {
    const task = await extra.taskStore.createTask({ ttl: 300000 });
    startBackgroundWork(task.taskId, args);
    return { task };
  },
  getTask: async (args, extra) => {
    return extra.taskStore.getTask(extra.taskId);
  },
  getTaskResult: async (args, extra) => {
    return extra.taskStore.getTaskResult(extra.taskId);
  }
});

ExperimentalServerTasks ​

Defined in: src/experimental/tasks/server.ts:40

Experimental

Experimental task features for low-level MCP servers.

Access via server.experimental.tasks:

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

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

Type Parameters ​

RequestT ​

RequestT extends Request = Request

NotificationT ​

NotificationT extends Notification = Notification

ResultT ​

ResultT extends Result = Result

Constructors ​

Constructor ​

new ExperimentalServerTasks<RequestT, NotificationT, ResultT>(_server): ExperimentalServerTasks<RequestT, NotificationT, ResultT>

Defined in: src/experimental/tasks/server.ts:45

Experimental

Parameters ​
_server ​

Server<RequestT, NotificationT, ResultT>

Returns ​

ExperimentalServerTasks<RequestT, NotificationT, ResultT>

Methods ​

cancelTask() ​

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

Defined in: src/experimental/tasks/server.ts:320

Experimental

Cancels a running task.

Parameters ​
taskId ​

string

The task identifier

options? ​

RequestOptions

Optional request options

Returns ​

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

createMessageStream() ​

createMessageStream(params, options?): AsyncGenerator<ResponseMessage<{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; 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; }>, void, void>

Defined in: src/experimental/tasks/server.ts:120

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 ​

The sampling request parameters

_meta? ​

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

See General fields: _meta for notes on _meta usage.

{ taskId: string; } = ...

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

string = ...

_meta.progressToken? ​

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.

includeContext? ​

"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 ​

object[] = ...

metadata? ​

object = ...

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

modelPreferences? ​

{ costPriority?: number; hints?: object[]; intelligencePriority?: number; speedPriority?: number; } = ...

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

modelPreferences.costPriority? ​

number = ...

How much to prioritize cost when selecting a model.

modelPreferences.hints? ​

object[] = ...

Optional hints to use for model selection.

modelPreferences.intelligencePriority? ​

number = ...

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

modelPreferences.speedPriority? ​

number = ...

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

stopSequences? ​

string[] = ...

systemPrompt? ​

string = ...

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

task? ​

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

task.ttl? ​

number = ...

temperature? ​

number = ...

toolChoice? ​

{ mode?: "required" | "none" | "auto"; } = ...

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" }.

toolChoice.mode? ​

"required" | "none" | "auto" = ...

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
tools? ​

object[] = ...

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.

options? ​

RequestOptions

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

Returns ​

AsyncGenerator<ResponseMessage<{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; 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; }>, void, void>

AsyncGenerator that yields ResponseMessage objects

Example ​
typescript
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;
    }
}
elicitInputStream() ​

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

Defined in: src/experimental/tasks/server.ts:220

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?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; message: string; mode?: "form"; requestedSchema: { properties: {[key: string]: { 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: object[]; 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: object[]; }; maxItems?: number; minItems?: number; title?: string; type: "array"; } | { default?: boolean; description?: string; title?: string; type: "boolean"; } | { default?: string; description?: string; format?: "date" | "uri" | "email" | "date-time"; maxLength?: number; minLength?: number; title?: string; type: "string"; } | { default?: number; description?: string; maximum?: number; minimum?: number; title?: string; type: "number" | "integer"; }; }; required?: string[]; type: "object"; }; task?: { ttl?: number; }; } | { _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; elicitationId: string; message: string; mode: "url"; task?: { ttl?: number; }; url: string; }

The elicitation request parameters

Type Literal ​

{ _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; message: string; mode?: "form"; requestedSchema: { properties: {[key: string]: { 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: object[]; 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: object[]; }; maxItems?: number; minItems?: number; title?: string; type: "array"; } | { default?: boolean; description?: string; title?: string; type: "boolean"; } | { default?: string; description?: string; format?: "date" | "uri" | "email" | "date-time"; maxLength?: number; minLength?: number; title?: string; type: "string"; } | { default?: number; description?: string; maximum?: number; minimum?: number; title?: string; type: "number" | "integer"; }; }; required?: string[]; type: "object"; }; task?: { ttl?: number; }; }

The elicitation request parameters

_meta? ​

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

See General fields: _meta for notes on _meta usage.

{ taskId: string; } = ...

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

string = ...

_meta.progressToken? ​

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.

mode? ​

"form" = ...

The elicitation mode.

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

requestedSchema ​

{ properties: {[key: string]: { 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: object[]; 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: object[]; }; maxItems?: number; minItems?: number; title?: string; type: "array"; } | { default?: boolean; description?: string; title?: string; type: "boolean"; } | { default?: string; description?: string; format?: "date" | "uri" | "email" | "date-time"; maxLength?: number; minLength?: number; title?: string; type: "string"; } | { default?: number; description?: string; maximum?: number; minimum?: number; title?: string; type: "number" | "integer"; }; }; required?: string[]; type: "object"; } = ...

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

requestedSchema.properties ​

{[key: string]: { 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: object[]; 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: object[]; }; maxItems?: number; minItems?: number; title?: string; type: "array"; } | { default?: boolean; description?: string; title?: string; type: "boolean"; } | { default?: string; description?: string; format?: "date" | "uri" | "email" | "date-time"; maxLength?: number; minLength?: number; title?: string; type: "string"; } | { default?: number; description?: string; maximum?: number; minimum?: number; title?: string; type: "number" | "integer"; }; } = ...

requestedSchema.required? ​

string[] = ...

requestedSchema.type ​

"object" = ...

task? ​

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

task.ttl? ​

number = ...


Type Literal ​

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

The elicitation request parameters

_meta? ​

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

See General fields: _meta for notes on _meta usage.

{ taskId: string; } = ...

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

string = ...

_meta.progressToken? ​

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.

task? ​

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

task.ttl? ​

number = ...

url ​

string = ...

The URL that the user should navigate to.

options? ​

RequestOptions

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

Returns ​

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

AsyncGenerator that yields ResponseMessage objects

Example ​
typescript
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;
    }
}
getTask() ​

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

Defined in: src/experimental/tasks/server.ts:268

Experimental

Gets the current status of a task.

Parameters ​
taskId ​

string

The task identifier

options? ​

RequestOptions

Optional request options

Returns ​

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

The task status

getTaskResult() ​

getTaskResult<T>(taskId, resultSchema?, options?): Promise<SchemaOutput<T>>

Defined in: src/experimental/tasks/server.ts:283

Experimental

Retrieves the result of a completed task.

Type Parameters ​
T ​

T extends AnySchema

Parameters ​
taskId ​

string

The task identifier

resultSchema? ​

T

Zod schema for validating the result

options? ​

RequestOptions

Optional request options

Returns ​

Promise<SchemaOutput<T>>

The task result

listTasks() ​

listTasks(cursor?, options?): Promise<{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; nextCursor?: string; tasks: object[]; }>

Defined in: src/experimental/tasks/server.ts:304

Experimental

Lists tasks with optional pagination.

Parameters ​
cursor? ​

string

Optional pagination cursor

options? ​

RequestOptions

Optional request options

Returns ​

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

List of tasks with optional next cursor

requestStream() ​

requestStream<T>(request, resultSchema, options?): AsyncGenerator<ResponseMessage<SchemaOutput<T>>, void, void>

Defined in: src/experimental/tasks/server.ts:61

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 ​
T ​

T extends AnySchema

Parameters ​
request ​

ServerRequest | RequestT

The request to send

resultSchema ​

T

Zod schema for validating the result

options? ​

RequestOptions

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

Returns ​

AsyncGenerator<ResponseMessage<SchemaOutput<T>>, void, void>

AsyncGenerator that yields ResponseMessage objects


InMemoryTaskMessageQueue ​

Defined in: src/experimental/tasks/stores/in-memory.ts:246

Experimental

A simple in-memory implementation of TaskMessageQueue for demonstration purposes.

This implementation stores messages in memory, organized by task ID and optional session ID. Messages are stored in FIFO queues per task.

Note: This is not suitable for production use in distributed systems. For production, consider implementing TaskMessageQueue with Redis or other distributed queues.

Implements ​

Constructors ​

Constructor ​

new InMemoryTaskMessageQueue(): InMemoryTaskMessageQueue

Experimental

Returns ​

InMemoryTaskMessageQueue

Methods ​

dequeue() ​

dequeue(taskId, sessionId?): Promise<QueuedMessage | undefined>

Defined in: src/experimental/tasks/stores/in-memory.ts:297

Experimental

Removes and returns the first message from the queue for a specific task.

Parameters ​
taskId ​

string

The task identifier

sessionId? ​

string

Optional session ID for binding the query to a specific session

Returns ​

Promise<QueuedMessage | undefined>

The first message, or undefined if the queue is empty

Implementation of ​

TaskMessageQueue.dequeue

dequeueAll() ​

dequeueAll(taskId, sessionId?): Promise<QueuedMessage[]>

Defined in: src/experimental/tasks/stores/in-memory.ts:308

Experimental

Removes and returns all messages from the queue for a specific task.

Parameters ​
taskId ​

string

The task identifier

sessionId? ​

string

Optional session ID for binding the query to a specific session

Returns ​

Promise<QueuedMessage[]>

Array of all messages that were in the queue

Implementation of ​

TaskMessageQueue.dequeueAll

enqueue() ​

enqueue(taskId, message, sessionId?, maxSize?): Promise<void>

Defined in: src/experimental/tasks/stores/in-memory.ts:280

Experimental

Adds a message to the end of the queue for a specific task. Atomically checks queue size and throws if maxSize would be exceeded.

Parameters ​
taskId ​

string

The task identifier

message ​

QueuedMessage

The message to enqueue

sessionId? ​

string

Optional session ID for binding the operation to a specific session

maxSize? ​

number

Optional maximum queue size - if specified and queue is full, throws an error

Returns ​

Promise<void>

Throws ​

Error if maxSize is specified and would be exceeded

Implementation of ​

TaskMessageQueue.enqueue


InMemoryTaskStore ​

Defined in: src/experimental/tasks/stores/in-memory.ts:36

Experimental

A simple in-memory implementation of TaskStore for demonstration purposes.

This implementation stores all tasks in memory and provides automatic cleanup based on the ttl duration specified in the task creation parameters.

A task created with a sessionId belongs to that session: calls that pass a different sessionId treat the task as not found, and listTasks with a sessionId returns that session's tasks and the tasks created without a sessionId. Calls that pass no sessionId are not restricted.

Note: This is not suitable for production use as all data is lost on restart. For production, consider implementing TaskStore with a database or distributed cache.

Implements ​

Constructors ​

Constructor ​

new InMemoryTaskStore(): InMemoryTaskStore

Experimental

Returns ​

InMemoryTaskStore

Methods ​

cleanup() ​

cleanup(): void

Defined in: src/experimental/tasks/stores/in-memory.ts:219

Experimental

Cleanup all timers (useful for testing or graceful shutdown)

Returns ​

void

createTask() ​

createTask(taskParams, requestId, request, sessionId?): Promise<{ createdAt: string; lastUpdatedAt: string; pollInterval?: number; status: "working" | "input_required" | "completed" | "failed" | "cancelled"; statusMessage?: string; taskId: string; ttl: number | null; }>

Defined in: src/experimental/tasks/stores/in-memory.ts:59

Experimental

Creates a new task with the given creation parameters and original request. The implementation must generate a unique taskId and createdAt timestamp.

TTL Management:

  • The implementation receives the TTL suggested by the requestor via taskParams.ttl
  • The implementation MAY override the requested TTL (e.g., to enforce limits)
  • The actual TTL used MUST be returned in the Task object
  • Null TTL indicates unlimited task lifetime (no automatic cleanup)
  • Cleanup SHOULD occur automatically after TTL expires, regardless of task status
Parameters ​
taskParams ​

CreateTaskOptions

The task creation parameters from the request (ttl, pollInterval)

requestId ​

RequestId

The JSON-RPC request ID

request ​

The original request that triggered task creation

method ​

string = ...

params? ​

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

params._meta? ​

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

See General fields: _meta for notes on _meta usage.

{ taskId: string; } = ...

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

string = ...

params._meta.progressToken? ​

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.

sessionId? ​

string

Optional session ID for binding the task to a specific session

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

Implementation of ​

TaskStore.createTask

getAllTasks() ​

getAllTasks(): object[]

Defined in: src/experimental/tasks/stores/in-memory.ts:230

Experimental

Get all tasks of all sessions (useful for debugging)

Returns ​
getTask() ​

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

Defined in: src/experimental/tasks/stores/in-memory.ts:102

Experimental

Gets the current status of a task.

Parameters ​
taskId ​

string

The task identifier

sessionId? ​

string

Optional session ID for binding the query to a specific session

Returns ​

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

The task object, or null if it does not exist

Implementation of ​

TaskStore.getTask

getTaskResult() ​

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

Defined in: src/experimental/tasks/stores/in-memory.ts:140

Experimental

Retrieves the stored result of a task.

Parameters ​
taskId ​

string

The task identifier

sessionId? ​

string

Optional session ID for binding the query to a specific session

Returns ​

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

The stored result

Implementation of ​

TaskStore.getTaskResult

listTasks() ​

listTasks(cursor?, sessionId?): Promise<{ nextCursor?: string; tasks: object[]; }>

Defined in: src/experimental/tasks/stores/in-memory.ts:189

Experimental

Lists tasks, optionally starting from a pagination cursor.

Parameters ​
cursor? ​

string

Optional cursor for pagination

sessionId? ​

string

Optional session ID for binding the query to a specific session

Returns ​

Promise<{ nextCursor?: string; tasks: object[]; }>

An object containing the tasks array and an optional nextCursor

Implementation of ​

TaskStore.listTasks

storeTaskResult() ​

storeTaskResult(taskId, status, result, sessionId?): Promise<void>

Defined in: src/experimental/tasks/stores/in-memory.ts:107

Experimental

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 ​

The result to store

_meta? ​

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

See MCP specification for notes on _meta usage.

{ taskId: string; } = ...

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

string = ...

_meta.progressToken? ​

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.

sessionId? ​

string

Optional session ID for binding the operation to a specific session

Returns ​

Promise<void>

Implementation of ​

TaskStore.storeTaskResult

updateTaskStatus() ​

updateTaskStatus(taskId, status, statusMessage?, sessionId?): Promise<void>

Defined in: src/experimental/tasks/stores/in-memory.ts:153

Experimental

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

statusMessage? ​

string

Optional diagnostic message for failed tasks or other status information

sessionId? ​

string

Optional session ID for binding the operation to a specific session

Returns ​

Promise<void>

Implementation of ​

TaskStore.updateTaskStatus

Interfaces ​

BaseQueuedMessage ​

Defined in: src/experimental/tasks/interfaces.ts:105

Extended by ​

Properties ​

timestamp ​

timestamp: number

Defined in: src/experimental/tasks/interfaces.ts:109

When the message was queued (milliseconds since epoch)

type ​

type: string

Defined in: src/experimental/tasks/interfaces.ts:107

Type of message


BaseResponseMessage ​

Defined in: src/shared/responseMessage.ts:6

Base message type

Extended by ​

Properties ​

type ​

type: string

Defined in: src/shared/responseMessage.ts:7


CreateTaskOptions ​

Defined in: src/experimental/tasks/interfaces.ts:185

Experimental

Task creation options.

Properties ​

context? ​

optional context?: Record<string, unknown>

Defined in: src/experimental/tasks/interfaces.ts:200

Experimental

Additional context to pass to the task store.

pollInterval? ​

optional pollInterval?: number

Defined in: src/experimental/tasks/interfaces.ts:195

Experimental

Time in milliseconds to wait between task status requests.

ttl? ​

optional ttl?: number | null

Defined in: src/experimental/tasks/interfaces.ts:190

Experimental

Time in milliseconds to keep task results available after completion. If null, the task has unlimited lifetime until manually cleaned up.


CreateTaskRequestHandlerExtra ​

Defined in: src/experimental/tasks/interfaces.ts:33

Experimental

Extended handler extra with task store for task creation.

Extends ​

Properties ​

_meta? ​

optional _meta?: object

Defined in: src/shared/protocol.ts:256

Experimental

Metadata from the original request.

Index Signature ​

[key: string]: unknown

optional io.modelcontextprotocol/related-task?: object

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

taskId: string

progressToken? ​

optional progressToken?: 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.

Inherited from ​

RequestHandlerExtra._meta

authInfo? ​

optional authInfo?: AuthInfo

Defined in: src/shared/protocol.ts:246

Experimental

Information about a validated access token, provided to request handlers.

Inherited from ​

RequestHandlerExtra.authInfo

closeSSEStream? ​

optional closeSSEStream?: () => void

Defined in: src/shared/protocol.ts:294

Experimental

Closes the SSE stream for this request, triggering client reconnection. Only available when using StreamableHTTPServerTransport with eventStore configured. Use this to implement polling behavior during long-running operations.

Returns ​

void

Inherited from ​

RequestHandlerExtra.closeSSEStream

closeStandaloneSSEStream? ​

optional closeStandaloneSSEStream?: () => void

Defined in: src/shared/protocol.ts:301

Experimental

Closes the standalone GET SSE stream, triggering client reconnection. Only available when using StreamableHTTPServerTransport with eventStore configured. Use this to implement polling behavior for server-initiated notifications.

Returns ​

void

Inherited from ​

RequestHandlerExtra.closeStandaloneSSEStream

requestId ​

requestId: RequestId

Defined in: src/shared/protocol.ts:262

Experimental

The JSON-RPC ID of the request being handled. This can be useful for tracking or logging purposes.

Inherited from ​

RequestHandlerExtra.requestId

requestInfo? ​

optional requestInfo?: RequestInfo

Defined in: src/shared/protocol.ts:273

Experimental

The original HTTP request.

Inherited from ​

RequestHandlerExtra.requestInfo

sendNotification ​

sendNotification: (notification) => Promise<void>

Defined in: src/shared/protocol.ts:280

Experimental

Sends a notification that relates to the current request being handled.

This is used by certain transports to correctly associate related messages.

Parameters ​
notification ​

ServerNotification

Returns ​

Promise<void>

Inherited from ​

RequestHandlerExtra.sendNotification

sendRequest ​

sendRequest: <U>(request, resultSchema, options?) => Promise<SchemaOutput<U>>

Defined in: src/shared/protocol.ts:287

Experimental

Sends a request that relates to the current request being handled.

This is used by certain transports to correctly associate related messages.

Type Parameters ​
U ​

U extends AnySchema

Parameters ​
request ​

ServerRequest

resultSchema ​

U

options? ​

TaskRequestOptions

Returns ​

Promise<SchemaOutput<U>>

Inherited from ​

RequestHandlerExtra.sendRequest

sessionId? ​

optional sessionId?: string

Defined in: src/shared/protocol.ts:251

Experimental

The session ID from the transport, if available.

Inherited from ​

RequestHandlerExtra.sessionId

signal ​

signal: AbortSignal

Defined in: src/shared/protocol.ts:241

Experimental

An abort signal used to communicate if the request was cancelled from the sender's side.

Inherited from ​

RequestHandlerExtra.signal

taskId? ​

optional taskId?: string

Defined in: src/shared/protocol.ts:264

Experimental

Inherited from ​

RequestHandlerExtra.taskId

taskRequestedTtl? ​

optional taskRequestedTtl?: number

Defined in: src/shared/protocol.ts:268

Experimental

Inherited from ​

RequestHandlerExtra.taskRequestedTtl

taskStore ​

taskStore: RequestTaskStore

Defined in: src/experimental/tasks/interfaces.ts:34

Experimental

Overrides ​

RequestHandlerExtra.taskStore


ErrorMessage ​

Defined in: src/shared/responseMessage.ts:37

Error message (terminal)

Extends ​

Properties ​

error ​

error: McpError

Defined in: src/shared/responseMessage.ts:39

type ​

type: "error"

Defined in: src/shared/responseMessage.ts:38

Overrides ​

BaseResponseMessage.type


QueuedError ​

Defined in: src/experimental/tasks/interfaces.ts:130

Extends ​

Properties ​

message ​

message: object

Defined in: src/experimental/tasks/interfaces.ts:133

The actual JSONRPC error

error ​

error: object

error.code ​

code: number

The error type that occurred.

error.data? ​

optional data?: unknown

Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).

error.message ​

message: string

A short description of the error. The message SHOULD be limited to a concise single sentence.

id? ​

optional id?: string | number

jsonrpc ​

jsonrpc: "2.0"

timestamp ​

timestamp: number

Defined in: src/experimental/tasks/interfaces.ts:109

When the message was queued (milliseconds since epoch)

Inherited from ​

BaseQueuedMessage.timestamp

type ​

type: "error"

Defined in: src/experimental/tasks/interfaces.ts:131

Type of message

Overrides ​

BaseQueuedMessage.type


QueuedNotification ​

Defined in: src/experimental/tasks/interfaces.ts:118

Extends ​

Properties ​

message ​

message: object

Defined in: src/experimental/tasks/interfaces.ts:121

The actual JSONRPC notification

jsonrpc ​

jsonrpc: "2.0"

method ​

method: string

params? ​

optional params?: object

Index Signature ​

[key: string]: unknown

params._meta? ​

optional _meta?: object

See MCP specification for notes on _meta usage.

Index Signature ​

[key: string]: unknown

optional io.modelcontextprotocol/related-task?: object

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

taskId: string

params._meta.progressToken? ​

optional progressToken?: 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.

timestamp ​

timestamp: number

Defined in: src/experimental/tasks/interfaces.ts:109

When the message was queued (milliseconds since epoch)

Inherited from ​

BaseQueuedMessage.timestamp

type ​

type: "notification"

Defined in: src/experimental/tasks/interfaces.ts:119

Type of message

Overrides ​

BaseQueuedMessage.type


QueuedRequest ​

Defined in: src/experimental/tasks/interfaces.ts:112

Extends ​

Properties ​

message ​

message: object

Defined in: src/experimental/tasks/interfaces.ts:115

The actual JSONRPC request

id ​

id: string | number = RequestIdSchema

jsonrpc ​

jsonrpc: "2.0"

method ​

method: string

params? ​

optional params?: object

Index Signature ​

[key: string]: unknown

params._meta? ​

optional _meta?: object

See General fields: _meta for notes on _meta usage.

Index Signature ​

[key: string]: unknown

optional io.modelcontextprotocol/related-task?: object

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

taskId: string

params._meta.progressToken? ​

optional progressToken?: 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.

timestamp ​

timestamp: number

Defined in: src/experimental/tasks/interfaces.ts:109

When the message was queued (milliseconds since epoch)

Inherited from ​

BaseQueuedMessage.timestamp

type ​

type: "request"

Defined in: src/experimental/tasks/interfaces.ts:113

Type of message

Overrides ​

BaseQueuedMessage.type


QueuedResponse ​

Defined in: src/experimental/tasks/interfaces.ts:124

Extends ​

Properties ​

message ​

message: object

Defined in: src/experimental/tasks/interfaces.ts:127

The actual JSONRPC response

id ​

id: string | number = RequestIdSchema

jsonrpc ​

jsonrpc: "2.0"

result ​

result: object = ResultSchema

Index Signature ​

[key: string]: unknown

result._meta? ​

optional _meta?: object

See MCP specification for notes on _meta usage.

Index Signature ​

[key: string]: unknown

optional io.modelcontextprotocol/related-task?: object

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

taskId: string

result._meta.progressToken? ​

optional progressToken?: 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.

timestamp ​

timestamp: number

Defined in: src/experimental/tasks/interfaces.ts:109

When the message was queued (milliseconds since epoch)

Inherited from ​

BaseQueuedMessage.timestamp

type ​

type: "response"

Defined in: src/experimental/tasks/interfaces.ts:125

Type of message

Overrides ​

BaseQueuedMessage.type


ResultMessage ​

Defined in: src/shared/responseMessage.ts:29

Final result message (terminal)

Extends ​

Type Parameters ​

T ​

T extends Result

Properties ​

result ​

result: T

Defined in: src/shared/responseMessage.ts:31

type ​

type: "result"

Defined in: src/shared/responseMessage.ts:30

Overrides ​

BaseResponseMessage.type


TaskCreatedMessage ​

Defined in: src/shared/responseMessage.ts:21

Task created message (first message for task-augmented requests)

Extends ​

Properties ​

task ​

task: object

Defined in: src/shared/responseMessage.ts:23

createdAt ​

createdAt: string

ISO 8601 timestamp when the task was created.

lastUpdatedAt ​

lastUpdatedAt: string

ISO 8601 timestamp when the task was last updated.

pollInterval? ​

optional pollInterval?: number

status ​

status: "working" | "input_required" | "completed" | "failed" | "cancelled" = TaskStatusSchema

statusMessage? ​

optional statusMessage?: string

Optional diagnostic message for failed tasks or other status information.

taskId ​

taskId: string

ttl ​

ttl: number | null

Time in milliseconds to keep task results available after completion. If null, the task has unlimited lifetime until manually cleaned up.

type ​

type: "taskCreated"

Defined in: src/shared/responseMessage.ts:22

Overrides ​

BaseResponseMessage.type


TaskMessageQueue ​

Defined in: src/experimental/tasks/interfaces.ts:151

Experimental

Interface for managing per-task FIFO message queues.

Similar to TaskStore, this allows pluggable queue implementations (in-memory, Redis, other distributed queues, etc.).

Each method accepts taskId and optional sessionId parameters to enable a single queue instance to manage messages for multiple tasks, with isolation based on task ID and session ID.

All methods are async to support external storage implementations. All data in QueuedMessage must be JSON-serializable.

Methods ​

dequeue() ​

dequeue(taskId, sessionId?): Promise<QueuedMessage | undefined>

Defined in: src/experimental/tasks/interfaces.ts:169

Experimental

Removes and returns the first message from the queue for a specific task.

Parameters ​
taskId ​

string

The task identifier

sessionId? ​

string

Optional session ID for binding the query to a specific session

Returns ​

Promise<QueuedMessage | undefined>

The first message, or undefined if the queue is empty

dequeueAll() ​

dequeueAll(taskId, sessionId?): Promise<QueuedMessage[]>

Defined in: src/experimental/tasks/interfaces.ts:178

Experimental

Removes and returns all messages from the queue for a specific task. Used when tasks are cancelled or failed to clean up pending messages.

Parameters ​
taskId ​

string

The task identifier

sessionId? ​

string

Optional session ID for binding the query to a specific session

Returns ​

Promise<QueuedMessage[]>

Array of all messages that were in the queue

enqueue() ​

enqueue(taskId, message, sessionId?, maxSize?): Promise<void>

Defined in: src/experimental/tasks/interfaces.ts:161

Experimental

Adds a message to the end of the queue for a specific task. Atomically checks queue size and throws if maxSize would be exceeded.

Parameters ​
taskId ​

string

The task identifier

message ​

QueuedMessage

The message to enqueue

sessionId? ​

string

Optional session ID for binding the operation to a specific session

maxSize? ​

number

Optional maximum queue size - if specified and queue is full, throws an error

Returns ​

Promise<void>

Throws ​

Error if maxSize is specified and would be exceeded


TaskRequestHandlerExtra ​

Defined in: src/experimental/tasks/interfaces.ts:41

Experimental

Extended handler extra with task ID and store for task operations.

Extends ​

Properties ​

_meta? ​

optional _meta?: object

Defined in: src/shared/protocol.ts:256

Experimental

Metadata from the original request.

Index Signature ​

[key: string]: unknown

optional io.modelcontextprotocol/related-task?: object

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

taskId: string

progressToken? ​

optional progressToken?: 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.

Inherited from ​

RequestHandlerExtra._meta

authInfo? ​

optional authInfo?: AuthInfo

Defined in: src/shared/protocol.ts:246

Experimental

Information about a validated access token, provided to request handlers.

Inherited from ​

RequestHandlerExtra.authInfo

closeSSEStream? ​

optional closeSSEStream?: () => void

Defined in: src/shared/protocol.ts:294

Experimental

Closes the SSE stream for this request, triggering client reconnection. Only available when using StreamableHTTPServerTransport with eventStore configured. Use this to implement polling behavior during long-running operations.

Returns ​

void

Inherited from ​

RequestHandlerExtra.closeSSEStream

closeStandaloneSSEStream? ​

optional closeStandaloneSSEStream?: () => void

Defined in: src/shared/protocol.ts:301

Experimental

Closes the standalone GET SSE stream, triggering client reconnection. Only available when using StreamableHTTPServerTransport with eventStore configured. Use this to implement polling behavior for server-initiated notifications.

Returns ​

void

Inherited from ​

RequestHandlerExtra.closeStandaloneSSEStream

requestId ​

requestId: RequestId

Defined in: src/shared/protocol.ts:262

Experimental

The JSON-RPC ID of the request being handled. This can be useful for tracking or logging purposes.

Inherited from ​

RequestHandlerExtra.requestId

requestInfo? ​

optional requestInfo?: RequestInfo

Defined in: src/shared/protocol.ts:273

Experimental

The original HTTP request.

Inherited from ​

RequestHandlerExtra.requestInfo

sendNotification ​

sendNotification: (notification) => Promise<void>

Defined in: src/shared/protocol.ts:280

Experimental

Sends a notification that relates to the current request being handled.

This is used by certain transports to correctly associate related messages.

Parameters ​
notification ​

ServerNotification

Returns ​

Promise<void>

Inherited from ​

RequestHandlerExtra.sendNotification

sendRequest ​

sendRequest: <U>(request, resultSchema, options?) => Promise<SchemaOutput<U>>

Defined in: src/shared/protocol.ts:287

Experimental

Sends a request that relates to the current request being handled.

This is used by certain transports to correctly associate related messages.

Type Parameters ​
U ​

U extends AnySchema

Parameters ​
request ​

ServerRequest

resultSchema ​

U

options? ​

TaskRequestOptions

Returns ​

Promise<SchemaOutput<U>>

Inherited from ​

RequestHandlerExtra.sendRequest

sessionId? ​

optional sessionId?: string

Defined in: src/shared/protocol.ts:251

Experimental

The session ID from the transport, if available.

Inherited from ​

RequestHandlerExtra.sessionId

signal ​

signal: AbortSignal

Defined in: src/shared/protocol.ts:241

Experimental

An abort signal used to communicate if the request was cancelled from the sender's side.

Inherited from ​

RequestHandlerExtra.signal

taskId ​

taskId: string

Defined in: src/experimental/tasks/interfaces.ts:42

Experimental

Overrides ​

RequestHandlerExtra.taskId

taskRequestedTtl? ​

optional taskRequestedTtl?: number

Defined in: src/shared/protocol.ts:268

Experimental

Inherited from ​

RequestHandlerExtra.taskRequestedTtl

taskStore ​

taskStore: RequestTaskStore

Defined in: src/experimental/tasks/interfaces.ts:43

Experimental

Overrides ​

RequestHandlerExtra.taskStore


TaskStatusMessage ​

Defined in: src/shared/responseMessage.ts:13

Task status update message

Extends ​

Properties ​

task ​

task: object

Defined in: src/shared/responseMessage.ts:15

createdAt ​

createdAt: string

ISO 8601 timestamp when the task was created.

lastUpdatedAt ​

lastUpdatedAt: string

ISO 8601 timestamp when the task was last updated.

pollInterval? ​

optional pollInterval?: number

status ​

status: "working" | "input_required" | "completed" | "failed" | "cancelled" = TaskStatusSchema

statusMessage? ​

optional statusMessage?: string

Optional diagnostic message for failed tasks or other status information.

taskId ​

taskId: string

ttl ​

ttl: number | null

Time in milliseconds to keep task results available after completion. If null, the task has unlimited lifetime until manually cleaned up.

type ​

type: "taskStatus"

Defined in: src/shared/responseMessage.ts:14

Overrides ​

BaseResponseMessage.type


TaskStore ​

Defined in: src/experimental/tasks/interfaces.ts:215

Experimental

Interface for storing and retrieving task state and results.

Similar to Transport, this allows pluggable task storage implementations (in-memory, database, distributed cache, etc.).

Every method receives the sessionId of the request it serves. A store shared by several sessions should record the sessionId passed to createTask and treat a task as not found (and leave it out of listTasks) when a different sessionId asks for it.

Methods ​

createTask() ​

createTask(taskParams, requestId, request, sessionId?): Promise<{ createdAt: string; lastUpdatedAt: string; pollInterval?: number; status: "working" | "input_required" | "completed" | "failed" | "cancelled"; statusMessage?: string; taskId: string; ttl: number | null; }>

Defined in: src/experimental/tasks/interfaces.ts:233

Experimental

Creates a new task with the given creation parameters and original request. The implementation must generate a unique taskId and createdAt timestamp.

TTL Management:

  • The implementation receives the TTL suggested by the requestor via taskParams.ttl
  • The implementation MAY override the requested TTL (e.g., to enforce limits)
  • The actual TTL used MUST be returned in the Task object
  • Null TTL indicates unlimited task lifetime (no automatic cleanup)
  • Cleanup SHOULD occur automatically after TTL expires, regardless of task status
Parameters ​
taskParams ​

CreateTaskOptions

The task creation parameters from the request (ttl, pollInterval)

requestId ​

RequestId

The JSON-RPC request ID

request ​

The original request that triggered task creation

method ​

string = ...

params? ​

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

params._meta? ​

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

See General fields: _meta for notes on _meta usage.

{ taskId: string; } = ...

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

string = ...

params._meta.progressToken? ​

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.

sessionId? ​

string

Optional session ID for binding the task to a specific session

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

getTask() ​

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

Defined in: src/experimental/tasks/interfaces.ts:242

Experimental

Gets the current status of a task.

Parameters ​
taskId ​

string

The task identifier

sessionId? ​

string

Optional session ID for binding the query to a specific session

Returns ​

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

The task object, or null if it does not exist

getTaskResult() ​

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

Defined in: src/experimental/tasks/interfaces.ts:261

Experimental

Retrieves the stored result of a task.

Parameters ​
taskId ​

string

The task identifier

sessionId? ​

string

Optional session ID for binding the query to a specific session

Returns ​

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

The stored result

listTasks() ​

listTasks(cursor?, sessionId?): Promise<{ nextCursor?: string; tasks: object[]; }>

Defined in: src/experimental/tasks/interfaces.ts:280

Experimental

Lists tasks, optionally starting from a pagination cursor.

Parameters ​
cursor? ​

string

Optional cursor for pagination

sessionId? ​

string

Optional session ID for binding the query to a specific session

Returns ​

Promise<{ nextCursor?: string; tasks: object[]; }>

An object containing the tasks array and an optional nextCursor

storeTaskResult() ​

storeTaskResult(taskId, status, result, sessionId?): Promise<void>

Defined in: src/experimental/tasks/interfaces.ts:252

Experimental

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 ​

The result to store

_meta? ​

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

See MCP specification for notes on _meta usage.

{ taskId: string; } = ...

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

string = ...

_meta.progressToken? ​

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.

sessionId? ​

string

Optional session ID for binding the operation to a specific session

Returns ​

Promise<void>

updateTaskStatus() ​

updateTaskStatus(taskId, status, statusMessage?, sessionId?): Promise<void>

Defined in: src/experimental/tasks/interfaces.ts:271

Experimental

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

statusMessage? ​

string

Optional diagnostic message for failed tasks or other status information

sessionId? ​

string

Optional session ID for binding the operation to a specific session

Returns ​

Promise<void>


ToolTaskHandler ​

Defined in: src/experimental/tasks/interfaces.ts:82

Experimental

Interface for task-based tool handlers.

Type Parameters ​

Args ​

Args extends undefined | ZodRawShapeCompat | AnySchema = undefined

Properties ​

createTask ​

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

Defined in: src/experimental/tasks/interfaces.ts:83

Experimental

getTask ​

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

Defined in: src/experimental/tasks/interfaces.ts:84

Experimental

getTaskResult ​

getTaskResult: BaseToolCallback<{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; 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; }; annotations?: { audience?: ("user" | "assistant")[]; lastModified?: string; priority?: number; }; description?: string; icons?: object[]; mimeType?: string; name: string; size?: number; title?: string; type: "resource_link"; uri: string; } | { _meta?: {[key: string]: unknown; }; annotations?: { audience?: ("user" | "assistant")[]; lastModified?: string; priority?: number; }; resource: { _meta?: {[key: string]: unknown; }; mimeType?: string; text: string; uri: string; } | { _meta?: {[key: string]: unknown; }; blob: string; mimeType?: string; uri: string; }; type: "resource"; })[]; isError?: boolean; structuredContent?: {[key: string]: unknown; }; }, TaskRequestHandlerExtra>

Defined in: src/experimental/tasks/interfaces.ts:85

Experimental

Type Aliases ​

BaseToolCallback ​

BaseToolCallback<SendResultT, ExtraT, Args> = Args extends ZodRawShapeCompat ? (args, extra) => SendResultT | Promise<SendResultT> : Args extends AnySchema ? (args, extra) => SendResultT | Promise<SendResultT> : (extra) => SendResultT | Promise<SendResultT>

Defined in: src/experimental/tasks/interfaces.ts:50

Experimental

Base callback type for tool handlers.

Type Parameters ​

SendResultT ​

SendResultT extends Result

ExtraT ​

ExtraT extends RequestHandlerExtra<ServerRequest, ServerNotification>

Args ​

Args extends undefined | ZodRawShapeCompat | AnySchema = undefined


CreateTaskRequestHandler ​

CreateTaskRequestHandler<SendResultT, Args> = BaseToolCallback<SendResultT, CreateTaskRequestHandlerExtra, Args>

Defined in: src/experimental/tasks/interfaces.ts:64

Experimental

Handler for creating a task.

Type Parameters ​

SendResultT ​

SendResultT extends Result

Args ​

Args extends undefined | ZodRawShapeCompat | AnySchema = undefined


QueuedMessage ​

QueuedMessage = QueuedRequest | QueuedNotification | QueuedResponse | QueuedError

Defined in: src/experimental/tasks/interfaces.ts:103

Represents a message queued for side-channel delivery via tasks/result.

This is a serializable data structure that can be stored in external systems. All fields are JSON-serializable.


ResponseMessage ​

ResponseMessage<T> = TaskStatusMessage | TaskCreatedMessage | ResultMessage<T> | ErrorMessage

Defined in: src/shared/responseMessage.ts:47

Union type representing all possible messages that can be yielded during request processing. Note: Progress notifications are handled through the existing onprogress callback mechanism. Side-channeled messages (server requests/notifications) are handled through registered handlers.

Type Parameters ​

T ​

T extends Result


TaskRequestHandler ​

TaskRequestHandler<SendResultT, Args> = BaseToolCallback<SendResultT, TaskRequestHandlerExtra, Args>

Defined in: src/experimental/tasks/interfaces.ts:73

Experimental

Handler for task operations (get, getResult).

Type Parameters ​

SendResultT ​

SendResultT extends Result

Args ​

Args extends undefined | ZodRawShapeCompat | AnySchema = undefined


TaskToolExecution ​

TaskToolExecution<TaskSupport> = Omit<ToolExecution, "taskSupport"> & object

Defined in: src/experimental/tasks/interfaces.ts:93

Experimental

Task-specific execution configuration. taskSupport cannot be 'forbidden' for task-based tools.

Type Declaration ​

taskSupport ​

taskSupport: TaskSupport extends "forbidden" | undefined ? never : TaskSupport

Type Parameters ​

TaskSupport ​

TaskSupport = ToolExecution["taskSupport"]

Functions ​

assertClientRequestTaskCapability() ​

assertClientRequestTaskCapability(requests, method, entityName): void

Defined in: src/experimental/tasks/helpers.ts:62

Experimental

Asserts that task creation is supported for sampling/createMessage or elicitation/create. Used by Server.assertTaskCapability and Client.assertTaskHandlerCapability.

Parameters ​

requests ​

TaskRequestsCapability | undefined

The task requests capability object

method ​

string

The method being checked

entityName ​

"Server" | "Client"

'Server' or 'Client' for error messages

Returns ​

void

Throws ​

Error if the capability is not supported


assertToolsCallTaskCapability() ​

assertToolsCallTaskCapability(requests, method, entityName): void

Defined in: src/experimental/tasks/helpers.ts:29

Experimental

Asserts that task creation is supported for tools/call. Used by Client.assertTaskCapability and Server.assertTaskHandlerCapability.

Parameters ​

requests ​

TaskRequestsCapability | undefined

The task requests capability object

method ​

string

The method being checked

entityName ​

"Server" | "Client"

'Server' or 'Client' for error messages

Returns ​

void

Throws ​

Error if the capability is not supported


isTerminal() ​

isTerminal(status): boolean

Defined in: src/experimental/tasks/interfaces.ts:291

Experimental

Checks if a task status represents a terminal state. Terminal states are those where the task has finished and will not change.

Parameters ​

status ​

"working" | "input_required" | "completed" | "failed" | "cancelled"

The task status to check

Returns ​

boolean

True if the status is terminal (completed, failed, or cancelled)


takeResult() ​

takeResult<T, U>(it): Promise<T>

Defined in: src/shared/responseMessage.ts:60

Type Parameters ​

T ​

T extends object

U ​

U extends AsyncGenerator<ResponseMessage<T>, any, any>

Parameters ​

it ​

U

Returns ​

Promise<T>


toArrayAsync() ​

toArrayAsync<T>(it): Promise<AsyncGeneratorValue<T>[]>

Defined in: src/shared/responseMessage.ts:51

Type Parameters ​

T ​

T extends AsyncGenerator<unknown, any, any>

Parameters ​

it ​

T

Returns ​

Promise<AsyncGeneratorValue<T>[]>

References ​

CancelTaskRequest ​

Re-exports CancelTaskRequest


CancelTaskRequestSchema ​

Re-exports CancelTaskRequestSchema


CancelTaskResult ​

Re-exports CancelTaskResult


CancelTaskResultSchema ​

Re-exports CancelTaskResultSchema


ClientTasksCapabilitySchema ​

Re-exports ClientTasksCapabilitySchema


CreateTaskResult ​

Re-exports CreateTaskResult


CreateTaskResultSchema ​

Re-exports CreateTaskResultSchema


GetTaskPayloadRequest ​

Re-exports GetTaskPayloadRequest


GetTaskPayloadRequestSchema ​

Re-exports GetTaskPayloadRequestSchema


GetTaskRequest ​

Re-exports GetTaskRequest


GetTaskRequestSchema ​

Re-exports GetTaskRequestSchema


GetTaskResult ​

Re-exports GetTaskResult


GetTaskResultSchema ​

Re-exports GetTaskResultSchema


ListTasksRequest ​

Re-exports ListTasksRequest


ListTasksRequestSchema ​

Re-exports ListTasksRequestSchema


ListTasksResult ​

Re-exports ListTasksResult


ListTasksResultSchema ​

Re-exports ListTasksResultSchema


RelatedTaskMetadata ​

Re-exports RelatedTaskMetadata


RelatedTaskMetadataSchema ​

Re-exports RelatedTaskMetadataSchema


ServerTasksCapabilitySchema ​

Re-exports ServerTasksCapabilitySchema


Task ​

Re-exports Task


TaskCreationParams ​

Re-exports TaskCreationParams


TaskCreationParamsSchema ​

Re-exports TaskCreationParamsSchema


TaskSchema ​

Re-exports TaskSchema


TaskStatusNotification ​

Re-exports TaskStatusNotification


TaskStatusNotificationParams ​

Re-exports TaskStatusNotificationParams


TaskStatusNotificationParamsSchema ​

Re-exports TaskStatusNotificationParamsSchema


TaskStatusNotificationSchema ​

Re-exports TaskStatusNotificationSchema