Skip to content

Take the bundle one way per server: a path locally, an upload on the hosted one - #245

Closed
raymondk wants to merge 31 commits into
deploy-5-hostedfrom
deploy-6-bundle-source
Closed

raymondk wants to merge 31 commits into
deploy-5-hostedfrom
deploy-6-bundle-source

Conversation

@raymondk

@raymondk raymondk commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #243 (deploy-5). Each server takes the bundle one way, and bundle_base64 is removed.

Why

icp_deploy_bundle accepted bundle_path, bundle_base64 and bundle_upload on every server, and only bundle_upload was checked against what the server could serve.

  • bundle_path was reachable on the hosted server. Nothing refused it, so a session allowed to deploy could have the server open any regular file its user can read, with errors that tell a missing file from a non-regular one from one that is not a bundle. Found by reading the code, not by running it against a deployment.
  • bundle_base64 had no use. Locally a path is always at hand. On the hosted server the request body cap (4 MiB) held it far below a real bundle, so the call failed with a 413.
  • Three sources cost code. A count of the arguments given, an unreachable match arm, a BundleSource::Upload placeholder the tool overwrote, and prose that switched on has_uploads().

What

  • One argument per server. A server with an upload store (hosted) takes bundle_upload; one without (local) takes bundle_path. request_from_args refuses the other before anything is read, with a message that names the right one.
  • Each server lists the argument it takes. IcDeployTools::tools() drops the other property from the deploy tool's input schema, and lists icp_deploy_upload only where there is a store. WithDeploy lists, looks up and dispatches from that one list, in place of two hand-written predicates.
  • bundle_base64 is gone, with its size bound, its test, and the crate's base64 dependency.
  • BundleSource::Upload is gone. request_from_args returns the bundle argument's value and what makes the request of a bundle, so the upload is still taken only after the rest of the arguments pass: a mistyped mode does not spend a one-time upload.
  • The skill, both READMEs, the server instructions and the tool description say the same.

BundleSource::Bytes stays: the pipeline tests in deploy.rs deploy from it.

Agent-facing changes

  • The local tool no longer accepts bundle_base64. An agent that passes it is told to pass bundle_path.
  • The hosted tool no longer lists or accepts bundle_path.

Review comments on #243 addressed here

Second commit.

  • Not an exception. Core's closing paragraph ("no tool here creates, funds or deploys one") is exported as DEPLOYS_ELSEWHERE; a server with the deploy tools puts the DEPLOYING paragraph in its place.
  • Shorter. The DEPLOYING paragraph is about a third of its length.
  • No CLI identity. The instructions, the icp_cycles_balance description and the skill no longer name https://cli.id.ai, icp identity link or icp identity principal. The principal is "the developer principal of the user's identity". The READMEs and code comments still explain it.
  • No slot count in the instructions. A full server answers "try again in a few minutes".
  • Canister ids as opaque metadata. The skill passes the ids file in and writes the answer back unchanged; it no longer shows the file's shape or asks for a merge.
  • One pointer to the guide. The instructions name icp_deploy_guide only.
  • The expect wording nit in uploads.rs.

Not addressed here: a mitigation for one client holding every deploy slot, and whether the guide should exist as both a skill resource and a tool.

Tests

  • a_server_takes_the_bundle_one_way: each kind of server accepts its argument and refuses the other, alone or beside its own.
  • a_server_lists_the_bundle_argument_it_takes: the listed schema per kind of server.
  • The hosted end-to-end test checks the listed schema, and that a bundle_path is refused, alone or beside a valid upload, without spending the upload.

cargo test --locked --workspace --all-targets and cargo test --locked -p imcp2 --features deploy --all-targets pass; cargo clippy --workspace --all-targets --features deploy and cargo fmt --all --check are clean.

🤖 Generated with Claude Code

raymondk and others added 30 commits November 11, 2026 21:17
…ted input

The first of three changes that bring `icp deploy` to the local MCP
server through the icp CLI's own project library. This one is the
library's `Host` for a bundle — the `.tar.gz` that `icp project bundle`
writes — and nothing yet drives it.

