Skip to content

Serve production II at /mcp; drop /mcp-prod; add opt-in /mcp-beta for staging - #92

Merged
aterga merged 3 commits into
mainfrom
claude/prod-mcp-endpoint
Jul 28, 2026
Merged

aterga merged 3 commits into
mainfrom
claude/prod-mcp-endpoint

Conversation

@aterga

@aterga aterga commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

We now run separate production and staging deployments, each serving a single /mcp endpoint. Previously the binary hardcoded two mounts on every deployment: /mcp (beta II) and /mcp-prod (production II). This makes /mcp the production Internet Identity (id.ai) endpoint everywhere, removes /mcp-prod, and adds an opt-in /mcp-beta (beta II) that only the staging deployment turns on.

  • Production (mcp.internetcomputer.org): serves /mcp against production II. /mcp-prod is gone.
  • Staging: serves the same /mcp (production II) plus /mcp-beta (beta II), enabled with MCP_SERVE_BETA.

Related issues

No GitHub issue open; requested directly.

Changes

  • src/main.rs: /mcp now uses IiInstance::prod() (production II, id.ai) and is the origin's default instance (owns the plain-root discovery documents). /mcp-prod removed. A second instance, beta II at /mcp-beta, is composed only when MCP_SERVE_BETA is truthy (1/true/yes/on); off by default so production serves /mcp alone. Router composition, auth_callbacks_router, the startup log line, and graceful-shutdown all handle the optional beta instance.
  • /version: reports the production gauge always and the beta gauge only when the staging instance is served (zero otherwise); keys are now prod/beta.
  • src/assets/index.html: the landing page lists /mcp as Production Internet Identity (dropped the /mcp-prod row); the connector URL is now https://mcp.internetcomputer.org/mcp.
  • README.md: the Run/Auth sections describe /mcp as production II; the former "Production instance (/mcp-prod)" section is now "Staging: beta instance (/mcp-beta)", documenting the MCP_SERVE_BETA opt-in and its II_URL/II_CANISTER_ID config. /mcp config is II_URL_PROD/II_CANISTER_ID_PROD (default id.ai).
  • tests/routers.rs: the composed test app now mirrors the staging shape (prod default at /mcp, beta at /mcp-beta); all assertions updated.
  • src/lib.rs, src/identities.rs, src/auth.rs: doc comments and test fixtures that referenced /mcp-prod updated to the new wiring.

Notes

  • "Hardcode id.ai": /mcp uses IiInstance::prod(), whose default is https://id.ai (canister rdmx6-jaaaa-aaaaa-aaadq-cai). The II_URL_PROD/II_CANISTER_ID_PROD overrides are retained for testing but default to production; no env is needed for prod. Say the word if you want a literal, non-overridable constant instead.
  • The stale "/mcp-prod only completes once production II carries the #4086 MCP feature set" caveat was removed, since /mcp is now the primary production endpoint.

Testing

  • cargo build --locked --all-targets (via the test build)
  • cargo test --locked --all-targets — 136 lib + 7 router + 1 doctest passing
  • cargo fmt --all / cargo clippy --all-targets — clippy is clean (no new warnings); cargo fmt --check reports pre-existing repo-wide deviations across untouched files (a rustfmt-toolchain mismatch), so I did not reformat the tree
  • npm test --prefix monitoring/mcp-status — not applicable (monitoring probes /mcp generically; no dashboard change)

Checklist

  • I have read the Contributing guidelines.
  • Docs (README / comments) updated for any user-visible change.
  • No secrets, credentials, or internal-only information are included.

Generated by Claude Code

… staging

The deployment now has separate production and staging environments, each
serving a single /mcp endpoint. Previously the binary hardcoded two mounts on
every deployment: /mcp (beta II) and /mcp-prod (production II).

- /mcp now serves PRODUCTION Internet Identity (id.ai) on every deployment
  (IiInstance::prod, II_URL_PROD/II_CANISTER_ID_PROD, default id.ai). It is the
  origin's default instance and owns the plain-root discovery documents.
- /mcp-prod is removed entirely.
- /mcp-beta serves beta II, opt-in via MCP_SERVE_BETA (off by default), so the
  staging deployment can offer beta while production serves /mcp alone.

/version reports the production gauge always and the beta gauge only when the
staging instance is served (zero otherwise). The landing page and design doc
now describe /mcp as production; the staging beta endpoint is documented as
opt-in. Router-level tests updated to the new shape (prod default at /mcp, beta
at /mcp-beta). cargo test: 136 lib + 7 router + 1 doctest passing.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_014T9N8USDfNK5yzznPGg7Ym

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.

Pull request overview

This PR updates the deployment routing model so /mcp is always the production Internet Identity-backed MCP endpoint, removes the legacy /mcp-prod mount, and introduces an opt-in staging-only /mcp-beta mount controlled by MCP_SERVE_BETA.

Changes:

  • Switch /mcp to IiInstance::prod() (production II) and make it the default instance that owns the plain-root discovery documents.
  • Remove /mcp-prod and add optional /mcp-beta (beta II) behind MCP_SERVE_BETA, including correct router composition, logging, shutdown, and /version gauges.
  • Update docs, landing page, and tests to reflect the new mount structure.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/main.rs Makes /mcp serve production II by default; conditionally adds /mcp-beta; updates /version, logging, and shutdown for optional beta.
tests/routers.rs Reshapes the composed test app to mirror staging (prod at /mcp, beta at /mcp-beta) and updates route assertions accordingly.
src/lib.rs Updates library docs describing multi-instance composition with /mcp + /mcp-beta.
src/identities.rs Updates comments to reflect beta being served at /mcp-beta (staging) and prod at /mcp.
src/auth.rs Updates test fixtures/strings referencing the removed /mcp-prod mount.
src/assets/index.html Updates the landing page endpoint list and connector URL to point to /mcp as production.
README.md Updates run/auth documentation to describe /mcp as production and /mcp-beta as staging-only via MCP_SERVE_BETA.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/routers.rs Resolved
Resolve two conflicts from main's landing-page redesign (#78/#79) and the
INDEX_HTML const change:

- src/main.rs: keep `let mut app` (needed for the conditional /mcp-beta mount)
  and take main's `Html(INDEX_HTML)` (INDEX_HTML is now a &str const, not a
  LazyLock<String>).
- src/assets/index.html: take main's exported design bundle, then re-apply this
  branch's endpoint change within it — the production connector URL becomes
  https://mcp.internetcomputer.org/mcp (5 occurrences; /mcp-prod is removed by
  this branch and must not be advertised), and the beta-testing hint becomes
  https://mcp.beta.id.ai/mcp-beta.

cargo test: 139 lib + 7 router + 1 doctest passing.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_014T9N8USDfNK5yzznPGg7Ym
@aterga
aterga marked this pull request as ready for review July 28, 2026 16:05
@aterga
aterga requested a review from a team as a code owner July 28, 2026 16:05
Copilot AI review requested due to automatic review settings July 28, 2026 16:05
The auth-challenge block now probes the `/mcp-beta` mount, but its assertion
failure message still read "prod challenge", which would misdirect diagnosis of
a routing failure. Changed it to "beta challenge". Test-only, no behavior change.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_014T9N8USDfNK5yzznPGg7Ym

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.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (2)

tests/routers.rs:198

  • The assertion failure message still says "prod challenge" even though this block is testing the /mcp-beta (beta) mount. This will be misleading when the test fails.
        "beta challenge: {challenge}"

src/identities.rs:64

  • This comment ties the beta Internet Identity defaults to a specific mount path (/mcp-beta). IiInstance::beta() is used by the library regardless of which path the caller mounts it at, so the path-specific wording is misleading.
/// connect-time `/mcp-beta` (staging) handshake (browser). Override with `II_URL`.

Copilot AI review requested due to automatic review settings July 28, 2026 16:09

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.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (2)

README.md:707

  • This section explains that /mcp uses production Internet Identity (id.ai), but it doesn’t mention that users must enable the deployment origin as a trusted MCP server in their id.ai settings (analogous to the beta.id.ai note below for staging). Without that, first-time users may fail to connect despite correct II_URL_PROD/II_CANISTER_ID_PROD config.
Set the public base URL (used in the discovery docs, as the MCP origin, and as the
management identity's derivation origin) with `PUBLIC_URL`. The `/mcp` endpoint is
**production** Internet Identity: `II_URL_PROD` (browser login, default
`https://id.ai`) plus `II_CANISTER_ID_PROD` (the canister the `mcp_*` calls target,
default `rdmx6-jaaaa-aaaaa-aaadq-cai`); both point at the same II.

src/identities.rs:65

  • This comment ties II_URL_DEFAULT to a specific mount path (/mcp-beta), but this is a library-level constant used for the beta Internet Identity instance regardless of where a consumer mounts it. Making it path-agnostic avoids misleading downstream users.
/// Internet Identity instance, single source of truth. Default: **`beta.id.ai`**.
/// A real domain is required: the raw `<canister>.icp0.io` origin is rate-limited
/// (HTTP 429) for the browser login SPA, leaving the II popup blank. Used for the
/// connect-time `/mcp-beta` (staging) handshake (browser). Override with `II_URL`.
const II_URL_DEFAULT: &str = "https://beta.id.ai";

@aterga
aterga merged commit 79ef0c7 into main Jul 28, 2026
2 checks passed
aterga pushed a commit that referenced this pull request Jul 28, 2026
…aging beta

#92 merged into main after this branch was last rebased: it made /mcp the
production Internet Identity endpoint, removed /mcp-prod, and added an opt-in
/mcp-beta (beta II) for staging. The rebase brought main's new wording in
cleanly, but this branch's own landing-page sentence still described the old
model ("/mcp on beta II, /mcp-prod on production II"). Updated it to name the
production /mcp endpoint and note staging's /mcp-beta. No /mcp-prod references
remain in the README.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_014T9N8USDfNK5yzznPGg7Ym
aterga pushed a commit that referenced this pull request Jul 28, 2026
Copilot caught a real break I missed: I updated the terminal renderer but not
the hosted web UI. public/index.html read `targets.iiOrigin` and
`facts.ii.canisterId`, so on the page Caddy actually serves at /status/ — the
one this whole change exists to fix — the header would have read
"II: (unresolved)" even with both instances discovered, and the canister line
would have vanished.

Rather than keep a back-compat single-instance shape alongside the new one,
update the consumers. Both live in this repo and ship with the server, so there
is no external reader to be compatible with, and a singular `iiOrigin` sitting
next to `iiOrigins` reintroduces exactly the failure this PR removes: a
consumer reads the singular field and silently reports one of N instances.

- public/index.html renders every advertised II with its name and canister id.
- facts.ii is renamed facts.iiInstances. The old key held ONE instance's facts,
  so anything still reaching for `facts.ii.canisterId` would read undefined
  against the new map; an absent key makes that a visible break rather than a
  quiet wrong answer.
- report.test.js's evilReport now carries `iiOrigins`. That test had gone
  vacuous: it pins CWE-150 terminal-injection sanitising on a field the
  renderer no longer reads, so it passed while asserting nothing. Confirmed the
  coverage is real again by mutation — deleting the clean() call on the
  iiOrigins path fails both report tests, restoring it passes.

Also drop the stale "/mcp → beta, /mcp-prod → production" examples from two
comments I wrote before rebasing onto #92. /mcp-prod no longer exists; the repo
now has no reference to it at all.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01R8ZshwKmjD5fZ4Hs9dS6zh
aterga added a commit that referenced this pull request Jul 28, 2026
…tname (#94)

* Read the II pairing from /version instead of guessing it from the hostname

The production dashboard reported "II /mcp connect page served: FAIL — GET
https://internetcomputer.org/mcp → 404". Production was healthy; the check was
probing the wrong host.

The dashboard derived the Internet Identity origin by stripping the leading
`mcp.` label off the MCP host. That encodes an assumption which only holds when
the MCP server is a subdomain of its II: it maps mcp.beta.id.ai to beta.id.ai
correctly, but maps mcp.internetcomputer.org to internetcomputer.org — the
marketing site, which legitimately 404s on /mcp. A red II section on a healthy
deployment is worse than no check, because it trains operators to ignore it.

Fixing the value alone would have relocated the bug: one origin cannot describe
a server that mounts more than one II, so whichever mount the hostname guess
did not name went unmonitored everywhere, silently.

So the server now advertises the pairing and the dashboard reads it:

- GET /version gains an `instances` array — one entry per SERVED mount, with
  its name, mcp_path, ii_origin and ii_canister. Built from the live
  McpServer handles, so it tracks $MCP_SERVE_BETA and honours II_URL /
  II_URL_PROD overrides rather than restating defaults a monitor could drift
  from. McpServer::instance() exposes what it is built with.
- The dashboard reads that array and runs the II-health section once per
  instance, ids and section titles suffixed per instance name. deriveIiOrigin
  is gone; no hostname arithmetic remains.
- Advertised origins are still validated against the probe allowlist before
  anything is fetched — they arrive in a remote response, and a misconfigured
  or compromised server must not be able to steer these probes at a third
  party. A rejected entry is reported as a warn rather than dropped, so the
  section never reads as fully monitored while covering less.
- A build with no instances[] (or an unreachable /version) now fails with
  "cannot determine the pairing" instead of confidently probing a guess.
  --ii / II_ORIGIN pins an origin for that case.

deploy.sh pinned the dashboard's allowlist to the PARENT domain, because the
derived II origin was a sibling host. On mcp.internetcomputer.org that quietly
allowlisted all of internetcomputer.org. The II origins are now covered by the
built-in id.ai suffixes, so it pins the deployment's own host instead.

Verified end to end, not just by unit test: run against a local server with
MCP_SERVE_BETA=1, the dashboard discovers both mounts and passes every check
against the real id.ai and beta.id.ai; against live production (still running
80b8586, which predates instances[]) it now reports "advertises no II
instances" instead of a false II outage, and --ii https://id.ai makes it pass.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01R8ZshwKmjD5fZ4Hs9dS6zh

* Update the web UI and report tests for the per-instance report shape

Copilot caught a real break I missed: I updated the terminal renderer but not
the hosted web UI. public/index.html read `targets.iiOrigin` and
`facts.ii.canisterId`, so on the page Caddy actually serves at /status/ — the
one this whole change exists to fix — the header would have read
"II: (unresolved)" even with both instances discovered, and the canister line
would have vanished.

Rather than keep a back-compat single-instance shape alongside the new one,
update the consumers. Both live in this repo and ship with the server, so there
is no external reader to be compatible with, and a singular `iiOrigin` sitting
next to `iiOrigins` reintroduces exactly the failure this PR removes: a
consumer reads the singular field and silently reports one of N instances.

- public/index.html renders every advertised II with its name and canister id.
- facts.ii is renamed facts.iiInstances. The old key held ONE instance's facts,
  so anything still reaching for `facts.ii.canisterId` would read undefined
  against the new map; an absent key makes that a visible break rather than a
  quiet wrong answer.
- report.test.js's evilReport now carries `iiOrigins`. That test had gone
  vacuous: it pins CWE-150 terminal-injection sanitising on a field the
  renderer no longer reads, so it passed while asserting nothing. Confirmed the
  coverage is real again by mutation — deleting the clean() call on the
  iiOrigins path fails both report tests, restoring it passes.

Also drop the stale "/mcp → beta, /mcp-prod → production" examples from two
comments I wrote before rebasing onto #92. /mcp-prod no longer exists; the repo
now has no reference to it at all.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01R8ZshwKmjD5fZ4Hs9dS6zh

---------

Co-authored-by: Claude <[email protected]>
aterga added a commit that referenced this pull request Jul 29, 2026
PR #92 gated the beta II instance at /mcp-beta behind $MCP_SERVE_BETA (off by
default), but no deployment set it, so /mcp-beta was never mounted anywhere
(including staging). Wire it on for the staging environment only:

- imcp2.service: add Environment=MCP_SERVE_BETA=__MCP_SERVE_BETA__, substituted
  by deploy.sh per environment.
- deploy.sh: substitute __MCP_SERVE_BETA__ from $MCP_SERVE_BETA (default empty).
- deploy-native.yml: pass MCP_SERVE_BETA=1 when inputs.environment == staging,
  empty otherwise, so production keeps serving /mcp (production II) alone.

An empty value reads as off, so production's rendered unit is inert. Verified
the unit renders MCP_SERVE_BETA=1 for staging and empty for production, and
deploy.sh passes `bash -n`.


Claude-Session: https://claude.ai/code/session_014T9N8USDfNK5yzznPGg7Ym

Co-authored-by: Claude <[email protected]>
@aterga aterga mentioned this pull request Jul 29, 2026
aterga pushed a commit that referenced this pull request Aug 20, 2026
Re-verify every claim and file:line reference against the rebased tree
and absorb what main already did or changed:

- The five vestigial deps (ed25519-dalek, p256, ic-signature-verification,
  ic-representation-independent-hash, schemars 0.8) were already removed
  on main (#100) — reframe that stripping work as done.
- Account for the new hosted-only surfaces the local split must gate:
  prometheus + src/metrics.rs (/metrics, #124) and McpConfig's
  state_dir/require_resource (#144/#127); note the local binary needs no
  state directory at all. pocket-ic (e2e-only, #76) never enters any
  closure.
- Rewrite §10: production II now serves at /mcp by default (#92), CI
  probes it (#113), and the PocketIC e2e harness verifies the full
  connect contract — the remaining unknowns are the local binary's
  http://127.0.0.1 mixed-content and CORS behavior, and the harness is
  the plan for testing the local flow.
- Prod-instance env overrides are II_URL_PROD/II_CANISTER_ID_PROD (#92);
  registration chains are also verified client-side against the agent's
  root key (new_with_root_key); registration_pubkey_b64 is now fallible;
  AuthStore's dropped fields now include mcp_path and require_resource,
  and the dropped OAuth side grew RFC 8707/9207 and the bounded DCR store.
- Note the crates.io publishing dimension (v0.2.0, tag-guarded trusted
  publishing, docs/ excluded from the .crate) and re-stamp every stale
  file:line reference (auth.rs shifted ~500-650 lines; the 13 call-site
  list and all evidence-index anchors updated).

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK
aterga added a commit that referenced this pull request Aug 25, 2026
…148)

* Add scoping doc for a local-deployment MCP instance

Analyze the current beta/prod composition and scope a secondary server
instance that bridges the MCP tools to a local dfx replica instead of
mainnet. Documents the mainnet assumptions that would break locally
(root-key fetch, hard-coded IC_URL, the discovery SSRF/https guard,
target_origin canonicalization, and the CMC/ledger management path), a
proposed local run-profile design, the security guardrails, a phased
work breakdown, and open decisions.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK

* Rescope: minimal stdio local binary, no OAuth, prod II

Rewrite the scoping doc for the intended model: a separate, minimal
run-it-yourself binary that speaks MCP over stdio and talks to mainnet
IC + production Internet Identity — not a local dfx replica. It drops
the entire OAuth 2.1 authorization-server layer (the local client is
co-located, so the stdio process boundary replaces bearer-token auth)
while keeping Internet Identity: login runs as a built-in browser
handshake and per-app account delegations work as today.

Adds a verified dependency-stripping analysis (four unreferenced crates
plus a vestigial schemars drop; rmcp swaps to the stdio transport and
drops auth), the auth.rs OAuth-drop/II-connect-keep partition, the
tool/session singleton seam, a 3-crate workspace layout, the security
model, and the production-II verification risks.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK

* Keep the crate named imcp2 in the layout

The shared library crate stays imcp2 (its existing embeddable identity)
and the hosted binary stays named imcp2, so the Dockerfile, systemd
unit, and deploy scripts that build/run an imcp2 binary are unchanged.
The hosted server + OAuth layer move behind a default-on `hosted`
feature (optional axum/tower-http); the new minimal stdio binary is a
separate imcp2-local crate depending on imcp2 with default-features
off, so it never compiles the OAuth/HTTP deps.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK

* Add "Working with AI tool clients" section

Cover how imcp2-local integrates with Claude (Desktop/Code + the
cloud surfaces), Codex, Cursor, Perplexity, and Antigravity, verified
against each client's current MCP docs.

Key findings: a stdio server is reachable only by clients that spawn a
local subprocess (Claude Desktop/Code, Codex CLI/IDE/desktop, Cursor,
Antigravity, and the Perplexity macOS app via its PerplexityXPC helper);
cloud/remote-only surfaces (claude.ai web/mobile, Perplexity web/Windows,
Codex Cloud) can't reach localhost and need the hosted imcp2 server — the
reason the OAuth layer stays in imcp2. Host-driven OAuth never applies to
stdio, and stderr is invisible in chat on every client, so the II login
URL is surfaced in-band via an authenticate tool (lazy, non-blocking)
plus a best-effort browser auto-open. Adds a capability matrix, per-client
registration snippets, the login invariants, and the Perplexity remote
OAuth/discovery caveats; updates the login section and open decisions to
match.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK

* Update the scoping doc for the 63-commit rebase onto v0.2.0

Re-verify every claim and file:line reference against the rebased tree
and absorb what main already did or changed:

- The five vestigial deps (ed25519-dalek, p256, ic-signature-verification,
  ic-representation-independent-hash, schemars 0.8) were already removed
  on main (#100) — reframe that stripping work as done.
- Account for the new hosted-only surfaces the local split must gate:
  prometheus + src/metrics.rs (/metrics, #124) and McpConfig's
  state_dir/require_resource (#144/#127); note the local binary needs no
  state directory at all. pocket-ic (e2e-only, #76) never enters any
  closure.
- Rewrite §10: production II now serves at /mcp by default (#92), CI
  probes it (#113), and the PocketIC e2e harness verifies the full
  connect contract — the remaining unknowns are the local binary's
  http://127.0.0.1 mixed-content and CORS behavior, and the harness is
  the plan for testing the local flow.
- Prod-instance env overrides are II_URL_PROD/II_CANISTER_ID_PROD (#92);
  registration chains are also verified client-side against the agent's
  root key (new_with_root_key); registration_pubkey_b64 is now fallible;
  AuthStore's dropped fields now include mcp_path and require_resource,
  and the dropped OAuth side grew RFC 8707/9207 and the bounded DCR store.
- Note the crates.io publishing dimension (v0.2.0, tag-guarded trusted
  publishing, docs/ excluded from the .crate) and re-stamp every stale
  file:line reference (auth.rs shifted ~500-650 lines; the 13 call-site
  list and all evidence-index anchors updated).

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK

* Restructure the design doc to the standard feature-doc shape

Reorganize into Summary -> Problem -> Non-goals -> Approach -> Design
components -> Implementation Stages (with the verification plan and
open decisions under the stages, and the code-evidence index as an
appendix). Content is unchanged apart from the connective text: the
same components, client matrix, security model, and file:line evidence,
now in the house design-doc structure.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK

* Add a concise high-level companion to the local-deployment design

docs/local-deployment.md is the short, stakeholder-facing overview
(same Summary -> Problem -> Non-goals -> Approach -> Design components
-> Implementation Stages shape, one altitude up: no file:line evidence
or dependency minutiae); the full doc keeps the detail and both docs
cross-link.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK

* Refer to ICP CLI-spawned local replicas, not dfx

Local replicas are spawned by the ICP CLI now; drop the dfx naming from
both design docs' non-goals.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK

* Make the local-replica mode a test configuration, not a non-goal

Talking to an ICP CLI-spawned local replica is a nice-to-have rather
than something we rule out: a test build enables it with an explicit
IC-endpoint override plus a loopback-guarded fetch_root_key, and the
integration tests run imcp2-local in exactly that configuration
(against an ICP CLI-spawned replica or PocketIC carrying a deployed II
canister). Chains are already verified against the injected agent's
root key, so the flow works on a test network. The shipped binary still
targets mainnet + production II only.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK

* State the no-listening-socket claim precisely

"The server has no listening socket" overclaimed: it is true of the MCP
tool surface (stdio), but the login handshake necessarily binds a
transient loopback listener — II navigates the browser to the callback
and fetches the #4091 well-known from the callback's origin, both of
which require a real HTTP origin (a custom URI scheme has no origin and
II offers no device-grant alternative; this is the RFC 8252 loopback
redirect). Scope the trust-boundary claim to the tool surface, note that
reaching the login listener confers nothing (static pages; /redeem is
state-correlated and only accepts a chain targeting the in-process X),
and add the rationale to the login component.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK

* Recommend an imcp2-core crate over the hosted feature flag

Make the shared components a new imcp2-core library that both binaries
build on: imcp2 (unchanged name, lib + hosted binary, OAuth AS, routers,
metrics, e2e harness) and imcp2-local depend on it, and imcp2 re-exports
core's public items so existing embedders keep compiling.

The default-on `hosted` cargo feature is demoted to a rejected
alternative: features unify additively, so any crate enabling
imcp2/hosted would switch the OAuth/axum closure on for the whole build
graph, leaving the minimal-closure claim invocation-dependent; it also
needs cfg gates scattered through the code, where the crate boundary
states the component split structurally — with the core split the
session seam needs no #[cfg] at all (AuthedSession lives in core and the
Bearer arm reads http::request::Parts). Cost accepted: imcp2-core
becomes a second published crate (family-internal, 0.x, published before
imcp2).

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK

* Make the session-handling component self-contained in the overview

The overview's "session seam" bullet leaned on the full doc's jargon
(seam, bearer-token lookup, singleton). State the motivation instead:
every tool call acts as the user's II session, the hosted server
resolves it per request from the OAuth bearer token, the single-user
local server reads the one in-memory session from login, and the tool
implementations are identical in both.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK

* Make the design docs self-contained

State the final design plainly instead of narrating how it evolved:
drop the rejected-alternative paragraphs and every contrast with
superseded drafts ("not a cargo feature", "originally proposed",
"since this design's first draft", "the original concern is resolved"),
recast the dependency profile per crate as final state, and remove the
settled layout item from the open decisions.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK

* Drop the local-replica bullet from Non-goals

The local-replica test configuration is covered where it belongs (the
II wiring component and the verification plan), and the mainnet +
production II targeting is already stated in the Approach, so the
non-goal bullet added nothing but a hedge.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK

* Resolve the login-flow choices like the ICP CLI; add end-user setup UX

The login listener is axum and the browser opens via open::that,
matching the ICP CLI's web-identity flow (icp identity link web: an
axum Router on 127.0.0.1:0 with graceful shutdown; open = "5"), so the
two tools behave the same way. Session persistence stays in-memory.
With all three choices settled, the open-decisions sections are gone.

Add component 9, end-user setup (UX): per-client steps with no JSON or
config editing — the double-click .mcpb bundle for Claude Desktop, an
Add-to-Cursor install link, one pasted command for Claude Code and
Codex, connector UIs for Perplexity (macOS) and Antigravity, an
`imcp2-local setup` command that detects installed clients and writes
their configs, and the signing/notarization packaging that makes
double-click installs work.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK

* Add the upgrade story to the end-user setup UX

Client registrations point at a stable install path, so an upgrade is
an in-place binary swap picked up on the next server start — nothing to
re-register and no state to migrate (sessions are in-memory).
Distribution and updates follow the ICP CLI: cargo-dist installers with
the axoupdater updater shipped alongside, and channel detection that
surfaces the right upgrade command (axoupdater receipt / Homebrew /
npm). The Claude Desktop bundle upgrades on its own channel by
installing the new .mcpb version.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK

* Add signing and provenance to the end-user setup component

Two layers for two verifiers. OS execution gates: macOS Developer ID +
notarization (Gatekeeper is the verifier for browser-downloaded files —
including binaries spawned as MCP subprocesses — and accepts only
Apple-issued signatures; a bare signed+notarized binary passes, no
installer artifact needed) and Windows Authenticode via Azure Trusted
Signing or an EV cert. Supply-chain provenance: keyless GitHub artifact
attestations on every artifact, verifiable with gh attestation verify.
The .mcpb's substance is the signed binary inside (the format specifies
no bundle-level signing), with directory listing as the trusted
distribution path. Notes which channels bypass the gates (installer
script, Homebrew, npm), where the steps hook into the cargo-dist
pipeline, and what DFINITY must acquire with lead time.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK

* Promote signing and provenance to its own design component

Give the signing content top-level visibility as component 10 instead
of a block inside the end-user setup component, and mirror it in the
overview's component list.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK

* Commit to PocketIC as the integration-test dependency

Integration tests run imcp2-local's local-replica test configuration
against PocketIC carrying a deployed II canister (the pocket-ic dev
dependency, reusing the e2e harness's real-II setup). The endpoint
override still lets a developer point a test build at any other local
replica, but the test plan names one vehicle.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK

* Reconcile the dependency and AuthStore claims with the axum decision

The login-listener decision (axum, matching the ICP CLI) left three
stale claims behind: imcp2-local does depend on axum for its three
transient login routes, so say so in the crate-layout bullet, the net
dependency list, and the overview, scoping the absence claim to
tower-http/prometheus/OAuth and the hosted MCP transport. Also state
the AuthStore reality under the crate split: it stays intact in imcp2
(the retained OAuth routes need all of its state), the extracted
primitives carry none of it, and the local binary replaces it with a
minimal pending-connect state rather than a slimmed copy.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK

* docs: address second review round on the local-deployment design

- Component 6: rmcp's #[tool_router] is type-level per impl block, so
  construction mode alone cannot hide tools. Specify that the local-only
  authenticate/auth_status tools live in their own router that only the
  local binary composes, with a hosted-side tools/list exclusion test.
- Component 7: the Singleton session source holds a shared, replaceable
  slot rather than a fixed String — the II contract requires a fresh
  session key after Unauthorized, so re-login must be a same-process
  step with no client restart.
- Sessions wording (both docs): replace the misleading "re-login per
  run" with the actual lifetime — sign in again after a restart, on
  grant expiry, or on revocation; note the one-hour grant requested
  today and the user's consent-time choice of effective TTL.
- Verification: PocketIC exercises the protocol, not browser policy, so
  add a real-browser compatibility gate (automated Chromium/Firefox
  login run plus a manual Safari/enterprise-policy pass) to Stage 2's
  login exit criterion.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK

* docs: address third review round on the local-deployment design

- Component 6: the login tools cannot be an impl block in imcp2-core —
  they drive the loopback listener and browser opener, which live in
  imcp2-local, and core cannot call back into its dependent crate. They
  now live on a small wrapper handler in imcp2-local that merges
  tools/list and dispatches tools/call to its own router before
  forwarding to the inner IcTools handler (RequestContext<RoleServer>
  is handler-independent). Hosted stays login-free by construction,
  with the tools/list test kept as a regression guard.
- Component 1: the crate split is not visibility-neutral — workspace
  packages share no crate-private access, so the composition API
  (IcTools/IcTools::new with SessionSource, the Identities
  registration/redeem entry points, the iiconnect builders) graduates
  from pub(crate) to core's deliberate public API, re-exported by
  imcp2; dropped the "kept verbatim" phrasing.
- Component 4/5: dropping the redeem's redirect tail breaks the
  callback page's only success arm (it treats a JSON redirect as
  success, error otherwise). Specify the second success arm: the local
  redeem answers {"done": true} and the shared page renders "Signed in
  — you can close this tab" in place; hosted keeps answering redirect.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK

* docs: address fourth review round on the local-deployment design

- Dependency isolation: distinguish direct dependencies and linked code
  from unavoidable transitives. prometheus and the OAuth modules are
  structurally absent from imcp2-local's graph (it never depends on
  imcp2), but tower-http still appears deep in the graph as an
  rmcp/reqwest internal — the guarantee is that the hosted CORS layer
  is not a dependency, not that the crate name vanishes. Scope the
  Stage 1 exit criterion the same way.
- Versioning: an "internal" 0.x label on imcp2-core cannot exempt items
  imcp2 re-exports — those are imcp2 public API and breaking them is a
  breaking change for imcp2 embedders under imcp2's own semver. State
  that the label relaxes stability only for core-only surface, with the
  re-export set curated to the pre-split imcp2 API.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK

---------

Co-authored-by: Claude <[email protected]>
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