feat(mcp): landing-pages AI toolset, async image uploads, and platform-aligned tool metadata - #113
Merged
Merged
Conversation
- CodLandingPageImageUploadWorkflow: background upload for MCP agents — URL-fetch (retried, size-capped, magic-byte-verified) and direct-R2-bytes entry paths, idempotent record insert, fail-open dimension parsing, audited landing_page_images row with source "ai" - dependency-free image sniffing/dimension parsing (png/jpeg/gif/webp) - shared minting rules for upload ids and R2 keys (landing-image-upload lib) - addLandingPageImage gains optional provenance (upload | ai) - getLandingPageById batched to two D1 round trips; opt-in list pagination (limit/offset) surfaced on the REST route; wrangler binding + env wiring
- uploadLandingPageImage: chat clients pass conversation images via the OpenAI file-object contract (openai/fileParams) or a public URL; programmatic clients via base64 — enqueues the background workflow and returns a polling job id - getLandingPageImageUploadStatus: polls the workflow instance and maps every state to a model-readable status view - stack + lifecycle tools: remove (R2 last-reference guard), reorder, duplicate, unpublish, archive - strict layer-2 validation on every tool (unknown fields rejected, never stripped); publish warns on an empty image stack; existence checks fix false-success on publish/update paths; STOREFRONT_URL fallback parity with REST; tool descriptions written for model consumption - REST list route gains validated limit/offset
Every ai-tools domain exports an output-schema map built from a shared success/failure envelope; the MCP surface advertises outputSchema on every registered tool and validates each result's structuredContent against it (drift logs loudly and falls back to the text result, never failing a working tool). Payload fields documented for model consumption; DB-row passthroughs declare guaranteed identity fields only.
- ToolAnnotations derived from the platform's own classifications (read scopes => readOnlyHint, DANGEROUS_TOOLS => destructiveHint) with consistency tests; human-readable titles on all 96 tools - per-subject tool-call rate limit (fixed window in RATE_LIMIT KV, fail-open) keyed by the client's openai/subject hint; client hints (subject/session) join the audit trail — correlation only, never authorization - removed the server-side two-round confirmation gate: per the platform docs, write-action approval is the client's job, framed by our destructiveHint annotations; the server gates by scope, validates, rate-limits, and audits (confirm-tool + MCP_REQUEST_STATE_KEY removed) - consent page redesign: real brand wordmark (light/dark), grouped permission chips with localized domain/action labels (ar/fr/en), account identity line, dark mode, RTL — all client-controlled values escaped - audit redaction for oversized string arguments
… BETA badge Landing page Studio uploads now request folder=landing on presign (they were landing in products/); the AI agents MCP nav item is no longer marked beta.
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
Extends the MCP surface so an AI client (ChatGPT, Claude, etc.) can build a complete landing page end-to-end — create the page, pass generated images into the image stack through a durable background workflow, poll until stored, arrange the stack, and publish — and aligns every tool's advertised metadata with the current MCP + OpenAI plugin requirements.
What's included
Landing pages toolset (7 new tools)
uploadLandingPageImage— accepts conversation images via the OpenAI file-object contract (openai/fileParams), a public http(s) URL, or base64 from programmatic clients; validates content by magic-byte sniffing, enforces an 8 MB cap, and enqueues a background workflowgetLandingPageImageUploadStatus— polls the upload workflow and maps every instance state to a model-readable status viewremoveLandingPageImage(shared-R2-object last-reference guard),reorderLandingPageImages,duplicateLandingPage,unpublishLandingPage,archiveLandingPageDurable upload workflow
CodLandingPageImageUploadWorkflow(Cloudflare Workflows): retried URL fetch with capped streaming read, content-type verification against served bytes, fail-open intrinsic-dimension parsing, idempotent record insert, auditedlanding_page_imagesrow withsource: "ai"Output contracts on all 96 tools
outputSchemais advertised on every tool and every result carries validatedstructuredContent(drift logs loudly and degrades to the text result)Platform-aligned tool metadata
ToolAnnotationsderived from the platform's own classifications (read-scope gating →readOnlyHint, dangerous-tool set →destructiveHint) with machine-checked consistency testsopenai/fileParamsandopenai/toolInvocationstatus text on the upload toolRATE_LIMITKV, fail-open) keyed by the client'sopenai/subjecthint; client hints join the audit trail as correlation-only fieldsConfirmation model
destructiveHintannotations; the server gates by OAuth scope, validates inputs, rate-limits, and writes the audit trail (confirm-toolandMCP_REQUEST_STATE_KEYremoved)Tooling fixes
STOREFRONT_URLfallback parity with REST, bounded default pagination on listlanding/R2 namespace; removed the BETA badge from the AI agents nav itemTest plan
astro checkclean)Notes
landing_page_images.sourcealready anticipated"ai"; no new production dependenciesDANGEROUS_TOOLSis retained as the risk classification feeding annotations; it no longer gates executionLP_IMAGE_UPLOAD_WORKFLOWbinding (example template updated; deploy-time config is gitignored per repo policy)