← Back to ToolBench
Utilities
Progress
Report progress on long-running operations
What it does
Progress notifications allow either side to report incremental progress on long-running operations. When a request includes a progressToken, the handler sends notifications/progress with a current value, optional total, and optional message. This enables clients to show progress bars and status indicators, keeping users informed during operations that take time.
How it works
Example implementation
server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
const items = await getItems();
for (let i = 0; i < items.length; i++) {
await processItem(items[i]);
await extra.sendProgress({ progress: i + 1, total: items.length });
}
return { content: [{ type: "text", text: "Done" }] };
});