---
title: "Kitesurf WebMCP Migration Fix Log: document.modelContext Cutover"
slug: "kitesurf-webmcp-migration-fix-log"
description: "Staff-engineer migration notes for Cloudflare Kitesurf WebMCP cutover: document.modelContext, CDP flags, pricing table, cold-start math, and container"
author: "Hamdi Soudani"
category: "cloud-gpu-infra"
archetype: "migration-fix-log"
published_at: "2026-12-06T08:05:21.372+00:00"
updated_at: "2026-12-06T08:05:21.560917+00:00"
canonical_url: "https://pyvren.com/blog/kitesurf-webmcp-migration-fix-log"
reading_time_minutes: 4
word_count: 803
quality_score: 87
tags: ["kitesurf","webmcp","cloudflare","migration","document-modelcontext"]
keywords: ["kitesurf webmcp migration","document.modelcontext cloudflare","webmcp fix log","kitesurf rendering fixes","cloudflare kitesurf cdp webmcp"]
sources: ["https://developers.cloudflare.com/changelog/post/2026-09-28-webmcp-api/","https://developers.cloudflare.com/changelog/post/2026-12-04-kitesurf-updates/","https://developers.cloudflare.com/workers/platform/pricing/","https://developers.cloudflare.com/r2/pricing/","https://daily.dev/posts/cloudflare-s-kitesurf-browser-adds-webmcp-support-and-expands-web-api-coverage-opt6f62n4"]
---

# Kitesurf WebMCP Migration Fix Log: document.modelContext Cutover

> **TL;DR:** 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 Facts

- **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. ([source](https://developers.cloudflare.com/changelog/post/2026-12-04-kitesurf-updates/))
- **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. ([source](https://developers.cloudflare.com/changelog/post/2026-09-28-webmcp-api/))
- **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. ([source](https://developers.cloudflare.com/changelog/post/2026-09-28-webmcp-api/))
- **Workers paid plan pricing:** $5 per month includes 100,000 requests per day; beyond that, $0.30 per million requests. ([source](https://developers.cloudflare.com/workers/platform/pricing/))
- **D1 and R2 pricing:** D1 costs $0.75 per million rows read; R2 egress costs $0.00 per GB. ([source](https://developers.cloudflare.com/r2/pricing/))
- **Kitesurf WPT pass rate:** Kitesurf passes over 730,000 Web Platform Test subtests, up from about 230,000 at launch. ([source](https://daily.dev/posts/cloudflare-s-kitesurf-browser-adds-webmcp-support-and-expands-web-api-coverage-opt6f62n4))

## 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](https://daily.dev/posts/cloudflare-s-kitesurf-browser-adds-webmcp-support-and-expands-web-api-coverage-opt6f62n4).

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:

```bash
# 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:

```javascript
// 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` | Restart CDP client with correct flag |
| 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` | Pin previous Kitesurf release |

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](https://developers.cloudflare.com/changelog/post/2026-09-28-webmcp-api/)

[Kitesurf adds WebMCP updates, custom elements, and rendering improvements · Changelog](https://developers.cloudflare.com/changelog/post/2026-12-04-kitesurf-updates/)

## Frequently Asked Questions

### What breaks when migrating from navigator.modelContextTesting to document.modelContext?

Lab sessions no longer expose navigator.modelContextTesting. Both Kitesurf and Lab backends now use document.modelContext from the WebMCP Community Group draft. Agent code referencing navigator.modelContextTesting will fail; update to document.modelContext and use waitForToolsUntil() while pages register tools.

### Which CDP flag enables WebMCP tools for AI agents?

Start Chrome DevTools MCP with --category-experimental-webmcp. This adds list_webmcp_tools and execute_webmcp_tool to the MCP surface. CDP clients use the WebMCP CDP domain directly.

### At what request volume does a container beat Workers serverless for this workload?

Workers costs $5 per month plus $0.30 per million requests beyond the included 100,000 daily requests. At roughly 2 million requests per month, serverless costs about $600 per month before egress and storage. A small GPU-backed container at $0.04 per GPU-hour runs about $29 per month plus egress, so containers break even below that volume if your agent round-trips are long enough to keep the container busy.

### What rendering regressions did the December 4 Kitesurf update fix?

CSS filter and backdrop-filter, background-clip: text, -webkit-text-fill-color, text-shadow, :hover styles on pointer movement, responsive images using sizes and media conditions, CSS grid, corner-shape, clip-path, 3D transforms, and inline SVG fill and stroke are now more accurate.

## Primary Sources

- https://developers.cloudflare.com/changelog/post/2026-09-28-webmcp-api/
- https://developers.cloudflare.com/changelog/post/2026-12-04-kitesurf-updates/
- https://developers.cloudflare.com/workers/platform/pricing/
- https://developers.cloudflare.com/r2/pricing/
- https://daily.dev/posts/cloudflare-s-kitesurf-browser-adds-webmcp-support-and-expands-web-api-coverage-opt6f62n4
