Description
Summary
Enable the MCP proxy (binding-mcp kind: proxy) to elicit independent authorization
per proxied toolkit and route the consent flow end-to-end with the connecting MCP client,
using MCP URL-mode elicitation (SEP-1036): the proxy emits/relays a per-toolkit
elicitation/create, correlates and routes the OAuth callback per toolkit, and fires
notifications/tools/list_changed as each toolkit authorizes.
The binding owns only the MCP surface — elicitation emission/relay, the callback
endpoint, and state correlation. The credential scheme that rides on the elicitation
(OAuth: token exchange, dynamic client registration, storage) is not the binding's
concern: it is completed either by the remote MCP server (Track A, OSS relay — Zilla
relays the elicitation and the callback and holds no token) or by an engine Guard
(Track B — a token-exchange-capable guard behind the Guard SPI, e.g. a zilla-plus OAuth
guard). A simple guard works today and a richer OAuth guard drops in later with no
binding-mcp change.
The work hinges on separating two flows (a holdover from when the cache was a
separate binding type): background cache hydration (shared, list-only credential,
tolerant) vs. the live proxy entry point (per-client, auth-eliciting, per-client
execution). See Design §1.
Builds on the examples/mcp.proxy work in #1793.
Scope note: per-client listing filtering by per-tool authorization metadata
(SEP-1488securitySchemes/ operator scope map / annotation fallback, acquirable vs
non-acquirable, cached-baseline ∪ per-identity hybrid serve) is tracked separately in
#1831 — it is a listing-accuracy optimization layered on the signaling this issue
delivers, and is not required for the Track A OSS-relay example.
Motivation
The proxy aggregates several upstream MCP servers behind one endpoint. Authenticated
upstreams (e.g. the local github-mcp-server) challenge with
HTTP 401 + WWW-Authenticate: Bearer resource_metadata="…" (RFC 9728). Today:
- the bearer-challenge path captures only
realm/scope/error— not
resource_metadata— so a github-style challenge conveys nothing actionable to the
client (the deferred URL-passthrough item); - a 401'd route is silently skipped during aggregation, so the client never learns it
needs to authorize; - the transport-level bearer model is single-credential (one protected resource →
one token), so it cannot represent N independent per-toolkit credentials at all; - cache and live handling share one tolerant path. The per-route auth-failure
tolerance needed to populate the cache is being imposed on live client requests, so a
client'stools/listsees the degraded cached aggregate (unauthorized toolkit hidden)
and is never prompted to authorize.
We want a client to be able to authorize each authenticated toolkit independently and
use the aggregated gateway with no per-upstream token wiring.
Goals
- Per-toolkit, independent authorization for proxied upstreams, surfaced as per-toolkit
URL-mode elicitation and routed end-to-end (elicit → callback → reauthorize →list_changed). - Cleanly separate cache hydration (shared baseline, list-only credential, tolerant)
from live request auth (per identity, eliciting, per-client execution). - Standards-based: MCP URL-mode elicitation + the
URLElicitationRequiredError
(-32042) array; OAuth callback handled by Zilla, tokens bound to the client identity. - Keep all credential semantics behind the Guard SPI;
binding-mcpowns only the
MCP surface (elicitation emission, callback endpoint, state correlation). - Default behavior = portable retry model; opt-in single-shot delivery.
- Never execute with the shared cache credential — every
tools/calluses the client's
own token, so the upstream remains the authoritative enforcer attools/call.
Background (current building blocks)
- Guard SPI already anticipates this:
reauthorize → NOT_AUTHORIZED | NEEDS_PREAUTHORIZE | sessionId,preauthorize(callback) → authorize URL, async
reauthorize(credentials=callbackURL)documented "for upstream token exchange after
an out-of-band consent step", pluscredentials/expiringAt/deauthorize. - Per-route bootstrap credential exists (binding-mcp: add cache option to mcp · proxy binding #1737,
options.authorizationon the south
mcp client) — this issue supersedes/reconciles it into the cache-credential model (§2). - URL-elicitation + callback machinery exists (
McpElicitCreateChallengeEx{id,url},
manipulateElicitUrlinjectingredirect_uri+state,McpAuthCallbackHandler,
resolveElicitation) — currently triggered by an upstreamelicitation/create,
and effectively a pre-standard extension under the negotiated protocol2025-06-18. - Streamable-HTTP resumability (
McpRequestStream, suspend/resume,
Last-Event-Id) — the substrate for hold-and-resume.
Design
1. Separate cache hydration from live request auth
Two distinct flows with different identity scope and auth-failure policy; they
must not share one tolerant path.
| Cache hydrater | Live proxy entry point | |
|---|---|---|
| Driver | background, periodic | per client request |
| Identity | one list-only credential | the connecting client's identity |
| Auth failure | degrade / skip, populate what succeeds | elicit (hold / -32042) |
| Credential use | list only, never invoke | execute with the client's own token |
| Result | shared store | response to that client |
- The hydrater fans out directly to the route exits to populate the shared store —
it does not loop back through the proxy entry. (This removes the old
originId == routedIdself-stream detection; the proxy entry then only ever handles
live client requests.) - Correctness constraint: per-client OAuth yields per-identity tokens and tool
lists. Those must not enter the shared store (cross-user leakage; cf. the draft
cacheScope: "private"signal). The shared cache is the shareable baseline;
per-client-authorized content is live / per-identity. - Live entry point serves, per identity, the shared baseline + the client's
per-identity authorized toolkits. Auth surfaces through the operations themselves (§6).
2. Cache (listing) credentials — with.cache, defaulting to options.cache
The credential used to enumerate an upstream's catalog into the shared cache.
- It is list-only: used by the hydrater to read
tools/listetc., never to
invoke a tool (destructive or not). All invocation uses the client's own token (§4/§7).
Because it never executes, it can be scoped broadly to enumerate the full superset
catalog without execution risk (it is still a sensitive secret — guard it). - Per-route, on the proxy route's
with.cache, with the binding-level
options.cache.authorizationas the default. Precedence:withwins overoptions. - Source split (by capability, via the guard SPI):
with= static per-route credential (e.g. a read-only listing PAT) — no guard
needed.options.authorization.name→ guard resolves the credential dynamically
(token exchange / client-credentials / DCR) — requires a guard that supports it; the
bundledidentityguard does not.
north_mcp_proxy:
type: mcp
kind: proxy
options:
cache:
store: cache
ttl: PT5M
authorization: # binding-level default
name: # dynamic, via a token-exchange-capable guard, or
credentials: <...> # static default
routes:
- when: [{ toolkit: github, capability: [tools, resources] }]
exit: south_mcp_client_github
with:
cache:
credentials: # static (zilla); wins over options3. Per-client listing accuracy & per-tool scopes — split to #1831
Filtering the aggregated listing per client by per-tool authorization metadata (SEP-1488
securitySchemes / operator scope map / annotation fallback), the acquirable-vs-non-acquirable
distinction, per-identity live listing where metadata is absent, and the cached-baseline ∪
per-identity hybrid serve are tracked in #1831. This issue delivers the underlying
mechanism: the shared cache is the role-neutral baseline, per-identity authorized content is
served live (§1), execution always uses the client's own token (§7), and tools/list fires
list_changed to the authorizing client (§6).
4. Guard does credentials; binding-mcp does the MCP surface
Single guard-agnostic path per route:
reauthorize(inbound-bearer-or-null) → valid → credentials() → stamp; NEEDS_PREAUTHORIZE
→ preauthorize(callback = Zilla connect URL) → authorize URL; on callback feed the
callback URL back into async reauthorize → guard exchanges + stores the token. The
bundled identity guard never returns NEEDS_PREAUTHORIZE; a guard that supports
preauthorize + async reauthorize (token exchange) implements DCR / PKCE / exchange /
refresh / storage behind the same interface — binding-mcp is unchanged either way. Each
route names its own guard (options.authorization.name) →
independent per-toolkit credentials, stored by the guard per (identity, route).
5. Delivery mode = live-exchange property, resolved at the server
Applies to blocking operations on the live entry point (e.g. tools/call);
tools/list is non-blocking (§6).
- New
timeoutoption on the mcp server binding (default0). 0→ promptURLElicitationRequiredError(-32042) → client retries.>0→ hold the request open up totimeout, single-shot via the resumable stream;
on expiry fall back to-32042.- The server resolves the effective timeout (configured value gated by the client's
negotiated capabilities —elicitation.url+ hold/resume tolerance; →0if the client
can't hold) and stamps the effective value on each request'sMcpXxxBeginEx(default
0). Per-request carriage matches the per-stream handler model; the proxy honors it to
choose suspend-and-resume vs tear-down-for-retry.
6. Where auth surfaces (per operation, live entry point)
No synthetic authorize tool — auth surfaces through the operations themselves:
tools/list(+ prompts/resources list): non-blocking. Return the authorized
toolkits' tools immediately, and emitelicitation/create(URL mode) for each
unauthorized toolkit on the list request's stream. Do not block. On completion fire
notifications/tools/list_changed(existingMcpToolsListChangedFlushEx) → the client
re-lists → newly-authorized tools appear. This makestools/listthe universal
discovery + prompt point.tools/call(+ prompts/get, resources/read) to an unauthorized toolkit: blocking.
timeout==0→-32042→ retry;timeout>0→ hold +elicitation/create, single-shot.
Each needs-preauth route contributes one ElicitRequestURLParams{mode:"url", url, message, elicitationId} (via preauthorize); the fan-out barriers on all per-route begins
reaching a terminal state. The multi-entry -32042 array is optional (a tools/call
targets one toolkit; tools/list prompts via per-toolkit elicitation/create).
7. Correlation, storage & execution
Each entry carries a server-minted elicitationId; the elicited URL is a Zilla
connect?elicitationId=… URL (anti-phishing), with state binding to identity (not
session id alone, per spec MUST), and provider/client_id/scopes kept server-side in the
guard. Execution tokens are stored per (identity, route) — never in the shared store,
and every tools/call executes with the client's own token, so the upstream remains
the authoritative enforcer (a client lacking a scope gets 401/403 → no escalation even
if synthesized scopes are wrong). Restrictions the upstream can't model (gateway-level
role policy) must be enforced authoritatively by Zilla at tools/call. Retries
converge and are idempotent (token present → skip).
Protocol version
URL-mode elicitation, the -32042 array, and capabilities.elicitation.url are MCP
2025-11-25; Zilla negotiates 2025-06-18. SEP-1488 (securitySchemes) and
cacheScope are draft. This work requires a protocol bump + capability negotiation,
and reconciling the existing pre-standard URL-elicitation extension with SEP-1036. Clients
without elicitation.url fall back to degrade.
Proposed phasing
resource_metadatacapture + carry onMcpBearerResetEx+ re-render to client
(extends binding-mcp: propagate upstream auth challenges to inbound client #1795; testable in isolation, no live OAuth needed).- Split the live entry point from the hydrater (§1); hydrater fans out directly to
route exits; removeoriginId == routedIdself-stream loopback; shared store = baseline. - Cache (listing) credential model (§2):
with.cachestatic (zilla) over
options.cache.authorization; list-only usage. - Protocol
2025-11-25+elicitation.urlcapability negotiation; reconcile existing
URL-elicitation with SEP-1036. - Guard-driven
NEEDS_PREAUTHORIZE → preauthorize → elicitation → callback → reauthorize
for a single route (retry /-32042); per-(identity,route)execution storage. timeoutoption + per-requestMcpXxxBeginExcarriage; hold-and-resume path.- Non-blocking
tools/list(partial + per-toolkitelicitation/create+list_changed)
and blockingtools/call. - (moved to binding-mcp: per-client
tools/listfiltering by per-tool authorization metadata #1831) Per-client listing filter: consume SEP-1488securitySchemeswhen
present; operator-declared mapping + annotation fallback; per-identity live listing where
absent; cached-baseline ∪ per-identity hybrid serve. - IT coverage of the
preauthorize → elicit → callback → reauthorizeflow using a test
guard that exercisesNEEDS_PREAUTHORIZE/preauthorize(no live OAuth provider needed).
References
- MCP elicitation (2025-11-25): https://modelcontextprotocol.io/specification/2025-11-25/client/elicitation
- SEP-1036 (URL elicitation): SEP-1036: URL Mode Elicitation for secure out-of-band interactions modelcontextprotocol/modelcontextprotocol#1036
- SEP-1488 (per-tool
securitySchemes, draft): SEP-1488: securitySchemes in Tool Metadata for Mixed-Auth Servers modelcontextprotocol/modelcontextprotocol#1488 - RFC 9728 (OAuth Protected Resource Metadata), RFC 6750
- Related: feat(examples): mcp.proxy demonstrates url-mode elicitation aggregation #1793, binding-mcp: add cache option to mcp · proxy binding #1737, binding-mcp: propagate upstream auth challenges to inbound client #1795, binding-mcp: per-client
tools/listfiltering by per-tool authorization metadata #1831
Activity
test(binding-mcp): cover resource_metadata on the SSE events-resume b…
docs: add HANDOFF.md for #1810 (Phase 1 done; Phase 2+ plan and file/…
docs(binding-mcp): record Phase 2 async constraint + verified relocat…
docs(binding-mcp): make HANDOFF fresh-start ready for Phase 2 (#1810)
docs(binding-mcp): confirm Phase 2 per-route + per-slice design (#1810)
docs(binding-mcp): reuse decoder states + streams in place, no new ab…
docs(binding-mcp): fold execution decisions + kickoff into handoff (#…
docs(handoff): #1810 phasing implications of OSS Path B (Track A rela…
docs(handoff): broaden #1810 + done-vs-needed audit; dual-ready bindi…
jfallows commentedon Jun 4, 2026
Broadening scope: support two per-toolkit authorization models behind one binding
After working through the proxy ↔ upstream authorization flows, there are two distinct models for completing per-toolkit authorization, and the
mcpbinding should support both so either can be configured with no binding fork. The phasing above already covers the gateway-managed model; this broadens the issue to add the relay model and reconcile the phases. The difference between the models is purely who is the authorization authority and where the token lives — a deployment/config choice, not a code fork.Model A — relay (upstream is the authorization authority)
The upstream MCP server itself originates the URL elicitation; the proxy relays it to the client verbatim and stays out of the OAuth callback path. The upstream binds the authorization to its own session (
Mcp-Session-Id). The proxy's responsibilities are narrow:state/redirect_uri) so the callback reaches the upstream directly and the upstream can correlate it via its ownstate.Mcp-Session-Id+MCP-Protocol-Versionon every subsequent request, resuming on reconnect.Once the client authorizes (out-of-band, directly with the upstream), the re-issued request on the same session is authorized. No proxy-side token storage; recovery is the standard "auth-required → authorize → retry" pattern. This scales to multiple authenticated upstreams cleanly: each route is isolated (own lifecycle, own
Mcp-Session-Id, own elicitation), and because each callback goes direct to its upstream, concurrent elicitations self-correlate with no shared proxy state.Model B — gateway-managed (proxy drives OAuth via the Guard SPI)
Exactly the existing design (§4–§7):
preauthorize → elicitation → callback → reauthorize, tokens stored per(identity, route)behind the guard, callback handled by Zilla. Unchanged.Both share the MCP surface the binding already owns (elicitation emission/relay, capability negotiation,
list_changed, resumable streams). Landing both models' binding-level support together means either example can be built on the merged binding with no further binding work. The initial example demonstrates Model A (relay), building onexamples/mcp.proxy(#1793).Phase reconciliation (done / still-needed / new)
Done & still required: 1 (
resource_metadata), 2/2e (hydrater split + cache infra), 3 (cache listing credential), 4 (protocol +elicitation.url), 5 (guardpreauthorize → reauthorize, incl. inbound-identity reuse — which is also the linchpin that makes the "authorize → re-issue" retry succeed), 6 (timeout+ hold-and-resume — see note), 9 (guard-flow ITs).Phase 7 splits:
tools/listreturning authorized tools immediately + relaying each unauthorized upstream'selicitation/createverbatim + relaying the upstream's nativelist_changed. Nostaterewriting; proxy out of the callback path.stateper toolkit on the way up, strip + route on the callback back, originatelist_changedonreauthorize. Required so a callback routes to the correct toolkit when the list stream is non-blocking (no held-stream correlation available).New items (relay model critical path):
redirect_uri/staterewritten. (manipulateElicitUrlbecomes origin-conditional — today it rewrites unconditionally.)Mcp-Session-Id+MCP-Protocol-Version; resume on reconnect (Last-Event-Id). Optionally store-backed for durability.examples/mcp.proxyexample demonstrating elicitation + authorization-guarded list/call via the relay model, scaling to multiple authenticated upstreams.Phase 8 (per-client listing filter, §3) unchanged; not required by the initial example — per-identity listing falls out of live per-session listing when no cache credential is configured.
Note on phase 6
With the "authorize → re-issue" retry pattern available to both models, the hold-and-resume path (
timeout>0) is additive UX (the held request resumes automatically, with no client re-issue round-trip) rather than strictly required. We keep it by design;timeout==0/-32042remains the portable default and the hold is the opt-in enhancement. Nothing already implemented needs to be removed.Generated by Claude Code
docs(handoff): keep P6 hold-and-resume by design (additive UX); record …
docs(handoff): split N3 example out of #1810; Phase 7 is the remainin…
docs(handoff): record #1810 tracking decision — status deltas go in P…
test(binding-mcp): pin Phase 7a contract — non-blocking partial-auth …
feat(binding-mcp): open proxy lifecycle on partial auth, relay elicit…
tools/listfiltering by per-tool authorization metadata #1831[-]binding-mcp: per-toolkit `oauth` for `mcp` proxy[/-][+]binding-mcp: per-toolkit elicitation for `mcp` proxy[/+]docs(handoff): record converged 7b context-field design + session sta…
feat(binding-mcp): per-toolkit elicitation for the mcp proxy (#1810) (#…
feat(metrics-mcp): add mcp metrics group with per-method counters and…
Add MCP metrics support with counters and histograms (#1837)
feat(binding-mcp): SEP-1036 url-mode elicitation passthrough + sessio…
feat(binding-mcp): SEP-1036 url-mode elicitation (passthrough + broke…
test(binding-mcp): enable tools/call URL-mode elicit context IT
test(binding-mcp): enable tools/call URL-mode elicit context IT
test(binding-mcp): enable tools/call URL-mode elicit context IT (#1883)