Why Use Progress Reporting?
Progress reporting is valuable for:- User experience: Keep users informed about long-running operations
- Progress indicators: Enable clients to show progress bars or percentages
- Timeout prevention: Demonstrate that operations are actively progressing
- Debugging: Track execution progress for performance analysis
Basic Usage
Usectx.report_progress()
to send progress updates to the client:
Method Signature
Context Progress Method
Report progress to the client for long-running operations
Progress Patterns
Percentage-Based Progress
Report progress as a percentage (0-100):Absolute Progress
Report progress with absolute values:Indeterminate Progress
Report progress without a known total for operations where the endpoint is unknown:Multi-Stage Operations
Break complex operations into stages with progress for each:Client Requirements
Progress reporting requires clients to support progress handling:- Clients must send a
progressToken
in the initial request to receive progress updates - If no progress token is provided, progress calls will have no effect (they won’t error)
- See Client Progress for details on implementing client-side progress handling