History

Drop the MCP Durable Object from the SSR app graph (#1696)

app.ts imported McpSessionDOSqlite only to pass it through as mcpExport and re-export it. ExecutorApp.make documents mcpExport as passed back out untouched, its result cloudMcpExport has no consumers, and server.ts imports the DO class directly for Cloudflare's required export. So the import was dead weight that pulled the MCP DO stack and the QuickJS WASM into TanStack Start's loadEntries closure (9.22MB -> 8.58MB without it). No measured latency win: loadEntries cost does not track closure size, same as isolate startup. Kept as dead-code removal and because the SSR graph should not depend on the MCP session DO.

Rhys Sullivan committed 2 months ago

Commit 54cde5e1 parent cd9b9781 file · +2 −7Browse files

Unified · Split

apps/cloud/src/app.ts+2−7
@@ -13,7 +13,6 @@ import { ApiKeyService } from "./auth/api-keys"; · 12 unmodified lines
13import { cloudIdentityFailureStrategy, workosIdentityLayer } from "./auth/workos-auth-provider";13import { cloudIdentityFailureStrategy, workosIdentityLayer } from "./auth/workos-auth-provider";
14import { DbService } from "./db/db";14import { DbService } from "./db/db";
15import { cloudMcpAuth } from "./mcp";15import { cloudMcpAuth } from "./mcp";
16import { McpSessionDOSqlite } from "./mcp/session-durable-object";
17import { ErrorCaptureLive } from "./observability";16import { ErrorCaptureLive } from "./observability";
18import { AutumnService } from "./extensions/billing/service";17import { AutumnService } from "./extensions/billing/service";
19import {18import {
@@ -31,7 +30,7 @@ import { WorkerTelemetryLive } from "./observability/telemetry"; · 11 unmodified lines
31// The whole scenario in 60 seconds: WorkOS identity (api-key Bearer OR sealed-30// The whole scenario in 60 seconds: WorkOS identity (api-key Bearer OR sealed-
32// session cookie, api-key wins) over a per-request Hyperdrive→Postgres socket,31// session cookie, api-key wins) over a per-request Hyperdrive→Postgres socket,
33// the Cloudflare dynamic-worker code substrate, MCP served by a Durable-Object32// the Cloudflare dynamic-worker code substrate, MCP served by a Durable-Object
34// session store (the DO surfaced via `config.mcpExport`), console+Sentry error33// session store (the DO class is exported straight from server.ts), console+Sentry error
35// capture — and Autumn BILLING entering ONLY as extensions: the engine34// capture — and Autumn BILLING entering ONLY as extensions: the engine
36// metering decorator, the account seat-gate, the `/api/billing/*` proxy route,35// metering decorator, the account seat-gate, the `/api/billing/*` proxy route,
37// and the createOrganization free-limit gate. `diff` against36// and the createOrganization free-limit gate. `diff` against
@@ -66,7 +65,7 @@ const controlPlane = Layer.mergeAll(CoreSharedServices, apiKeyService); · 28 unmodified lines
66// satisfied by `boot`, `DbService` per request via `requestScoped`).65// satisfied by `boot`, `DbService` per request via `requestScoped`).
67const cloudDb: Layer.Layer<DbProvider, never, DbService | AutumnService> = CloudDbProvider;66const cloudDb: Layer.Layer<DbProvider, never, DbService | AutumnService> = CloudDbProvider;
68 67
69const { appLayer, toWebHandler, mcpExport } = ExecutorApp.make({68const { appLayer, toWebHandler } = ExecutorApp.make({
70 plugins: cloudPlugins,69 plugins: cloudPlugins,
71 providers: {70 providers: {
72 // Identity: the NEUTRAL `IdentityProvider`. WorkOS api-key Bearer BEATS71 // Identity: the NEUTRAL `IdentityProvider`. WorkOS api-key Bearer BEATS
@@ -112,7 +111,6 @@ const { appLayer, toWebHandler, mcpExport } = ExecutorApp.make({ · 39 unmodified lines
112 failure: cloudIdentityFailureStrategy,111 failure: cloudIdentityFailureStrategy,
113 // The MCP session Durable Object class — a top-level Workers export a Layer112 // The MCP session Durable Object class — a top-level Workers export a Layer
114 // can't return; surfaced so `server.ts` can re-export it.113 // can't return; surfaced so `server.ts` can re-export it.
115 mcpExport: McpSessionDOSqlite,
116 },114 },
117 // The long-lived (boot-scoped) context provideMerge'd under everything: the115 // The long-lived (boot-scoped) context provideMerge'd under everything: the
118 // WorkOS control plane (the raw `WorkOSClient` + `ApiKeyService` the per-request116 // WorkOS control plane (the raw `WorkOSClient` + `ApiKeyService` the per-request
@@ -135,10 +133,7 @@ const { appLayer, toWebHandler, mcpExport } = ExecutorApp.make({ · 16 unmodified lines
135 requestScoped: RequestScopedServicesLive,133 requestScoped: RequestScopedServicesLive,
136});134});
137 135
138export { McpSessionDOSqlite };
139
140export const CloudAppLayer = appLayer;136export const CloudAppLayer = appLayer;
141export const cloudMcpExport = mcpExport;
142 137
143// The unified cloud web handler: serves /api/* (incl. /api/billing/*, /api/docs),138// The unified cloud web handler: serves /api/* (incl. /api/billing/*, /api/docs),
144// /mcp, /.well-known/* — everything the worker dispatches.139// /mcp, /.well-known/* — everything the worker dispatches.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t