A bundle is handed over by an agent, so the host takes it for exactly
what a bundle is and no more:

- `extract_bundle` unpacks it into a scratch directory under a
  compressed-size limit (256 MiB) and a decompressed-stream limit
  (1 GiB), refusing symlinks and other non-file entries, and anything
  under `.icp/`, the state a deploy seeds itself.
- `BundleFs` is the `FileSystem` the library reads the project through:
  backed by the index of what extraction wrote, so a path is normalized
  against the bundle root (`..` clamped, absolute re-anchored) and looked
  up there. A path the archive did not carry is "not in the bundle",
  whatever exists on disk at that spelling. Writes land only in scratch
  directories the filesystem created.
- `IcMainnet` is the network seam: the `ic` network with the pinned
  mainnet root key, and nothing else.
- `BundledWasm` serves local wasm sources from the index, sha256
  verified; `NoScripts` runs pre-built steps and refuses script ones.
- `check_bundle` validates the whole bundle before a deploy would run:
  one pre-built step per canister naming a wasm in the archive that
  hashes to its checksum, every sync plugin in the archive, no scripts,
  an environment on `ic`.

The crate is `publish = false` by construction: `icp-project` and its
siblings are git dependencies, which crates.io refuses, so this cannot
live in `imcp2-core`. The four icp-cli crates are pinned to one rev.
`icp-sync-plugin` brings wasmtime into the workspace. The manifest
carries the full dependency list so the lockfile lands once; a few deps
(rmcp, base64) are used only by the tools that follow.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…store the crate version

Four review findings on the host:

- The network seam accepted any connected network claiming the mainnet
  root key, so a manifest could point the user's signed calls at an
  endpoint of its choosing. Only the reserved `ic` network is served
  now: that name, the mainnet endpoint and the mainnet root key, which
  is what the loader supplies and refuses to let a manifest redeclare.
- A canister directory spelled absolutely (`/etc`) resolved inside the
  bundle for every reader that goes through `BundleFs`, but the
  sync-plugin runtime takes it as a host path and makes a directory
  outside the project its own sandbox root. `check_bundle` now holds
  each canister directory to the bundle root by spelling.
- The `.icp/` guard at extraction tested the archive path's first
  component, which `./.icp/...` sidesteps. It tests the normalized path.
- The root crate had slipped back to 0.6.0 while the others are at
  0.6.1, which the release guard refuses. Restored, lockfile included.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Four more review findings on the host:

- Directory lookups scanned the whole index per call, which a recursive
  glob over a bundle of many files turned quadratic. A path set orders
  by component, so a directory's descendants sit right after it: `is_dir`
  and `read_dir` now take one range lookup and read while the prefix
  holds. An archive is also capped at 250,000 entries, since the byte
  budget alone admits millions of empty files.
- Canister names that differ only in letter case passed, and the
  library's artifact store keys build output by name on disk, where a
  case-insensitive volume would hand the last-built module to both.
  `check_bundle` refuses them.
- A gzip-compressed module hashed correctly however much it expanded to,
  and the library gunzips it in memory, unbounded, to read its Candid
  interface. `check_bundle` streams it through a bounded decoder first,
  holding it to 100 MiB expanded, the IC's own ceiling on a module.
- The `.icp/` guard at extraction compared case-sensitively, which
  `.ICP/` sidesteps on a case-insensitive disk. Compared without case.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…eate

Two more costs a bundle could run up past the budgets that were there, and
one it still can, named for what it is.

The project loader reads an argument or variable file into every canister
that names it and keeps each copy, so the extraction budget bounded none
of it: fifty canisters naming one file of 100 MiB would hold 5 GiB. The
loader now reads through a metered view of the bundle, charged by file
size before each read, with 256 MiB for everything it loads; the phases
keep reading the bundle itself, where a module is read as often as the
deploy needs it.

The entry cap counted archive records, but `unpack_in` creates the missing
parents of every entry, so a few files at the bottom of long, distinct
directory chains cost inodes the count never saw. Extraction now counts
files and directories alike, charging each directory an entry's path
implies once, read off the index and the directory entries written so far.
Since that walk costs a lookup per component, an entry's path is first
held to Linux's PATH_MAX, past which nothing could be created anyway.

What stays unbounded is a sync plugin's memory: the runner in
icp-sync-plugin bounds compute time and stack and builds its own engine
and store, so a store limiter belongs there. The host's docs say so, so
the gap is not mistaken for a bound.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
The index-backed filesystem went: the confinement it provided is now the
library's own. dfinity/icp-cli#866 (issue #865) adds `files::Confined`,
the host filesystem held to one directory: every path is resolved
against the root before the disk sees it, and one that comes to rest
outside — by climbing, by being absolute elsewhere, or through a symlink
inside pointing out — is refused. The loader resolves every path a
manifest names through the filesystem it is given, so that one seam
holds all of them, canister directories included, which is also why the
spelling check on canister directories went: a directory outside the
root is not found, and the project does not load.

What stays here is what the library cannot know about an archive: the
bounds on its size, its decompressed size, its files and directories
and their paths, the refusal of symlinks, device nodes and `.icp`, the
metered view the loader reads through, and the checks on the bundle's
shape before any phase runs.

The four icp-cli crates are pinned to that branch's head until it is on
main.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…aths to it

The check read, hashed and gunzipped a module once per canister naming
it, and nothing summed the expansions: a manifest of ten thousand
canisters on one gzip module expanding to the 100 MiB limit had it
decompress a terabyte before refusing anything, and ten thousand
kilobyte-sized gzip files did the same without repeating a name. Now
each file is read, hashed and expanded once, by where it lies on disk
(`Verified`), and the expansions are summed under
`MAX_WASM_BYTES_IN_ALL`, the extraction budget again: compressing a
module buys nothing against it.

The check also said nothing about what a sync step declares under
`dirs:` and `files:`. The runtime resolves each against the canister
directory, confined to the project, and reads every `files:` entry into
a string of its own before the plugin runs — so a missing file, or a
path outside the bundle, failed at sync, after the canisters had been
created and paid for, and a 100 MiB file declared a hundred times asked
for 10 GiB. `check_declared` now holds each entry to the runtime's rule
(relative, within the root, present, a directory where `dirs:` says so)
and the files, counted as often as declared, to `MAX_PLUGIN_INPUT_BYTES`
per step. Which of the two settings a plugin's interface accepts stays
the runtime's to tell.

Two regressions for what the move to `Confined` already fixed: the
parents a directory entry implies are counted once, and an empty
directory entry is a directory of the bundle.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
dfinity/icp-cli#868 completes the rule #866 began, split three ways
(#863): the user's own project may link wherever it likes, `icp project
bundle` writes an archive of regular files and directories alone, and a
consumer of a bundle it does not trust refuses any other entry on the
way in. `files::Confined` is accordingly held to the root by the
spelling of each path alone — it no longer canonicalizes the root or
follows symlinks to see where a path comes to rest — and `Confined::new`
is infallible.

This crate is that consumer: extraction already refuses a symlink, a
device node and anything else that is not a regular file or directory,
so the lexical check is complete here. The pin moves to the head of the
stack, the docs say why the extractor's refusal is what the confinement
relies on, and the one call site follows the signature.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…m upstream

The rule for a project someone else handed over now lives in icp-project
(dfinity/icp-cli#871, `icp_project::untrusted`, what the CLI's
`--untrusted` flag applies), so the host composes it as the CLI does
instead of assembling its own from the seams: the project is loaded
through `Confined::refusing_links`, which refuses a path through a
symlink anywhere under the root; no recipe is fetched (`NoRecipes`); and
the loaded project is vetted (`Vetted`) before it is handed out, so a
build step that is not a pre-built module from a file in the project, or
a sync step that is not a plugin from one, fails the load.

With the loader the one gate on the project's shape, the hand-rolled
`NoRecipes`, the `Build` backstop and the script checks in `check_bundle`
go; the builder is the library's own, and the syncer takes a runner that
spawns nothing, since no script step reaches it. Extraction still
refuses a symlink on the way in, and the filesystem now refuses one
again should it appear under the root later.

Pins the four icp-cli crates to the head of #871. Two tests: the load
refuses a script step, a remote module and a recipe, naming each; and
the bundle filesystem refuses a link made after extraction.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…t runs

dfinity/icp-cli#871 has moved its line: between reading and running,
rather than around the project directory. Reading is no longer
restricted — the loader reads argument files, manifests and recipes
from wherever the manifest points, through the ordinary filesystem —
and what runs is held to the list: each build step a pre-built module,
each sync step a plugin, and the file each names within the project,
judged by where it really is once every link is followed and every `..`
applied. `Confined::refusing_links` and `NoRecipes` are gone from
upstream, `Vetted::new` takes the filesystem the paths resolve through,
and `--untrusted` sits on `build`, `deploy` and `sync` rather than on
every command.

The host follows. The bundle is still read through `Confined` — a bundle
has no business outside its own directory, and the vet resolves each
module through the same seam — but the confinement is this crate's
choice now, not the rule's. No recipe is fetched, by this crate's rule
rather than the library's: the CLI would render one and vet the steps
it produces, a bundle has none, so the resolver that refuses them is
back here, naming the recipe. The refusal wording follows upstream: a
step is "not a pre-built module", not "from a file in the project", and
a module linked out of the root is refused for where it resolves, not
for passing through a link.

Pins the four icp-cli crates to the head of #871. The test that read a
link made after extraction as a filesystem refusal now loads a project
through one: a link out fails the load naming where it leads, a link
within is let be, a dangling one is refused. The read-budget test's
archive carries the module its manifest names, as the vet now asks.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
dfinity/icp-cli#871 now asks, after resolving where a module or plugin
really is, whether a regular file is there, since a directory cannot be
read as a module and a pipe is read from whoever writes to it. The vet
asks the filesystem it is given, and a path that does not resolve is now
refused as resolving "to anything" rather than "to a file".

The host follows, and resolves the extraction root once before the
filesystem is held to it. The vet hands the filesystem a resolved path,
and `Confined` holds every path to the root by spelling alone, so a root
named through a link — macOS keeps its temporary directories under
`/var`, a link to `/private/var` — would put every resolved path outside
it and refuse every bundle. `dunce` resolves it, as icp-project's own
host filesystem does, keeping a Windows path free of the `\\?\` prefix.

Pins the four icp-cli crates to the head of #871. Two tests: a directory
of the bundle named as a module fails the load naming what was found,
and a root named through a link is the directory it leads to.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…handle

The pin moves from the #866 -> #871 stack to #873, the same `--untrusted`
feature with `files::Confined` built on cap-std. What changes for the
host:

The confined filesystem opens the root once as a directory handle and
makes every read beneath it, so the operating system refuses a path that
leaves the root; on top of that a path through a symlink is refused
wherever it leads, within the root or without. The vet asks that
filesystem whether what a step names is a regular file, so a module
named through a link now fails the load as not a regular file of the
project, where before one resolving within the root was let be. The
root is matched as spelled, so the extraction directory is no longer
canonicalized and `dunce` goes; a root named through a link holds the
project as it is.

`NoRecipes` is the library's own now, and so is holding a plugin's
`dirs:` and `files:` to the project at the load: this crate's resolver
goes, and its declared-paths check keeps only the byte budget the
runtime's reads are held to. The tests read the new refusals, and the
docs name #873 on #868.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
dfinity/icp-cli#873 is merged (8f98455, on #868's merge e097f7f), as one
squash of the two heads this crate followed. The code is the same as the
head it was pinned at; the merge adds a doc note on `untrusted::vet` and
`Vetted::new` that the filesystem handed in must be the one that confines
the project, which the host's composition already satisfies. The pin
moves to main, and the manifest and docs stop saying it awaits that.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
The second of three changes bringing `icp deploy` to the local MCP
server. On top of the bundle host, this adds what runs a deploy:

- `deploy_bundle(identity, request)`: read the bundle (a regular file by
  absolute path, or bytes), extract it, load the project, check the
  bundle whole before any phase runs, seed the id store from the
  caller's canister-id mapping, then `resolve_targets` and the library's
  `deploy` — the same entry point `icp deploy` uses, so creation, id
  wiring, settings, install/upgrade with the Candid check and the sync
  steps behave as the CLI does. The outcome carries the status, the
  canisters created, the resulting mapping (the id store read back,
  always merged with what was created, so a failed run still reports
  every canister it made) and the event stream rendered as a log.
- `AgentCalls`: the library's `CanisterCalls` over `ic-agent`, modelled
  on icp-app's own implementation minus proxy routing, with certified
  reads via `read_state`. The agent is built by the first phase that
  reaches the network, as the CLI does.

The tests run the real pipeline offline: a hand-built bundle is
extracted, loaded, checked and stopped at the create phase with
`no_create`, exactly where `icp deploy --no-create` stops. A checksum
mismatch, a script step, a managed network or a testnet, a path the
bundle does not hold, an unknown environment or canister, and a bundle
path that is not a regular file are each refused as request errors
before any phase.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
… split comment

Two review findings on the host (#230) are now also covered through the
real pipeline: a manifest that spells a canister's directory as `/etc`,
with the `canister.yaml` the loader looks for carried in the archive at
that spelling, and a manifest that declares a connected network claiming
the mainnet root key over a loopback endpoint. Both are refused before
any phase. The comment above the manifest-path test had been split in
two by an insertion; it is whole again.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Two of the host bounds from #230 through the real pipeline: a
gzip-compressed module that hashes correctly but expands past the module
limit, and two canisters whose names differ only in letter case. Both
refused before any phase.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
… check off the workers

Four more things a request could do to the deploy before any phase ran,
each now refused at the door.

The library resolves the install mode only when it installs, after the
canisters exist, and panics on a spelling it does not know; a typo would
create funded canisters and unwind without reporting them. The mode is
checked against the four the library takes before anything is read.

A bundle file was sized by its path and then read to its end, so a file
replaced or grown in between was read whole. The open file is sized again
and read to the limit plus one byte, which is enough to tell it outgrew
the limit; the path is still checked first, so a pipe is never opened.

The library parses a canister's Candid arguments at install and its
module's `candid:service` interface at the upgrade check, with no depth
guard and on the worker thread, where nesting past the stack aborts the
process. The bundle's arguments and interfaces are held to the bound the
call tools apply to caller-supplied Candid (`guard_candid_text`, now
public in imcp2-core) in check_bundle, and the interface the deployed
canister answers with is held to it in the calls adapter, so neither
side of the comparison can be deeper than the parser can take.

check_bundle reads, hashes and gunzips every module, up to a gigabyte of
them, so like extraction it now runs off the runtime's workers.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
A canister directory outside the root is now something the loader does
not find, and a variable file outside it is refused by the filesystem as
outside, so the two tests read those messages rather than the host's
old ones. A wasm outside the root is refused earlier still, by the
untrusted rule's vet at the load: it asks the bundle's filesystem where
the module really is, and nothing outside the root resolves through it,
so the test reads that.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
The untrusted rule now holds at the load, naming the step it refuses, so
the test reads that refusal, and the preflight comment no longer counts a
script step among what the check catches.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
… workers

What a certificate proves about a metadata section is decided in one
function over the tree alone, so each branch is read from a fixture with
no network: a section the tree holds, a canister proven to exist without
it (no module, or a module without that section), a canister proven
absent, a pruned section and a pruned controllers entry, which each prove
nothing and are reported as such rather than guessed at.

The project load reads the manifest and every file a canister names with
the filesystem's own blocking reads, up to the metered budget, and ran on
the runtime's worker that took the call; it now runs on a blocking thread
as extraction and the bundle check already do, and the lazy loader keeps
what it loaded for every ask after.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
The last of three changes bringing `icp deploy` to the local MCP server:
the tools over the bundle host and the deploy pipeline, and their wiring.

- `icp_deploy_bundle` takes a bundle (by absolute path, or inline as
  base64 bounded on its length before decoding), the environment name,
  and optionally the canister-id mapping an earlier deploy returned;
  it answers with the status, the mapping to pass back next time, the
  canisters created and a per-phase log, as structured content under a
  declared output schema. It needs a session granted "Actions &
  questions", checked before the bundle is decoded.
- Calls are signed as the user's CLI identity: their default Internet
  Identity account at `https://cli.id.ai`, the origin `icp identity
  link web` signs in at, so canisters created here are the ones `icp`
  lists and controls, funded from the same cycles balance. It is not the
  management identity the canister lifecycle tools act as; the docs say
  so. A per-app delegation lives five minutes and a deploy can run
  longer, so the agent signs through `RefreshingIdentity`, which swaps
  in a fresh delegation from the session store every ten seconds, for
  the same principal, until the deploy ends.
- `icp_cycles_balance` reports that principal and its cycles-ledger
  balance, the check a deploy that will create canisters starts with.
  Core's tool of that name sits in the protocol half the local server
  does not serve; this is the same logic on the served surface.
  `cycles_balance_of` is split out of core's `cycles_balance` and
  `Identities::agent_as` made public for it.
- The local server composes the deploy router next to the login tools,
  serves the `skill://deploy-with-mcp` skill (bundle, deploy, write the
  mapping back into `.icp/data/mappings/<environment>.ids.json`) ahead
  of core's bundled skills, and adds a DEPLOYING paragraph to its
  instructions. README and the crate docs describe the tool, the
  identity it acts as and the `ic`-only rule.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…t past a cut-off

What the review found around the tools rather than in the pipeline, each
taken as it was raised.

A deploy signs as the account the first derivation resolved the session's
default to, and asks for that account by number from then on (core's
delegated_identity_resolved reports it): the default is the user's to
change, and a refresh that came back as another principal would have been
refused until the delegation in hand expired. When the store reports the
grant over — II's one terminal answer, RECONNECT_MSG, now public — the
identity stops signing at once instead of riding out that delegation.

Two deploys at once for one project, each with the mapping as it was
before either, would create two sets of canisters: a server runs one at a
time, and refuses rather than queues a second, since its mapping would be
stale by the time it ran. And a deploy's working directory is kept under
the OS's local data directory until the outcome is assembled, so a call
cut off mid-deploy leaves `.icp/data/mappings/<env>.ids.json` with every
canister it created where the README and the skill say to look.

The balance check reads the Internet Computer through the same mainnet
agent a deploy uses, whatever endpoint the rest of the server is pointed
at. `bundle_path` is trimmed and must be absolute before any I/O, and an
unparsable id is reported as what it is, not a valid principal. The deploy
skill joins the first page of resources alone.

The identity the tools act as is described as what it is: the default II
account at cli.id.ai, which `icp identity link web` links the CLI to —
the CLI's own principal only when its selected identity is that link.
The README, the skill, the server instructions and the module docs say
so, and point at `icp identity principal` for the comparison.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
A deploy cut off mid-run leaves the ids it created in its working
directory, under the local data directory the README points at. With
none reported by the OS the server fell back to the system temporary
directory in silence, where a cleanup may remove the record before the
user looks; it now fails at startup, naming what to set.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…esources

