Skip to main content
Progress notifications allow tools to report their progress during execution, providing real-time feedback for long-running operations.

Basic usage

Use the reportProgress function from the context object:

Progress with known total

When you know the total number of items or bytes:

Progress with bytes

Report progress for file operations using bytes:

Progress without known total

For indeterminate operations, report progress as a percentage:

Combining with logging

Provide both progress updates and detailed logs:

Progress with streaming

Combine progress with streaming output:

Best practices

1

Update progress regularly

Update progress frequently enough to provide smooth feedback, but not so often that it impacts performance.
2

Always report completion

Always report 100% progress when the operation completes.
3

Use meaningful units

Choose progress units that make sense for your operation (items, bytes, percentage).
4

Handle errors gracefully

Don’t report progress if an error occurs.

Performance considerations

Calling reportProgress too frequently can impact performance. Batch your progress updates for optimal performance.

Next steps

Streaming Output

Learn about streaming partial results

Logging

Add detailed logging to your tools