How do you report progress during a long-running MCP tool operation?
MCP Advanced: Logging, Progress Notifications, Context Methods for Long Tasks
Audio flashcard · 0:30Nortren·
How do you report progress during a long-running MCP tool operation?
0:30
You report progress by calling the report_progress method on the Context object with two arguments: the current progress value and the total value. For example, await context.report_progress with arguments 20 and 100 means 20 percent complete. You call this method at key checkpoints in your tool function, such as after fetching data and before generating a report. The client receives these values and can display them as a progress bar, percentage, or any other visual indicator. Both values are numbers, and the total can be None if the total is unknown.
github.com