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§
- Noop
Progress Sink - Zero-cost sink used whenever a caller does not care about progress.
- Progress
Handle - Ergonomic scoped handle: binds a
ProgressTokento aProgressSinkso tool code can emit without repeating the token argument. - Progress
Token - Opaque token identifying a single progress stream.
Traits§
- Progress
Sink - 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§
- Shared
Progress Sink - Shared/owned sink alias, for callers that need to stash one in a struct.