- Start the shipment-tracker server used in this lesson:
PL-4417:
- Simple requests may complete instantly, but many useful server tasks involve multiple steps or take significant time. In these cases it’s helpful for the server to notify the client about progress (e.g., “started lookup”, “processing records”, “finished”).
- MCP servers can send server-to-client notifications using the server context object (
ctx) and itsreport_progressmethod.
ctx.report_progress twice to indicate two steps: lookup started and lookup completed.
- Call:
await ctx.report_progress(progress, total=..., message="..."). - Each call sends a server-to-client notification containing:
progress— current progress value (you determine semantics: step index, percent, etc.).total— total number of steps or maximum progress value.message— a human-readable description of what’s happening.
- In the example above, we used
1and2to express “first of two steps” and “second of two steps”.
Registering a progress token in mcp.json
- To allow clients to correlate progress notifications with the right server, include a
progressTokenin your server entry withinmcp.json. This metadata token is attached to the server configuration and the client will see it in notifications.
mcp.json entry:
- When the client spawns or connects to the configured server, progress notifications will include the token so the client can match notifications to the correct server/tool invocation.
- The server sends asynchronous
server-to-clientprogress notifications while the client initiates thetool/call. - Progress notifications and the final tool response are independent messages; use
progressTokento associate them with the correct server invocation. - You control the meaning of
progressandtotal(step indexes, percentage, or custom semantics).
The server can only send notifications to the client (e.g., progress updates). The client is the only entity that can initiate tool calls. Use
metadata.progressToken in mcp.json so the client can correlate server notifications with the corresponding server instance.- MCP Protocol Overview (replace with your MCP docs)
- MCP Server API — report_progress
- Python async patterns