ExperimentalExperimentalCalls 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.
Tool call parameters (name and arguments)
Optional_meta?: {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 | numberIf specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.
Optionalarguments?: { [key: string]: unknown }Arguments to pass to the tool.
The name of the tool to call.
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: RequestOptionsOptional request options (timeout, signal, task creation params, etc.)
AsyncGenerator that yields ResponseMessage objects
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;
}
}
}
ExperimentalCancels a running task.
The task identifier
Optionaloptions: RequestOptionsOptional request options
ExperimentalGets the current status of a task.
The task identifier
Optionaloptions: RequestOptionsOptional request options
The task status
ExperimentalRetrieves the result of a completed task.
The task identifier
OptionalresultSchema: TZod schema for validating the result
Optionaloptions: RequestOptionsOptional request options
The task result
ExperimentalLists tasks with optional pagination.
Optionalcursor: stringOptional pagination cursor
Optionaloptions: RequestOptionsOptional request options
List of tasks with optional next cursor
ExperimentalSends 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.
The request to send
Zod schema for validating the result
Optionaloptions: RequestOptionsOptional request options (timeout, signal, task creation params, etc.)
AsyncGenerator that yields ResponseMessage objects
const stream = client.experimental.tasks.requestStream(request, CallToolResultSchema, options);
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 task features for MCP clients.
Access via
client.experimental.tasks: