codemode: add durable MCP elicitation approvals example#1954
Draft
mattzcarey wants to merge 1 commit into
Draft
Conversation
|
agents
@cloudflare/ai-chat
@cloudflare/codemode
create-think
hono-agents
@cloudflare/shell
@cloudflare/think
@cloudflare/voice
@cloudflare/worker-bundler
commit: |
mattzcarey
force-pushed
the
feat/codemode-mcp-elicitation-approval-example
branch
from
July 21, 2026 15:01
700e0df to
291e804
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
Agent, persistentWorkerTransport, andcreateMcpHandlersearch({ code })for read-only Portal catalog discovery andexecute({ code })for durable operation executionportal.<operation>()methods from one dynamicPortalConnector, with collision and reserved-name checksrequiresApprovalpauses into form-mode MCP elicitation, then approve/replay or reject without exposing a model-callable approval toolruntime.tool().execute({ code }, undefined)API for both tools; this PR contains no Codemode package or SDK changesThe framework-neutral
runtime.execute(),runtime.search(), andruntime.describe()convenience APIs have moved to the independent #1969.Search and execute isolation
searchexposes onlyportal.tools()from the Portal connector. It returns JavaScript-safe names, raw upstream names, schemas, and approval policy, and removes completed searches from the durable audit history.executeexposes callableportal.<operation>()methods but notportal.tools().codemoderemains reserved for runtime primitives.Approval flow
elicitation/createon the originatingtools/callstream.runtime.approve()and resumes through abort-and-replay; decline or cancel callsruntime.reject().The demo policy allows listing and commenting while requiring approval to create issues or merge requests.
Validation
pnpm install --frozen-lockfile— passedpnpm --filter @cloudflare/agents-codemode-mcp-approvals-example test— 13 passedpnpm --filter @cloudflare/codemode test— 376 passedpnpm run build— 25 projects passedpnpm run check— exports, format, lint, and all 118 TypeScript projects passedpnpm exec nx affected -t test --base=origin/main --parallel=1— 20 affected projects passedpnpm --dir examples/codemode-mcp-approvals exec wrangler deploy --dry-run --outdir /tmp/codemode-mcp-approvals-dry-run— bundled successfully