Skip to content

fix(cloud): repoint MCP DO binding to new SQLite class (unbreaks main deploy)#1191

Merged
RhysSullivan merged 1 commit into
mainfrom
fix-cloud-do-sqlite-final
Jun 28, 2026
Merged

fix(cloud): repoint MCP DO binding to new SQLite class (unbreaks main deploy)#1191
RhysSullivan merged 1 commit into
mainfrom
fix-cloud-do-sqlite-final

Conversation

@RhysSullivan

Copy link
Copy Markdown
Owner

Why

The previous fix attempt (merged) deletes McpSessionDO but the MCP_SESSION binding still referenced it, so the non-versioned main deploy failed:

Cannot apply --delete-class migration to class 'McpSessionDO' without also removing the binding that references it. [code: 10061]

main currently fails to deploy. Prod is still on the rolled-back (working KV) version.

Fix

Use a new SQLite class name and move the binding to it first, so the old KV class is unreferenced and can be deleted (Cloudflare's documented KV→SQLite path):

  • rename the concrete DO class + every reference → McpSessionDOSqlite
  • MCP_SESSION binding → McpSessionDOSqlite
  • migration v2: deleted_classes: ["McpSessionDO"] + new_sqlite_classes: ["McpSessionDOSqlite"]

Verified locally (the part CI can't check)

The built worker exports McpSessionDOSqlite ×5 and McpSessionDO ×0 — the deleted class is no longer exported and nothing binds it, which is exactly what error 10061 required. typecheck + lint clean.

Deploy note

The PR Workers Build will still red with code 10211 ("migrations must be applied via a non-versioned deployment") — that's inherent to PR preview builds and not a real failure. The main build is non-versioned (it got to applying the migration last time), so merging applies the migration. Migration state is v1 (the prior attempt failed atomically), so v2 applies cleanly on merge.

…f the deleted KV class

CF rejects deleting McpSessionDO while MCP_SESSION still binds it (code 10061),
and won't reuse a deleted class name. Rename the concrete class + all refs to
McpSessionDOSqlite, repoint the binding, and have v2 delete the old KV McpSessionDO
+ create the new SQLite class. Verified the built worker exports McpSessionDOSqlite
and nothing named McpSessionDO.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 28, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
executor-cloud 7fca096 Jun 28 2026, 09:52 PM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 28, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
executor-marketing 7fca096 Commit Preview URL

Branch Preview URL
Jun 28 2026, 09:52 PM

@greptile-apps

greptile-apps Bot commented Jun 28, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes a broken main deploy caused by a Cloudflare error 10061 — the previous migration attempt deleted McpSessionDO while the MCP_SESSION DO binding still referenced it. The fix follows Cloudflare's documented KV→SQLite migration path by introducing a new class name (McpSessionDOSqlite), moving the binding to it, and deleting the old class in the same migration step.

  • McpSessionDO is renamed to McpSessionDOSqlite across all TypeScript source files (session-durable-object.ts, app.ts, agent-handler.ts, server.ts), and span names inside the DO are updated to match.
  • wrangler.jsonc collapses the previous two-step v2/v3 migration into a single v2 that simultaneously runs deleted_classes: ["McpSessionDO"] and new_sqlite_classes: ["McpSessionDOSqlite"], with the MCP_SESSION binding already pointing at the new class name so no binding references the deleted class during apply.

Confidence Score: 5/5

Safe to merge — all changes are consistent renames with no logic alterations, and the migration correctly leaves no binding referencing the deleted class.

Every TypeScript file that previously imported or exported McpSessionDO has been updated to McpSessionDOSqlite. The wrangler binding, the Sentry wrapper export, the .serve() call, and the mcpExport config all agree on the new name. The v2 migration atomically deletes the old KV class (now unreferenced) and creates the new SQLite class in a single step, which is the pattern Cloudflare requires for this scenario. Session state is intentionally ephemeral so there is no data-loss concern.

No files require special attention — the rename is mechanical and complete across all five changed files.

Important Files Changed

Filename Overview
apps/cloud/wrangler.jsonc Binding repointed to McpSessionDOSqlite and v2/v3 migrations collapsed into a single v2 that deletes the old KV class and creates the new SQLite class atomically; approach matches Cloudflare's documented migration path.
apps/cloud/src/mcp/session-durable-object.ts Class renamed from McpSessionDO to McpSessionDOSqlite; span names updated to match; no logic changes.
apps/cloud/src/server.ts DO export renamed from McpSessionDO to McpSessionDOSqlite; Sentry instrumentation wrapper updated consistently.
apps/cloud/src/app.ts Import, mcpExport config, and named export all updated to McpSessionDOSqlite; no logic changes.
apps/cloud/src/mcp/agent-handler.ts Import and .serve() call updated to McpSessionDOSqlite; MCP_SESSION binding string unchanged, correctly matching the wrangler binding name.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant CF as Cloudflare
    participant W as Worker (server.ts)
    participant AH as agent-handler.ts
    participant DO as McpSessionDOSqlite (SQLite)

    Note over CF: wrangler deploy (main, non-versioned)<br/>Migration v2 applies atomically:<br/>deleted_classes: [McpSessionDO]<br/>new_sqlite_classes: [McpSessionDOSqlite]

    CF->>W: fetch /mcp/...
    W->>AH: mcpAgentHandler(request, env, ctx)
    AH->>AH: "McpSessionDOSqlite.serve("/mcp", { binding: "MCP_SESSION" })"
    AH->>CF: env.MCP_SESSION (→ McpSessionDOSqlite namespace)
    CF->>DO: stub.fetch(request)
    DO-->>W: Response
    W-->>CF: Response
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant CF as Cloudflare
    participant W as Worker (server.ts)
    participant AH as agent-handler.ts
    participant DO as McpSessionDOSqlite (SQLite)

    Note over CF: wrangler deploy (main, non-versioned)<br/>Migration v2 applies atomically:<br/>deleted_classes: [McpSessionDO]<br/>new_sqlite_classes: [McpSessionDOSqlite]

    CF->>W: fetch /mcp/...
    W->>AH: mcpAgentHandler(request, env, ctx)
    AH->>AH: "McpSessionDOSqlite.serve("/mcp", { binding: "MCP_SESSION" })"
    AH->>CF: env.MCP_SESSION (→ McpSessionDOSqlite namespace)
    CF->>DO: stub.fetch(request)
    DO-->>W: Response
    W-->>CF: Response
Loading

Reviews (1): Last reviewed commit: "fix(cloud): use a new SQLite DO class na..." | Re-trigger Greptile

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Cloudflare preview

Torn down — the PR is closed.

@pkg-pr-new

pkg-pr-new Bot commented Jun 28, 2026

Copy link
Copy Markdown

Open in StackBlitz

@executor-js/cli

npm i https://pkg.pr.new/@executor-js/cli@1191

@executor-js/config

npm i https://pkg.pr.new/@executor-js/config@1191

@executor-js/execution

npm i https://pkg.pr.new/@executor-js/execution@1191

@executor-js/sdk

npm i https://pkg.pr.new/@executor-js/sdk@1191

@executor-js/codemode-core

npm i https://pkg.pr.new/@executor-js/codemode-core@1191

@executor-js/runtime-quickjs

npm i https://pkg.pr.new/@executor-js/runtime-quickjs@1191

@executor-js/plugin-file-secrets

npm i https://pkg.pr.new/@executor-js/plugin-file-secrets@1191

@executor-js/plugin-graphql

npm i https://pkg.pr.new/@executor-js/plugin-graphql@1191

@executor-js/plugin-keychain

npm i https://pkg.pr.new/@executor-js/plugin-keychain@1191

@executor-js/plugin-mcp

npm i https://pkg.pr.new/@executor-js/plugin-mcp@1191

@executor-js/plugin-onepassword

npm i https://pkg.pr.new/@executor-js/plugin-onepassword@1191

@executor-js/plugin-openapi

npm i https://pkg.pr.new/@executor-js/plugin-openapi@1191

executor

npm i https://pkg.pr.new/executor@1191

commit: 7fca096

@RhysSullivan RhysSullivan merged commit 83a8c44 into main Jun 28, 2026
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant