Skip to content

Report each deploy phase as it completes, and stop the deploy when the call is cancelled - #242

Draft
raymondk wants to merge 1 commit into
deploy-3-mcp-toolsfrom
deploy-4-streaming
Draft

raymondk wants to merge 1 commit into
deploy-3-mcp-toolsfrom
deploy-4-streaming

Conversation

@raymondk

Copy link
Copy Markdown

Stacked on #232 (deploy-3). Fourth step of the deploy stack, and the first of the work that brings the deploy tool to the hosted server: the call shape both servers will share.

What

icp_deploy_bundle stays one blocking call, but now reports each phase as it completes and stops when the call is cancelled.

Why

A deploy lasts from seconds to minutes (canister creation, installs, a frontend's asset sync) and the call said nothing until it ended. On the hosted server a silent minutes-long call is also what trips a client's per-call timeout. Progress notifications fix both: the client sees each phase, and the MCP SDK clients reset their timeout on every progress notification.

How

  • deploy::Watch is handed to deploy_bundle: a stop token and an optional lines sender. collect_log sends each log line the moment it is made, so the outcome's log and the streamed lines are the same lines in the same order (test: the_log_is_streamed_as_it_is_made).
  • The run is raced against stop with a biased select!: cancelling drops the run at its next await, which is the next canister call or plugin step. A canister call already in flight completes on the network. The outcome reports a new status, interrupted, with every canister created before the stop in created and canister_ids, like a failure does. The tool returns it as an error result, like a failure.
  • An interrupted deploy keeps its working directory (test: an_interrupted_deploy_stops_and_keeps_its_directory): whoever asked for the stop may be a client that went away and will never read the answer, so the directory's mapping file stays as the record, as it does for a run that is cut off.
  • The tool forwards each line to the client mid-call: as a progress notification when the request carried a progress token, else as a logging message. MCP logging is deprecated (SEP-2577) and rmcp marks it so; it is used only as the fallback, under #[allow(deprecated)] with the reason. The local server declares the logging capability so a client expects it.
  • stop is the request context's cancellation token, which rmcp cancels on the client's notifications/cancelled. The hosted server will add the connection going away as a second source in a later PR.
  • Skill, tool description, server instructions and README say the call lasts as long as the deploy, to send a progress token, and what cancelling does.

Not here: the hosted composition, the bundle upload, concurrency across sessions. Those are the next PRs on this stack.

🤖 Generated with Claude Code

…e call is cancelled

A deploy lasts from seconds to minutes, and until now the call said
nothing until it ended. The pipeline now hands each log line to a
watcher the moment it is made, and the tool delivers it to the client
mid-call: as a progress notification when the request carried a
progress token (which is also what keeps a client's per-call timeout
from running out), else as a logging message. The local server declares
the logging capability so a client expects the latter.

The same watch carries a stop: cancelling the request drops the run at
its next step (a canister call already in flight completes on the
network), and the outcome reports `interrupted` with every canister the
run had created, like a failure does. An interrupted deploy keeps its
working directory, since whoever asked for the stop may be a client that
went away and will never read the answer; the directory's mapping file
remains the record, as for a run that is cut off.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant