Skip to content

feat(binding-mcp): per-toolkit elicitation for the mcp proxy (#1810) - #1834

Merged
jfallows merged 82 commits into
developfrom
claude/kind-wright-P3p6I
Jun 4, 2026
Merged

jfallows merged 82 commits into
developfrom
claude/kind-wright-P3p6I

Conversation

@jfallows

@jfallows jfallows commented Jun 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Makes the mcp binding dual-ready for per-toolkit elicitation behind an mcp proxy (#1810): the binding emits/relays elicitation/create, routes the OAuth/URL callback to the correct route-exit, and drives tools/list_changed — supporting both the OSS relay model (remote is the auth authority) and the guard-driven model (Zilla is the OAuth client). Only the interactive OAuth-client guard itself is out of scope (zilla-plus).

#1810 was reframed from "oauth" to "per-toolkit elicitation" — the binding owns the MCP surface; OAuth (token exchange/DCR/storage) lives in the guard (zilla-plus) or the remote.

What's included

Foundations (earlier on the branch)

  • Phase 1 — capture + re-render RFC 9728 resource_metadata on bearer challenge.
  • Phase 2 / 2e — split the cache hydrater from the live entry; per-route fragments with keep-stale-on-failure; jacoco.
  • Phase 3 — per-route with.cache.credentials over options.cache.authorization.
  • Phase 5 (Gap A/B) — forward inbound client identity to the upstream bearer for tools/call, prompts/get, resources/read; shared elicit flow; disallow options.authorization for kind: proxy.
  • Phase 6 — timeout option + per-request McpXxxBeginEx carriage; hold-and-resume; -32042 URLElicitationRequiredError.
  • N1 — origin-conditional passthrough of a remote-originated elicitation URL (placeholder-gated).
  • N2 — persistent per-route lifecycle + Mcp-Session-Id/MCP-Protocol-Version replay/resume, locked in by a face-based session-id convention (net=transport-N, app=session-N) swept across the corpus.

Phase 7a — non-blocking partial-auth proxy tools/list: the unified lifecycle opens on the authorized subset, the per-route elicitation is relayed up the lifecycle SSE, and a native list_changed rides up as routes authorize.

Phase 7b — per-toolkit elicitation callback routing (this effort)

  • In-band context field on the elicit challenge/callback extensions (never enters the OAuth state).
  • Server records context per elicitation and echoes it on the forwarded elicitCallback (held and non-blocking).
  • Server handles an elicitCreate challenge on the lifecycle stream, renders elicitation/create on the lifecycle SSE, and resolves the callback three ways: held stream → request flush; no stream → lifecycle flush; unknown → 410 Gone.
  • Proxy carries context end to end: injects the route's aggregate prefix on the way up, routes by the echoed context (routeByPrefix) and pops its segment on the way back — stateless for elicit routing.
  • Client decodes a remote-originated elicitation/create/complete on the session SSE and relays it up (symmetry with the server side).
  • Route-exit reauthorizes on the forwarded callback (guard.reauthorize) and originates tools/list_changed; the proxy only routes/relays.
  • Synthetic (guard-driven) list_changed carries no SSE event id, so it never pollutes the remote's Last-Event-Id resumption space.
  • Open-elicitation records are single-use (consumed on resolve → replay = 410); temporal bound is the session lifetime via existing inactivity eviction.

Status deltas for #1810

Testing

Full no-skip green for the touched modules:

  • runtime/binding-mcp: 218 ITs + 26 UTs (jacoco/checkstyle/license/notice).
  • specs/binding-mcp.spec: 203 ITs + 82 UTs (+ gates).

Every new scenario has a binding IT and, where a self-consistent peer pair exists, a NetworkIT/ApplicationIT peer.

Fixes #1810

Note

HANDOFF.md is a cross-session working doc that accumulated on the branch (alongside many docs(handoff) commits). Happy to drop it / squash those out before merge if preferred.

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ


Generated by Claude Code

claude added 30 commits June 3, 2026 06:52
…n bearer challenge

Phase 1 of #1810. The upstream MCP bearer challenge (HTTP 401/403 +
WWW-Authenticate: Bearer) may carry an RFC 9728 resource_metadata parameter
pointing at the protected-resource metadata document. Capture it on the
McpClientFactory parse path, carry it on McpBearerResetEx, and re-render it
into the WWW-Authenticate header back to the connecting client on both
McpServerFactory reject paths.

Adds a dedicated lifecycle.initialize.reject.bearer.resource.metadata scenario
(network + application) with peer-to-peer NetworkIT/ApplicationIT coverage and
end-to-end McpClientIT (capture) and McpServerIT (re-render) coverage.

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
…earer reject path

Phase 1 of #1810 (follow-up). The resource_metadata capture/carry/re-render
added previously flows through both McpServerFactory reject paths, but only the
POST reject path had resource_metadata coverage. Add a
lifecycle.events.resume.reject.bearer.resource.metadata scenario (network +
application) exercising the GET/SSE reconnect reject path (McpEventStream), with
peer-to-peer NetworkIT/ApplicationIT coverage and end-to-end McpServerIT
coverage of the second re-render path.

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
…line map)

Cross-session handoff note: status table, Phase 1 summary, build/test gotchas,
verified architecture map of the proxy loopback, and a concrete Phase 2 plan
with the exact file/line targets to refactor. To be deleted before the PR.

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
…ion plan (#1810)

Investigated Phase 2 (split hydrater from live entry; remove originId==routedId
loopback). Prototyped and reverted a "direct-call decoupling" shortcut after
proving it is infeasible: the hydrater<->proxy-entry path relies on the engine
bus delivering frames asynchronously, but a direct in-process call is
synchronous/re-entrant and NPEs (reply BEGIN delivered before the hydrater's
receiver field is assigned), with broader flow-control re-entrancy hazards.

Updated HANDOFF.md with the verified finding, the confirmed current
architecture (loopback is internal plumbing; route-exit streams are already
direct), the required full-relocation approach, and the working/fast build+IT
loop plus the FileSystemAlreadyExists stale-target gotcha. No production code
change; baseline remains green.

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
Add a "start here" pointer to the Phase 2 plan, fix stale line counts in the
architecture map (1489/2032/915), and collapse the duplicate loopback
description into a pointer to the authoritative, re-verified Phase 2 section.

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
Record maintainer decisions (per-route hydration; per-(kind,prefix) slice
keys), the atomic-change coupling, the single-route aggregateRoutes finding,
the re-entrancy-safe pure-sink relocation design, and verified file/line
targets. Fresh-container build loop confirmed (baseline 27 cache ITs green).
…stractions (#1810)

Per maintainer constraint: the relocated hydrater reuses the existing decode*
states and McpListServer/McpListClient/McpLifecycleClient stream classes driven
per route into a pure-sink accumulator. Remove the vetoed sink-interface /
decoder-extraction recommendation.
…1810)

Maintainer decisions: land Phase 2 as one atomic green commit; defer the 2d
live-path baseline test to Phase 7/8. Add a self-contained next-session kickoff
(constraints + build bootstrap).
Record the maintainer reversal of decisions #1 (per-route hydration) and
#2 (per-(kind,prefix) slice keys): keep single aggregated cache storage per
kind. Storage format is orthogonal to the loopback removal, which is the only
required Phase 2 change. Keeps McpListCache, the serve path, seeded YAMLs, and
all .rpt scripts unchanged; demotes the per-slice plan to history.

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
…ments, keep-stale

Per maintainer decision: keep single unified blob storage per kind, but the
relocated hydrater holds an in-memory per-route fragment map and assembles the
blob, enabling per-(route,kind) refresh and keep-stale-on-failure (a failing
route retains last-known-good; successful-empty replaces with empty). Store
layout, serve path, seeded YAMLs, and .rpt scripts stay unchanged. Sequenced as
commit 1 (behavior-preserving relocation) + commit 2 (keep-stale test).

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
…edId loopback

Split the background cache hydrater from the live proxy entry point. The
hydrater moves into the stream package and drives McpLifecycleServer /
McpListServer / McpListClient in place (no new abstractions) via package-private
newHydration* methods, with a pure-sink MessageConsumer reply target and a
pre-granted/self-advancing reply window; the only async bus streams are the
route-exit client streams (unchanged wire ids originId=bindingId,
routedId=route.id), preserving the async decoupling the loopback provided.

The hydrater drives the merge per route into per-route fragments and assembles
the unified blob per kind (byte-identical to the prior all-routes merge), then
puts the single per-kind blob — store layout, serve path, seeded YAMLs, and all
.rpt scripts are unchanged.

Replace the originId==routedId loopback proxy with an explicit hydration flag on
McpLifecycleServer and remove the loopback discriminators (hydrating(), the
originId term in aggregating(), the onServerBegin loopback branch, and the
McpProxyListFactory.newStream originId term); flush deferral and the abort/reset
guards now key on the hydration flag. Behavior-preserving: McpProxyCacheIT (27),
McpProxyLifecycleIT (7), unit (20) green; checkstyle, license, jacoco pass.

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
…ilure

The per-route list fragments now live on McpProxyCache's per-kind McpListCache
(persisting for the binding lifetime, across hydrater stop/start and lock
handovers) rather than on a per-cycle hydrater map. On hydrate/refresh:
successful routes update their fragment (empty result replaces with empty);
a route that fails — abort, reset, timeout, or bearer challenge — keeps its
last-known-good fragment instead of being dropped. The unified blob per kind is
reassembled from the persisted fragments in configured-prefix order.

A bearer-challenge/no-session route during hydration is now surfaced as a route
failure (McpListServer aborts its sink) rather than an empty list, so its tools
are kept stale rather than cleared; initial-populate skip still contributes
nothing, so cache.hydrate.toolkit.multi.skip.unauthorized is unaffected.

Adds the cache.refresh.toolkit.keep.stale.on.failure scenario and
McpProxyCacheIT#shouldRefreshToolkitKeepingStaleOnFailure proving a failed
toolkit route retains its prior tools while another refreshes. McpProxyCacheIT
(28), McpProxyLifecycleIT (7), unit (20) green; checkstyle, license, jacoco pass.

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
…lders+matchers

Raise specs/binding-mcp.spec instruction coverage from 0.95 to 0.98 (above the
0.96 gate) by extending McpFunctionsTest. Phase 1's McpFunctions additions for
RFC 9728 resource_metadata, the lifecycle begin builder/matcher capabilities,
and the empty-buffer null branches of the BeginEx/FlushEx/ChallengeEx/ResetEx/
AbortEx matchers were never exercised. Adds build, positive-match, mismatch, and
empty-buffer tests (50->69 methods). Test-only; no production code, pom
threshold, or excludes changed.

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
…e.authorization

Add a per-route static `with.cache.credentials` to the mcp proxy `with` config.
During cache hydration each route's list stream is reauthorized through the
cache guard using the route's credential when present, falling back to
`options.cache.authorization` otherwise, so `with` takes precedence. Usage is
list-only; the shared hydration lifecycle continues to use the binding cache
authorization.

- McpWithConfig gains a `cache` (McpWithCacheConfig{credentials}) + builder
- McpWithConfigAdapter and the route `with` schema block adapt cache.credentials
- McpRoutePrefix carries the per-route credential (null-default 2-arg ctor kept
  for the live list path); populated in McpBindingConfig.resolveAll(kind,auth)
- McpProxyCacheHydrater.startRoutes reauthorizes per-route credential precedence
- McpWithConfigAdapterTest + cache.hydrate.credentials.toolkit scenario
  (McpProxyCacheIT + peer-to-peer ProxyCacheIT)

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
…and list streams

Resolve a route's with.cache.credentials once in McpLifecycleClient (hydration
only) into a per-route authorization, falling back to the binding cache
authorization (options.cache.authorization) when absent. The route's lifecycle
and list hydration streams now share that single authorization — McpListClient's
upstream frames use lifecycle.authorization rather than the list server's. This
replaces the earlier list-only wiring that left the lifecycle stream on the
binding credential. The live path is unchanged (lifecycle client authorization
defaults to server.authorization).

The hydrate scenario simplifies to a single route-exit accept since the
lifecycle and list streams now carry the same authorization.

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
…#1752

Audited the binding-mcp source against the Phase 5-9 sketch. The guard
NEEDS_PREAUTHORIZE -> preauthorize -> elicit -> callback -> reauthorize flow
and its IT coverage already exist in develop (#1739/#1752), so Phases 5 and 9
are core-done, not "not started". Phase 6 is the first genuinely-unbuilt phase.
Recorded per-phase EXISTS/MISSING evidence and the two residual Phase-5 gaps
(binding-level not per-route guard/credentials; reauthorize(null) not inbound
bearer).

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
…+ proxy schema)

Records the maintainer-confirmed design: carry only the inbound authorization
long (no bearer string, no IDL change); on the client-kind path reuse an
already-authorized inbound authorization via guard.credentials(authorization)
and skip elicit, else fall through to the existing reauthorize/elicit flow;
push elicit machinery into the shared McpRequestStream so prompts/get and
resources/read elicit too (Gap B); disallow options.authorization for
kind: proxy via schema while keeping the field for server/client kinds.
Includes verified facts, edit points, and the test plan.

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
…call bearer

On the client-kind path, reuse an already-authorized inbound authorization to
derive the upstream Authorization bearer via guard.credentials(authorization),
instead of ignoring it and falling back to a static credential. The inbound
identity is consumed at the binding: upstream net streams are opened unguarded
(authorization 0) so the external MCP server sees only the bearer, matching the
existing guarded-elicit behavior and avoiding propagation of the internal
authorization long onto the external connection.

Test-first: tools.call app scripts parameterized with an authorization property
(default 0, overridden to 1 via @ScriptProperty for the identity case, reusing
the existing scripts); new tools.call.identity network scenario asserts the
upstream Authorization: Bearer header; client.identity.yaml fixtures the test
guard. NetworkIT + McpClientIT cover it; full spec and runtime builds green.

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
…p B/schema

Notes the shipped tools/call identity forwarding and the maintainer decision to
consume inbound identity at the binding (upstream authorization 0), the
discovered lifecycle stall it avoids, and the precise remaining work: extend
inbound-reuse + elicit to prompts/get & resources/read via McpRequestStream, and
the proxy authorization schema constraint (incl. the proxy.options.yaml fixture
cleanup it requires).

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
A proxy-kind binding routes and aggregates; it never reads its own request
guard (only the cache guard via options.cache.authorization), so a top-level
options.authorization on a proxy is meaningless. Disallow it in the schema's
proxy branch, mirroring how the server/client branch disallows cache.

Removes the unused options.authorization from the proxy.options.yaml fixture
(cache.authorization is unaffected), adds proxy.authorization.invalid.yaml and
SchemaTest.shouldRejectProxyWithAuthorization. server/client keep
options.authorization. Full spec and runtime builds green.

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
…d resources/read

Add the inbound-authorization reuse to the shared McpRequestStream so every
request kind (prompts/get, resources/read, tools/list) derives the upstream
bearer from an already-authorized inbound authorization via
guard.credentials(authorization), consistent with tools/call. The lifecycle
(McpStream) is intentionally left unchanged so its upstream stays unguarded.

Test-first: prompts.get and resources.read app scripts parameterized with the
authorization property (default 0, overridden to 1 via @ScriptProperty); new
prompts.get.identity and resources.read.identity network scenarios assert the
upstream Authorization: Bearer header; NetworkIT + McpClientIT cover both.
Full spec and runtime builds green.

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
…pts/get, resources/read)

Move the preauthorize/elicitation machinery (pendingAuth buffering, elicit
challenge, callback reauthorize, timeout signal, completion/decline/cancel
handling) from McpToolsCallStream up into the shared McpRequestStream base, so
prompts/get and resources/read support the same inbound elicitation flow as
tools/call. tools/call, prompts/get and resources/read now inherit a single
implementation; the lifecycle (McpStream) is unaffected.

The moved code stays covered by the existing tools.call.elicit.{completed,
declined,timeout} tests (tools/call now inherits it); new
prompts.get.elicit.completed.guarded and resources.read.elicit.completed.guarded
scenarios prove the capability end-to-end for the two new request kinds.
Full spec and runtime builds green.

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
Schema proxy-authorization constraint, Gap A inbound identity for prompts/get
and resources/read, and Gap B shared elicit flow all shipped and green.

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
…ginEx timeout carriage

Phase 6 (sub-step 6a, plumbing). Adds an `int64 timeout = 0` field to the six
operation BeginEx variants (toolsList/toolsCall/promptsList/promptsGet/
resourcesList/resourcesRead) so the effective elicitation hold budget can be
carried per request, and a `timeout` Duration option on the mcp binding
(McpOptionsConfig + builder + adapter + schema, default unset → 0). McpFunctions
gains timeout builders/matchers for all six variants.

No behavior change yet: nothing stamps or consumes the field (the server
effective-timeout stamping and the -32042 hold-vs-reject behavior follow in
the next sub-steps). Covered by McpFunctionsTest (timeout per variant) and a
new McpOptionsConfigAdapterTest (timeout round-trip). Full spec and runtime
builds green.

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
…inEx at the server

Completes Phase 6 sub-step 6a. McpServerFactory resolves the effective timeout
= options.timeout, gated to 0 when the client did not negotiate
CLIENT_ELICITATION_URL (persisted per session at initialize), and stamps it on
each request BeginEx it emits (toolsList/toolsCall/promptsList/promptsGet/
resourcesList/resourcesRead). The McpServer carries the configured timeout; the
session holds the resolved per-request value.

Still behavior-neutral downstream (nothing consumes the stamped value yet — the
-32042 hold-vs-reject behavior is 6b). New tools.call.timeout scenario
(initialize negotiates elicitation.url; app toolsCall BeginEx asserts
timeout=30000) wired into McpServerIT (server.timeout.yaml) and peer
NetworkIT/ApplicationIT. Full spec and runtime builds green.

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
claude added 25 commits June 4, 2026 05:50
Mark N2 (persistent per-route lifecycle / Mcp-Session-Id+protocol-version
replay / resume) DONE: face-based session-id convention swept corpus-wide
(net=transport-N, app=session-N; proxy per-toolkit exits session-1a/1b under
aggregate session-1), N2c resume covered, N2d deferred. Update the start-here
pointer to flag N3 (examples/mcp.proxy) as the next Track-A deliverable.

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
…g binding work

Record maintainer decision that the OSS mcp.proxy e2e example (N3) ships as a
separate effort and does not gate the binding PR. The only remaining #1810
binding work is Phase 7 (P7a OSS relay list + native list_changed; P7b Track B
state inject/strip + callback routing + list_changed origination).

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
…R description

Decided: leave the #1810 body and the 2026-06-04 broadening comment as-is; fold
the status deltas (N1+N2 done, N3 split out, Phase 7 remaining) into the PR
description when the PR opens, rather than editing the issue or adding a comment.

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
…tation shape

Verified against code: the live list already non-blocks; an unauthorized route
surfaces at the per-route lifecycle (sessionId==null skip), and the real blocker
is McpLifecycleServer.onClientBearerReset doing an all-or-nothing reset of the
whole unified lifecycle. Core 7a work is restructuring the lifecycle aggregation
to allow partial auth + relay per-toolkit elicitation up the north SSE. Includes
the test-first plan and the one open kickoff decision.

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
… client binding

Maintainer decision: unified lifecycle always opens (empty baseline if all
routes fail, never whole-session bearer-reset); the elicitation is sourced at
the route-exit mcp client binding and only RELAYED up by the proxy (proxy never
mints elicitations, per Decision A).

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
…proxy list

Author the spec scenarios that define Phase 7a (Track A / OSS relay, #1810)
before the runtime change:
- lifecycle.initialize.partial.toolkit.multi: app1 settles (session-1a, NOT
  aborted), app2 relays an elicitCreate challenge, unified session OPENS
  (session-1) with the relayed elicitation — replaces today's all-or-nothing
  bearer-reset.
- tools.list.partial.toolkit.multi{,.prefixed}: live tools/list returns only the
  authorized route's tools; unauthorized route skipped (peer-tested).
- lifecycle.notify.tools.list.changed.after.authorize.toolkit.multi{,.prefixed}:
  route authorizes out-of-band, native list_changed relayed up the lifecycle
  SSE, re-list returns the full set.

Peer ApplicationIT methods added (shouldListToolsWithPartialToolkitMulti{,Prefixed});
full spec module green (ApplicationIT 105, module 199). No runtime Java yet — the
proxy-IT methods are RED until the lifecycle aggregation restructure lands and are
listed in HANDOFF as the implementation targets. No McpFunctions changes.

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
… + list_changed

Phase 7a (Track A / OSS relay, #1810). The unified proxy lifecycle no longer
fails when one route needs authorization: a route-exit that is unauthorized
advises an elicitCreate challenge (no sessionId) instead of bearer-resetting,
and the proxy now

- counts that route as settled (one-shot settled flag via settleLifecycle) so
  the unified north lifecycle opens on whatever authorized subset exists, and
- relays the elicitation up the north lifecycle SSE
  (McpLifecycleServer.doServerChallenge, mirroring McpProxyItemFactory).

McpLifecycleClient.register now keys off settled rather than
replyOpened && sessionId != null, so a challenged-but-unauthorized route settles
immediately as a skip in the list fan-out instead of blocking the aggregation on
a reply that never comes. The already-non-blocking list serves the authorized
subset; when the route later authorizes, its native tools/list_changed rides up
the existing aggregate-event-id relay and a re-list returns the full set. The
genuine bearer-reset path (onClientBearerReset) is unchanged.

Spec corrections (consistent with the N2 persistence invariant + relay design;
peer ApplicationIT stays green):
- tools.list.partial.toolkit.multi.prefixed: assert/emit the relayed elicit
- tools.list.partial.toolkit.multi: drop the premature unauthorized-route close
  (the route lifecycle stays open for the whole session)
- lifecycle.notify.tools.list.changed.after.authorize.toolkit.multi: add
  barriers so the route authorizes only after the first list completes; fix the
  aggregate id to 2=200

McpProxyIT 44->47. Full no-skip green: runtime binding-mcp 212 IT + 26 UT +
jacoco/checkstyle/license; spec binding-mcp.spec 199 IT (ApplicationIT 105) + UT.

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
…ecycle eagerly

A bare upstream bearer challenge is not actionable for a client connecting to the
1-to-many proxy aggregate: auth lives on the route-exit (the many) side and the
connecting client must not present per-remote credentials to the aggregate. So the
proxy no longer relays a route's bearer reset to the client or fails the whole
session on it. McpLifecycleClient.onClientReset now treats a bearer reset as
"route unauthorized" — it settles that route and skips it, opening the unified
lifecycle on whatever authorized subset exists (onClientBearerReset's all-or-nothing
reset is removed). A route-exit guard still converts a 401 into an elicitCreate
challenge before it reaches the proxy (onClientChallenge), so only a bare,
unconvertible reset degrades a route to skipped. Faithful bearer relay to the
connecting client remains in the non-proxy mcp server -> mcp client topology only.

The proxy also now opens the unified reply eagerly when the routes are established,
rather than blocking on every route settling. The sessionId is minted and
serverCapabilities is derived from the configured routes, so initialize is answered
immediately; routes settle independently and their tools fill in via tools/list.
This is what makes partial-open correct for a request/response client: it finishes
its initialize request (request-side END) and awaits the response, so a slow or
unauthorized route can neither delay the session nor tear it down before the reply
is served.

Reframes the proxy-only reject.bearer scenarios accordingly:
- lifecycle.initialize.skip.bearer.toolkit.multi (was reject.bearer.toolkit.multi):
  authorized route settles, bearer-rejected route is skipped, unified session opens.
- lifecycle.initialize.skip.bearer: single-route proxy opens an empty session when
  its only route bearer-rejects.
McpProxyIT / McpProxyLifecycleIT repointed. Full no-skip green: runtime binding-mcp
212 IT + 26 UT + jacoco/checkstyle/license; spec binding-mcp.spec 199 IT + 76 UT.

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
… on the callback

The mcp server injects <sessionId>.<elicitationId>. into the elicit URL state on the
way up (manipulateElicitUrl); on the OAuth callback it now strips exactly that prefix
before forwarding the elicitCallback down the application pipeline. Each hop reverses
its own injection, so the route-exit guard sees the bare nonce it minted rather than
Zilla's internal framing — a cleaner guard contract and the foundation for per-toolkit
proxy elicitation, where the proxy will likewise strip the <toolkit>__ it injects.

Updates the committed elicit scenarios so the route-exit elicitCallback state is the
stripped 7f3a9b1c rather than transport-1.elicit-1.7f3a9b1c. Inbound OAuth callback
paths (network scripts) keep the full state, as the authorization server returns it.

Full no-skip green: runtime binding-mcp McpServerIT 68 + McpClientIT 61 + UT;
spec binding-mcp.spec 199 IT + 76 UT.

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
Add an optional `string8 context = null` to McpElicitCreateChallengeEx (the
challenge relayed up: proxy → server) and McpElicitCallbackFlushEx (the callback
forwarded down: server → proxy). This is the in-band carrier for per-toolkit
elicitation-callback routing through the mcp proxy:

- on the way up the proxy pushes the route's (opaque) prefix into `context`;
- the server records it in its open-elicitation tracking keyed by elicitationId
  (it is NOT encoded into the OAuth state, so nothing route-related leaves the
  binding); and
- on the callback the server echoes `context` on the forwarded elicitCallback so
  the proxy can route to the right route-exit and strip its own segment.

Optional with a null default, so the non-proxy server <-> client elicit flow is
byte-identical and existing behavior is unchanged. Wire carrier only in this
commit; server/proxy use lands next.

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
…te for fresh handoff

Capture the design that converged this session so a fresh context can resume cleanly:
- #1810 reframed to "per-toolkit elicitation"; Phase 8 split to #1831.
- 7a + bearer handling + server-side strip + context IDL field are landed/pushed
  (commits noted in the start-here block).
- New authoritative "Phase 7b — CONVERGED DESIGN (context field)" section: in-band
  context routing (never in the OAuth state), elicitation completion decoupled from the
  originating request, 410 only on unrecognized elicitation ids, ordered remaining steps,
  and the gotchas (peer shape scripts don't compose through the proxy; blocking-through-proxy
  elicit never verified e2e; capabilities ignored binding-wide).
- Marked the older <toolkit>__ state-injection mechanism SUPERSEDED.

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
…icit helpers

Extend the McpElicitCreateChallengeEx and McpElicitCallbackFlushEx builder and
matcher helpers in McpFunctions with the optional in-band `context` field
(string8, landed on the IDL in bb3f74d). The proxy pushes the route prefix
into `context` on the relayed elicitCreate (UP) and the server echoes it on the
forwarded elicitCallback (BACK) so per-toolkit elicitation callbacks self-route.

Builder threads `context` into the flyweight; matcher ignores it when unset
(partial-match convention). Adds six McpFunctionsTest cases (generate + match +
mismatch for each of elicitCreate and elicitCallback); McpFunctionsTest 69 -> 75.

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
The mcp server now records the in-band `context` carried on an inbound
elicitCreate challenge (string8, set by a downstream proxy to identify the
route) and echoes it on the elicitCallback flush it forwards back down on the
held request stream. This lets a proxy route the callback to the right
route-exit by the echoed context and strip its own segment, without keeping any
per-elicitation map.

context defaults to null, so the non-proxy server <-> client elicit flow is
byte-identical. New `tools.call.elicit.completed.context` application scenario;
ApplicationIT peer + McpServerIT (server echoes context) coverage.

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
…ifecycle

Add server-side handling for a per-toolkit elicitation that has no held request
stream (the non-blocking tools/list case relayed up by a proxy):

- the lifecycle stream now handles an inbound elicitCreate CHALLENGE: it mints
  the elicitationId, manipulates the URL, records an open elicitation keyed by
  elicitationId, and renders elicitation/create on the lifecycle events SSE;
- open elicitations are tracked as a McpElicitation record (held request stream
  may be null) instead of a bare McpRequestStream, carrying the in-band context;
- the auth callback handler resolves the record and routes the callback three
  ways: held stream present -> flush on the request stream (blocking, as before);
  no held stream -> flush elicitCallback up the lifecycle so a proxy can route it
  to the right route-exit; unknown -> 410 Gone. context is echoed on both paths.

New lifecycle.elicit.toolkit scenario: McpServerIT drives net client + app
server (server renders the elicit on the lifecycle SSE and forwards the callback
up the lifecycle with context echoed); ApplicationIT peer covers the app pair.
Full no-skip green: runtime 214 IT/26 UT (jacoco/checkstyle/license); spec 201
IT/82 UT.

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
…e proxy

The proxy now carries the in-band elicitation context end to end:

- UP: when relaying a route-exit's elicitCreate challenge up the north
  lifecycle, the proxy injects context = that route's aggregate prefix
  (injectChallengeContext on McpLifecycleClient); single-route bindings have no
  prefix so context stays null and the relay is byte-identical;
- BACK: the north-facing lifecycle now handles an inbound elicitCallback FLUSH
  (onServerFlush) — it reads context, resolves the route via routeByPrefix,
  pops its segment, and forwards the callback down to that route-exit
  (doClientFlushElicitCallback). A single-route binding (no context) forwards to
  its sole route.

The proxy stays stateless for elicit routing: push the prefix on UP, route by
the echoed context on BACK, no per-elicitation map. New proxy-only
lifecycle.elicit.toolkit.multi scenario (route A authorized, route B elicits;
relayed challenge carries context, callback routes back to route B) +
McpProxyIT#shouldRouteElicitCallbackToToolkit. Full no-skip green: runtime 215
IT/26 UT (jacoco/checkstyle/license).

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
Restores client/server symmetry for session-stream elicitation. The mcp client
opens a standalone GET (session/events) SSE to the remote and already relayed
native notifications (list_changed) from it, but McpLifecycleStream did not
override onDecodeElicitCreate/onDecodeElicitComplete, so a remote-originated
elicitation/create arriving on the session SSE fell through to the base no-op
and was silently dropped (only a request-response SSE handled it).

McpLifecycleStream now overrides both, mirroring McpRequestStream: a
session-SSE elicitation/create is relayed up as an elicitCreate CHALLENGE (so a
downstream proxy's onClientChallenge injects context and the north server
renders it), and elicitation/complete is relayed up as an elicitComplete flush.
This is spec-legitimate: in Streamable HTTP, elicitation/create is a
server->client request and the standalone SSE stream may carry server-initiated
requests.

New lifecycle.events.elicit scenario: McpClientIT drives app client + net
server (remote emits elicitation/create then /complete on the session SSE; the
client relays both up the lifecycle); ApplicationIT peer covers the app pair.
Full no-skip green: runtime 216 IT/26 UT; spec 202 IT/82 UT
(jacoco/checkstyle/license).

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
…-exit lifecycle

Completes guard-driven per-toolkit auth. When the proxy forwards an elicitCallback
down to a route-exit (3a), the route-exit mcp client lifecycle now drives the
guard and originates the listing-changed notification itself:

- McpLifecycleStream.onAppFlush detects an elicitCallback flush and calls
  guard.reauthorize(callbackUrl, completion) (no held request stream needed);
- on async completion, if the session is authorized (MASK_AUTHORIZED), it emits
  notifications/tools/list_changed up its lifecycle (doAppFlush toolsListChanged
  with a minted event id) so the proxy aggregates/relays it up and the client
  re-lists. Per the converged design, reauthorize + list_changed ORIGINATE at the
  route-exit client; the proxy only routes the callback and relays the
  notification.

New lifecycle.elicit.reauthorize scenario: McpClientIT (client.guarded.yaml) drives
app client + net server (forwarded callback -> guard reauthorize -> list_changed);
ApplicationIT peer covers the app pair. Full no-skip green: runtime 217 IT/26 UT;
spec 203 IT/82 UT (jacoco/checkstyle/license).

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
…orize

A guard-driven notifications/tools/list_changed minted by the route-exit on
reauthorize is injected on behalf of the remote and has no counterpart in the
remote's SSE event stream. Emitting a Zilla-minted id would pollute the remote's
Last-Event-Id resumption space and could be replayed as an unknown id on
recovery. Emit it with no id (transient re-list nudge, not a resumable
position); the proxy skips id-less events in aggregation and relays them
verbatim, and the north server renders a data-only SSE event with no id line.

Drops the per-lifecycle notify counter; lifecycle.elicit.reauthorize scripts
updated to expect a toolsListChanged with no id. Full no-skip green: runtime 217
IT/26 UT; spec ApplicationIT peer green.

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ
Open-elicitation records are now consumed on resolve: resolveElicitation removes
the record from the session map instead of getting it, so a replayed or
duplicate auth callback for the same elicitation resolves to 410 Gone and a
resolved record never lingers past its one callback. Combined with the existing
session-inactivity eviction (which already clears a session's records when it
goes idle), open-elicitation records now have a complete bounded lifecycle: a
record lives only until its single callback or until its session is evicted.

This deliberately uses the session lifetime as the temporal bound rather than an
aggressive independent timer, which would prematurely abort legitimate
multi-minute URL/OAuth elicitation flows (and could not be tested
deterministically without a clock hook).

New lifecycle.elicit.toolkit.replay scenario in McpServerIT: an authorized
callback (200) followed by a duplicate for the same state -> 410, with the
session kept alive so the rejection proves record consumption (not session
eviction). Full no-skip green: runtime 218 IT/26 UT; spec 203 IT/82 UT
(jacoco/checkstyle/license).

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ

@jfallows jfallows left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

LGTM

Align options.authorization with options.cache.authorization (same binding) and
the http/mqtt bindings: instead of a flat { name, credentials }, an authorization
entry is now keyed by the guard name with an optional credentials inside:

  authorization:
    <guard>:
      credentials: <value>

McpAuthorizationConfig (name + credentials) and all factory behavior are
unchanged; only the JSON/YAML shape and its adapter + schema change. The schema
block now mirrors cache.authorization (patternProperties on the guard name,
maxProperties 1). The guardless static bootstrap credential
(client.credentials.yaml) now names a test guard; with no preauthorize the guard
returns NOT_AUTHORIZED on the live reauthorize(null), so the static credential
still falls back and is attached, preserving shouldInitializeLifecycleWithBootstrapCredential.

Updated config yamls (client.guarded/identity/options, server.options,
proxy.authorization.invalid, client.credentials). Full no-skip green: runtime
218 IT/26 UT; spec 203 IT/82 UT (jacoco/checkstyle/license).

https://claude.ai/code/session_01QM4QVu6tnoHS7X4GpxfXmJ

@jfallows jfallows left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

LGTM

@jfallows
jfallows merged commit a45be7e into develop Jun 4, 2026
1 of 2 checks passed
@jfallows
jfallows deleted the claude/kind-wright-P3p6I branch July 1, 2026 23:04
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.

binding-mcp: per-toolkit elicitation for mcp proxy

2 participants