Draft
Conversation
When the execute tool hits a 403 from the Cloudflare API, instead of returning a generic error, we now create an ElicitationAgent (Durable Object) that serves a scope picker UI matching the Cloudflare design system. The user can upgrade their permissions without a full re-auth: - HTTP status propagation from sandbox worker errors (httpStatus field) - ElicitationAgent renders scope picker with current scopes pre-checked - Scope templates (read-only, workers-full, dns-full) + individual checkboxes - POST /upgrade redirects through Cloudflare OAuth with new scopes - /oauth/callback detects scope_upgrade state, stores upgraded token in KV - Execute handler checks KV for upgraded tokens before each API call - Supports MCP URL elicitation for capable clients, falls back to tool error URL
8ae3f6c to
4475054
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
executetool hits a 403 from the Cloudflare API, creates an ElicitationAgent (Durable Object via Agents SDK) that serves a scope picker UIexecutecallsHow it works
executetool catches 403 →elicitUpdatedScopes()creates ElicitationAgent with error context + current scopes/oauth/callbackdetectsscope_upgradestate → exchanges code → stores upgraded token inOAUTH_KVastoken-upgrade:{tokenHash}executecall →getUpgradedToken()finds the upgrade in KV → uses the new token transparentlyChanges
src/elicitation-agent.tssrc/server.tselicitUpdatedScopes()passes scopes/tokenHash/userId to agent; execute handler checks KV for upgradessrc/auth/oauth-handler.ts/oauth/callbackhandlesscope_upgradeflowsrc/auth/types.tsscopes?: string[]toUserAuthPropssrc/executor.tshttpStatusfield)src/index.ts/elicitation/:id[/action]to DOwrangler.jsoncworker-configuration.d.tsELICITATION_AGENTbinding typesrc/tests/jit-auth.test.tsTest plan
npm run typecheckpassesnpm test— 92 tests passstaging.mcp.cloudflare.com)execute→ elicitation URL returned