Skip to main content

Module progress

Module progress 

Source
Expand description

Progress-notification hook for long-running tools.

This module provides an additive, no-op-by-default surface that tools can use to emit progress events during execution. Callers that care about progress (e.g. a future MCP server wrapping Construct tools and forwarding notifications/progress) can supply a real ProgressSink; everyone else gets a NoopProgressSink and pays no cost.

§Design

The Tool trait gained a new default method, [Tool::execute_with_progress], that takes a &dyn ProgressSink alongside the existing args. Its default body simply calls Tool::execute and drops the sink, so the ~93 existing tool implementations compile and behave exactly as before. Tool authors that want to emit progress opt in by overriding execute_with_progress.

§MCP alignment

The ProgressSink::notify shape (progress_token, progress, total: Option<u64>, message: Option<&str>) mirrors the MCP notifications/progress payload so that a future adapter can forward events verbatim.

Structs§

NoopProgressSink
Zero-cost sink used whenever a caller does not care about progress.
ProgressHandle
Ergonomic scoped handle: binds a ProgressToken to a ProgressSink so tool code can emit without repeating the token argument.
ProgressToken
Opaque token identifying a single progress stream.

Traits§

ProgressSink
Sink that receives progress emissions from a running tool.

Functions§

noop_sink
Process-wide default no-op sink, handed out when no sink is supplied.

Type Aliases§

SharedProgressSink
Shared/owned sink alias, for callers that need to stash one in a struct.