Skip to content

Commit 0672e20

Browse files
committed
fix(cloud): back the MCP session Durable Object with SQLite
The MCP session DO now extends the Cloudflare Agents `McpAgent` base, which stores its state in SQLite. apps/cloud still had the original `McpSessionDO` class on the key-value backend (`new_classes`), and Cloudflare cannot convert a live class to SQLite in place, so every session 500'd with "This Durable Object is not backed by SQLite storage". Session state is ephemeral, so delete the old KV class and create a new SQLite-backed class (`McpSessionDOSqlite`) in migration v2, repointing the `MCP_SESSION` binding. The DO is addressed by binding + idFromName, so the rename is transparent at runtime. host-cloudflare was already on `new_sqlite_classes`, so only cloud was affected.
1 parent 5d3648d commit 0672e20

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

apps/cloud/src/server.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ const sentryOptions = (env: Env) => ({
4141
// not a global fetch wrapper.
4242
// ---------------------------------------------------------------------------
4343

44-
export const McpSessionDO = Sentry.instrumentDurableObjectWithSentry(
44+
// Exported under `McpSessionDOSqlite` (not `McpSessionDO`) to match the SQLite
45+
// class migration in wrangler.jsonc: the Agents (`McpAgent`) base needs a
46+
// SQLite-backed DO, and the original KV-backed `McpSessionDO` class cannot be
47+
// converted in place, so it is deleted and replaced by this new class.
48+
export const McpSessionDOSqlite = Sentry.instrumentDurableObjectWithSentry(
4549
sentryOptions,
4650
McpSessionDOBase,
4751
);

apps/cloud/wrangler.jsonc

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,27 @@
2020
"bindings": [
2121
{
2222
"name": "MCP_SESSION",
23-
"class_name": "McpSessionDO",
23+
"class_name": "McpSessionDOSqlite",
2424
},
2525
],
2626
},
27+
// The MCP session DO moved to the Cloudflare Agents (`McpAgent`) base, which
28+
// stores its state in SQLite. The original `McpSessionDO` class was deployed
29+
// with the key-value backend (`new_classes`), and Cloudflare cannot convert a
30+
// live class to SQLite in place. Session state is ephemeral, so v2 deletes the
31+
// old KV class and creates a new SQLite-backed class under a new name; the
32+
// `MCP_SESSION` binding repoints to it. The DO is addressed by binding +
33+
// `idFromName`, so the class rename is transparent at runtime.
2734
"migrations": [
2835
{
2936
"tag": "v1",
3037
"new_classes": ["McpSessionDO"],
3138
},
39+
{
40+
"tag": "v2",
41+
"deleted_classes": ["McpSessionDO"],
42+
"new_sqlite_classes": ["McpSessionDOSqlite"],
43+
},
3244
],
3345
"services": [
3446
{

0 commit comments

Comments
 (0)