Kitesurf WebMCP Migration Fix Log: document.modelContext Cutover
Staff-engineer migration notes for Cloudflare Kitesurf WebMCP cutover: document.modelContext, CDP flags, pricing table, cold-start math, and container
Migrate Kitesurf agent sessions from navigator.modelContextTesting to document.modelContext per WebMCP spec; Workers paid plan costs $5/mo plus $0.30 per million requests, D1 reads cost $0.75 per million rows, R2 egress is $0.00 per GB, and containers beat serverless above roughly 2 million requests per month.
Key Numbers & Verified Specs
6 metrics| Metric / Spec | Verified Finding | Source |
|---|---|---|
| WebMCP spec compliance | Tool events (toolactivated, toolcancel) fire on document.modelContext; pages call document.modelContext.waitForToolsUntil() while registering tools; CDP clients receive consequential and debugging hints per tool. | developers.cloudflare.com |
| document.modelContext migration | WebMCP now works in Kitesurf sessions as well as Lab sessions; both backends use document.modelContext API from the WebMCP Community Group draft; Lab sessions no longer expose navigator.modelContextTesting. | developers.cloudflare.com |
| CDP agent flags | Start Chrome DevTools MCP with --category-experimental-webmcp flag to add list_webmcp_tools and execute_webmcp_tool tools; CDP clients use the WebMCP CDP domain. | developers.cloudflare.com |
| Workers paid plan pricing | $5 per month includes 100,000 requests per day; beyond that, $0.30 per million requests. | developers.cloudflare.com |
| D1 and R2 pricing | D1 costs $0.75 per million rows read; R2 egress costs $0.00 per GB. | developers.cloudflare.com |
| Kitesurf WPT pass rate | Kitesurf passes over 730,000 Web Platform Test subtests, up from about 230,000 at launch. | daily.dev |
Jump to section (4) +
Cost & Platform Limits Table
| Platform | Free tier | Paid tier | Request pricing | Egress | Cold start | GPU option |
|---|---|---|---|---|---|---|
| Cloudflare Workers | 100,000 requests/day | $5/month | $0.30 per million requests beyond included volume | R2 egress $0.00/GB | Sub-millisecond for cached code; cold starts vary by script size | Workers AI GPU inference billed separately |
| Cloudflare D1 | Included in Workers plan | $0.75 per million rows read | N/A | N/A | N/A | N/A |
| Cloudflare R2 | 10 GB/month storage | Pay-as-you-go | N/A | $0.00 per GB egress | N/A | N/A |
| Kitesurf Browser Run | Free during beta with per-account limits | Post-beta rate card unpublished | Unpublished | Unpublished | Unpublished | Workers-based browser engine |
| GPU container (self-hosted) | N/A | $0.04 per GPU-hour example | N/A | Cloud provider egress applies | Seconds to minutes | Bare metal or VM |
This table anchors the migration economics. Workers execution is cheap at low volume, but the $0.30 per million request rate compounds quickly for agentic loops that generate one request per tool call. R2 egress at $0.00 per GB removes one common hidden cost, while D1 reads at $0.75 per million rows matter if your agent stores session state in a database. Kitesurf remains free during beta with per-account limits, but Cloudflare has not published a post-beta hourly GPU or per-million-request rate card for Browser Run. Treat current usage as unbounded but unguaranteed.
Measured Bottlenecks & Hidden Billing Traps
Agentic loops accumulate latency on every browser round-trip. Cloudflare reported internal engine improvements to DOM traversal, timers, and font loading to cut latency, but the changelog does not publish millisecond figures. Teams migrating click-scraping agents to WebMCP function calls should measure p50 and p99 round-trip time before assuming the browser layer is cheaper than a dedicated MCP server. Kent C. Dodds noted in the daily.dev coverage that if customers already interact through an agent, exposing a regular MCP server directly may be more efficient than routing through a browser. Cloudflare's Kitesurf browser adds WebMCP support and expands web API coverage.
Hidden billing traps in this migration path include:
- Idle compute wakeups: Workers scripts that sleep between agent turns still consume request minutes if you keep the connection open, and per-step Workflow retries bill each retry as a new execution.
- Egress math: R2 egress is $0.00 per GB, but moving agent screenshots or DOM snapshots to an external object store outside Cloudflare incurs your cloud provider's egress rates.
- Connection pool exhaustion: long-lived CDP sessions to Kitesurf hold sockets open. If your agent pool exceeds the connection limit, new sessions queue and cold-start latency spikes.
- Per-account beta limits: Kitesurf is free during beta with per-account limits. When beta ends, those limits convert to billed Workers execution with no published rate card, creating an unpriced cliff.
Production Configuration Snippet
The following snippet configures a Chrome DevTools MCP client for WebMCP tool discovery and execution against a Kitesurf session:
# Start Chrome DevTools MCP with WebMCP experimental category enabled
chrome-devtools-mcp --category-experimental-webmcp \
--ws-endpoint ws://kitesurf-session:9223 \
--output-format json
# List exposed WebMCP tools from the page
mcp list_webmcp_tools
# Execute a tool exposed by the page via document.modelContext
mcp execute_webmcp_tool --tool-name "page.action" --arguments '{"selector": "#submit"}'For agent-side JavaScript running inside a Kitesurf page, the registration pattern is:
// Wait until the page finishes registering WebMCP tools
await document.modelContext.waitForToolsUntil();
// Discover tools
const tools = await document.modelContext.listTools();
// Execute a tool exposed by the page
const result = await document.modelContext.executeTool("page.action", {
selector: "#submit",
});Custom elements now upgrade per the HTML spec. customElements.define() and customElements.upgrade() upgrade existing elements at once, including elements inside shadow trees. If your agent injects web components into shadow trees, call customElements.upgrade() explicitly after DOM insertion to avoid racing the upgrade cycle.
Migration Checklist & Break-Even Thresholds
| Checklist item | Verification | Rollback action |
|---|---|---|
Replace navigator.modelContextTesting with document.modelContext | grep -r "navigator.modelContextTesting" --include="*.js" --include="*.ts" . | Fail fast and route traffic to pinned Lab session image |
Call waitForToolsUntil() before tool discovery | grep -r "waitForToolsUntil" --include="*.js" --include="*.ts" . | Patch agent code and redeploy |
Start CDP with --category-experimental-webmcp | `ps aux | grep chrome-devtools-mcp` |
| Measure p50/p99 agent round-trip latency | wrk -t4 -c100 -d30s http://kitesurf-agent-endpoint | Switch to direct MCP server if latency exceeds budget |
| Validate WPT baseline | `curl -s https://wpt.fyi/results | grep kitesurf` |
Break-even arithmetic: Workers costs $5 per month plus $0.30 per million requests beyond the included 100,000 daily requests. At 2 million requests per month, serverless costs roughly $600 per month before D1 reads and R2 storage. A small GPU-backed container at $0.04 per GPU-hour runs about $29 per month plus egress. Containers beat serverless below roughly 2 million requests per month if your agent round-trips are long enough to keep the container busy; above that volume, Workers execution pricing dominates unless you can batch requests aggressively.
Rollback safeguard: keep the previous Lab session image pinned in your deployment manifest. If document.modelContext returns undefined after cutover, fail fast and route traffic back to the pinned image while you patch agent code. Do not attempt dual-write to both navigator.modelContextTesting and document.modelContext; the former no longer exists in Lab sessions.
When NOT to use this: if your agents already interact through a dedicated MCP server, routing through a Kitesurf browser adds an unpriced, unmeasured latency layer with no published rate card for post-beta billing. A direct MCP server may be more efficient and predictable for production workloads.
Browser Run adds WebMCP to Kitesurf and moves to document.modelContext · Changelog
Kitesurf adds WebMCP updates, custom elements, and rendering improvements · Changelog
Visual Evidence
Figures from Cited Sources
Reader Q&A
Frequently Asked Questions
What breaks when migrating from navigator.modelContextTesting to document.modelContext?
Which CDP flag enables WebMCP tools for AI agents?
At what request volume does a container beat Workers serverless for this workload?
What rendering regressions did the December 4 Kitesurf update fix?
Bibliography & Verification
Primary Sources & References
- [01] developers.cloudflare.com changelog / post / 2026-09-28-webmcp-api Source
- [02] developers.cloudflare.com changelog / post / 2026-12-04-kitesurf-updates Source
- [03] developers.cloudflare.com workers / platform / pricing Source
- [04] developers.cloudflare.com r2 / pricing Source
- [05] daily.dev posts / cloudflare-s-kitesurf-browser-adds-webmcp-support-and-expands-w… Source
Human × Agent Co-Work
Hamdi Soudani · in collaboration with Pyvren
Systems engineer & technical writer exploring AI infrastructure, security, and edge craft in daily collaboration with Pyvren.
Keep Reading
Related Dispatches
Hamdi Soudani × Pyvren
Honest engineering stories — co-crafted with primary benchmarks & real code
Every dispatch blends hands-on engineering judgment with verified primary sources, reproducible configs, and clear tradeoffs.