The skill around `icp_deploy_bundle` was served as the MCP resource
`skill://deploy-with-mcp` alone, and not every client reads resources
(review on #232). `icp_deploy_guide` returns the same document as a tool
result, text and structured content, as core serves its Candid guide both
ways. The server's instructions and README say so, and the round-trip
test calls it.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Every deploy runs in a fresh, randomly named directory under the user's
local data directory (or the system temporary directory), and nothing
reads it but that run. Its mode followed the umask, though, so another
user of the machine could read what the bundle holds and the ids the
deploy records wherever the parent allowed it. On Unix the directory is
now made with mode 0700. A test creates two and checks that they differ,
sit under the parent, and are the owner's alone (review on #232).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…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 <[email protected]>
… on a ticket

The hosted server could not deploy: the tool lived in the local binary
alone. Now, behind the gateway crate's `deploy` feature, the MCP endpoint
serves imcp2-deploy's tools beside the core surface, through the one
handler both servers mount (`WithDeploy`, moved out of imcp2-local).

Three things the hosted shape needs that the local one did not:

How the bundle arrives. The agent's machine cannot hand this server a
file, and a tool call carries only what the model writes, so
`icp_deploy_upload` mints a one-time ticket inside the authenticated
call and returns the curl command that PUTs the archive to
`{mcp_path}/deploy/upload`. The ticket is 256 random bits, single use,
good for five minutes, bound to the session that minted it (the upload
it produces is deployable by that session alone), and sent in a header
so it stays out of proxy logs. The route is outside the bearer gate (the
ticket is its authentication) and streams the body to disk under a cap,
a declared length over it refused unread. `icp_deploy_bundle` takes the
upload id as `bundle_upload`; the archive goes with the deploy.

How the deploy call is answered. The endpoint answers a POST with plain
JSON, the one message a handler returns, and a deploy reports each phase
before its result. A `tools/call` of `icp_deploy_bundle` is therefore
dispatched to a second rmcp service configured for Server-Sent-Events
responses, still stateless; every other request keeps the JSON service.

A client that goes away. The event stream's body is wrapped so that its
drop cancels a token the deploy watches (`ClientGone`), and the deploy
stops at its next step, keeping its directory as the record.

Also: one deploy per session plus a server-wide cap (`concurrent`,
default 2 hosted, 1 local), refused past it rather than queued; deploy
directories and uploads under `{state_dir}/deploys`; the knobs
`MCP_DEPLOY_MAX_CONCURRENT` and `MCP_DEPLOY_MAX_UPLOAD_BYTES`; the native
build turns the feature on and CI tests it. The feature keeps `cargo
publish` of imcp2 from working until the icp CLI's crates are published.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…server starts

A server started with a relative state directory (IMCP2_STATE_DIR=state,
or the default working directory) wrote uploaded bundles under a relative
path, and the deploy that read one refused it: the bundle reader takes an
absolute path only. The deploy directory and the upload store now make
their directory when they are built and canonicalize it, so every path a
deploy works with is absolute, and one named through a link is spelled as
it is on disk; the hosted binary resolves IMCP2_STATE_DIR once at startup
for the same reason.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…ession

The deploy's phases reached the client as progress notifications and
nothing else: an operator reading the server's log saw no trace of a
deploy, its outcome, or the upload it consumed. The deploy tool now runs
each deploy in a `deploy` span carrying the session id; inside it the
deploy logs the directory it works in, every event line as it is made
(the collector is a task of its own, so the span is carried to it on
purpose), and how it ended, with the error when it did not finish. The
upload store logs tickets minted, archives received or refused, and
uploads taken by a deploy. All at `info`, the default level.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…hosted one

icp_deploy_bundle accepted bundle_path, bundle_base64 and bundle_upload on
every server, whichever of them the server could serve. Nothing refused
bundle_path on the hosted server, so a session allowed to deploy could have
it open any regular file its user can read, and learn from the error whether
the file exists, what it is and how large.

A server now takes one bundle argument, decided by whether it has an upload
store: bundle_upload with one, bundle_path without. The other is refused
before anything is read, and each server lists only the argument it takes.

bundle_base64 is gone. Locally a path is always at hand; on the hosted
server the request body cap held an inline bundle far below the size of a
real one.

With one argument per server the count of arguments given, the
BundleSource::Upload placeholder and the split of request_from_args go.
The upload is still taken only after the rest of the arguments pass.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
… or the slot count

From the review of #243.

The instructions no longer call the deploy tool an exception: where core's
closing paragraph says nothing here deploys (now the exported
DEPLOYS_ELSEWHERE), a server with the deploy tools puts the paragraph on how
deploying works. That paragraph is about a third of its length.

What an agent reads (the instructions, the description of
icp_cycles_balance, the skill) no longer names https://cli.id.ai or the icp
CLI's identity commands: the principal is the developer principal of the
user's identity, where cycles are sent and what is added as a controller.

How many deploys a server runs at once is no longer in the instructions. A
server that is full says to try again in a few minutes.

The canister ids are passed in and written back unchanged, as the app's
development metadata: the skill no longer shows the file's shape or asks for
a merge, since what the tool returns holds every id passed in.

The instructions point at icp_deploy_guide alone, not at it and the skill
resource.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
icp-project, icp-events, icp-sync-plugin and icp-canister-interfaces are
published, so imcp2-deploy depends on their 0.1 release instead of a pinned
commit of the icp-cli repository. Nothing in the crate's code changes.

The notes that gave the git pin as the reason imcp2-deploy cannot be
published now say what is still true: the crate is not published, and the
published imcp2 cannot carry the `deploy` feature until it is.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@raymondk
raymondk marked this pull request as ready for review November 18, 2026 01:23
@raymondk
raymondk requested a review from a team as a code owner November 18, 2026 01:23
Copilot AI max review requested due to automatic review settings November 18, 2026 01:23
@raymondk
raymondk added this pull request to stack #233 November 18, 2026 01:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Requests containing the removed bundle_base64 argument alongside a supported source can silently deploy unintended contents and consume hosted uploads instead of being rejected.

2 open issues
What changed in this PR

Restricts deployment bundles to local paths on the local server and ticketed uploads on the hosted server, preventing hosted callers from supplying filesystem paths.

Changes:

  • Enforce and advertise one bundle source per server, removing bundle_base64 and the upload placeholder.
  • Centralize tool selection, simplify deployment guidance, and add server-specific regression checks.
  • Move four icp-cli dependencies from a git pin to crates.io 0.1 releases.
File Description
src/​deploy.rs Test hosted schemas and path rejection without consuming uploads.
README.md Document upload-only hosted deployment and publishing constraints.
crates/​imcp2-local/​src/​server.rs Assert that composed instructions teach local deployment correctly.
crates/​imcp2-local/​src/​main.rs Remove an outdated git-dependency limitation from module docs.
crates/​imcp2-local/​README.md Document path-only bundles and the deploy crate’s purpose.
crates/​imcp2-local/​Cargo.toml Clarify deploy-crate separation in dependency comments.
crates/​imcp2-deploy/​static/​skills/​deploy-with-mcp.md Update bundle transport and canister IDs-file guidance.
crates/​imcp2-deploy/​src/​uploads.rs Adjust random-source panic wording.
crates/​imcp2-deploy/​src/​server.rs Share tool selection across listing and dispatch; replace deployment instructions.
crates/​imcp2-deploy/​src/​lib.rs Validate per-server bundle inputs, tailor schemas, and update tests.
crates/​imcp2-deploy/​src/​host.rs Update the dependency-version note in host documentation.
crates/​imcp2-deploy/​src/​deploy.rs Remove the unresolved-upload bundle variant.
crates/​imcp2-deploy/​Cargo.toml Drop base64 and use registry icp-cli dependencies.
crates/​imcp2-core/​src/​tools.rs Extract the reusable no-deployment instruction paragraph.
crates/​imcp2-core/​src/​lib.rs Re-export DEPLOYS_ELSEWHERE for server composition.
Cargo.toml Update hosted-feature publishing comments.
Cargo.lock Lock registry icp-cli releases and refresh transitive dependencies.

Review effort: Max

args: DeployBundleArgs,
uploads: bool,
) -> Result<(String, impl FnOnce(BundleSource) -> DeployRequest), String> {
let bundle = match (args.bundle_path, args.bundle_upload, uploads) {
Comment on lines +513 to +517
if let Some(properties) =
schema.get_mut("properties").and_then(|p| p.as_object_mut())
{
properties.remove(refused);
}
@raymondk

Copy link
Copy Markdown
Contributor Author

Closing: folded into the re-cut stack, so that each PR shows its files in their final form. One bundle source per server, the removal of bundle_base64 and the shorter instructions are in #232; the hosted server refusing bundle_path is in #243; the icp CLI crates from crates.io are in #230. The tree at the top of the stack (#243) is the tree this PR had, rebased onto main.

@raymondk raymondk closed this Nov 18, 2026
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.

2 participants