ExperimentalExperimentalRegisters 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.
The tool name
Tool configuration (description, schemas, etc.)
Task handler with createTask, getTask, getTaskResult methods
RegisteredTool for managing the tool's lifecycle
server.experimental.tasks.registerToolTask('long-computation', {
description: 'Performs a long computation',
inputSchema: z.object({ input: z.string() }),
execution: { taskSupport: 'required' }
}, {
createTask: async (args, ctx) => {
const task = await ctx.task.store.createTask({ ttl: 300000 });
startBackgroundWork(task.taskId, args);
return { task };
},
getTask: async (args, ctx) => {
return ctx.task.store.getTask(ctx.task.id);
},
getTaskResult: async (args, ctx) => {
return ctx.task.store.getTaskResult(ctx.task.id);
}
});
ExperimentalRegisters 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.
The tool name
Tool configuration (description, schemas, etc.)
Task handler with createTask, getTask, getTaskResult methods
RegisteredTool for managing the tool's lifecycle
server.experimental.tasks.registerToolTask('long-computation', {
description: 'Performs a long computation',
inputSchema: z.object({ input: z.string() }),
execution: { taskSupport: 'required' }
}, {
createTask: async (args, ctx) => {
const task = await ctx.task.store.createTask({ ttl: 300000 });
startBackgroundWork(task.taskId, args);
return { task };
},
getTask: async (args, ctx) => {
return ctx.task.store.getTask(ctx.task.id);
},
getTaskResult: async (args, ctx) => {
return ctx.task.store.getTaskResult(ctx.task.id);
}
});
Experimental task features for
McpServer.Access via
server.experimental.tasks: