Skip to content

Add progress notification support to async tool execution#71

Merged
jancurn merged 1 commit intomainfrom
claude/add-async-progress-message-aLHK9
Mar 13, 2026
Merged

Add progress notification support to async tool execution#71
jancurn merged 1 commit intomainfrom
claude/add-async-progress-message-aLHK9

Conversation

@jancurn
Copy link
Member

@jancurn jancurn commented Mar 13, 2026

Summary

This PR adds support for progress notifications during async tool execution, allowing tools to report progress updates (progress value, total, and messages) that are displayed in the CLI spinner alongside elapsed time and status messages.

Key Changes

  • MCP Client (src/core/mcp-client.ts)

    • Added tracking of current task ID and status to enable progress callback handling
    • Implemented onprogress callback handler that converts progress notifications into TaskUpdate objects with progress metadata
    • Pass onprogress handler to the callToolStream request options when onUpdate callback is provided
    • Update currentTaskId and currentStatus when task creation and status messages are received
  • CLI Tools Command (src/cli/commands/tools.ts)

    • Added lastProgressMessage tracking separate from lastStatusMessage
    • Updated spinner text formatting to prioritize progress messages over status messages
    • Extract and display progressMessage from task updates in the spinner
  • Type Definitions (src/lib/types.ts)

    • Extended TaskUpdate interface with three new optional fields:
      • progressMessage: Message from progress notifications
      • progress: Current progress value
      • progressTotal: Total progress value for percentage calculations
  • Documentation (CHANGELOG.md)

    • Updated feature description to mention progress notification messages are now displayed in the spinner

Implementation Details

The progress notification flow works by:

  1. Capturing progress events from the tool stream via the onprogress callback
  2. Converting progress data into TaskUpdate objects that include progress metadata
  3. Passing these updates through the existing onUpdate callback mechanism
  4. Displaying progress messages in the CLI spinner with proper formatting priority (progress messages take precedence over status messages)

https://claude.ai/code/session_013XT1MvJMo5zMkg9koyBLqr

The --async flag spinner now shows messages from MCP progress
notifications (notifications/progress) in addition to task status
messages. This uses the SDK's onprogress callback to capture the
message field from progress notifications and display it in the
spinner alongside elapsed time.

https://claude.ai/code/session_013XT1MvJMo5zMkg9koyBLqr
@jancurn jancurn merged commit 14fb607 into main Mar 13, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants