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
1313 import { cloudIdentityFailureStrategy, workosIdentityLayer } from "./auth/workos-auth-provider";
1414 import { DbService } from "./db/db";
1515 import { cloudMcpAuth } from "./mcp";
16−import { McpSessionDOSqlite } from "./mcp/session-durable-object";
1716 import { ErrorCaptureLive } from "./observability";
1817 import { AutumnService } from "./extensions/billing/service";
1918 import {
@@ -31,7 +30,7 @@ import { WorkerTelemetryLive } from "./observability/telemetry"; · 11 unmodified lines
3130 // The whole scenario in 60 seconds: WorkOS identity (api-key Bearer OR sealed-
3231 // session cookie, api-key wins) over a per-request Hyperdrive→Postgres socket,
3332 // the Cloudflare dynamic-worker code substrate, MCP served by a Durable-Object
34−// session store (the DO surfaced via `config.mcpExport`), console+Sentry error
33+// session store (the DO class is exported straight from server.ts), console+Sentry error
3534 // capture — and Autumn BILLING entering ONLY as extensions: the engine
3635 // metering decorator, the account seat-gate, the `/api/billing/*` proxy route,
3736 // and the createOrganization free-limit gate. `diff` against
@@ -66,7 +65,7 @@ const controlPlane = Layer.mergeAll(CoreSharedServices, apiKeyService); · 28 unmodified lines
6665 // satisfied by `boot`, `DbService` per request via `requestScoped`).
6766 const cloudDb: Layer.Layer<DbProvider, never, DbService | AutumnService> = CloudDbProvider;
6867
69−const { appLayer, toWebHandler, mcpExport } = ExecutorApp.make({
68+const { appLayer, toWebHandler } = ExecutorApp.make({
7069 plugins: cloudPlugins,
7170 providers: {
7271 // Identity: the NEUTRAL `IdentityProvider`. WorkOS api-key Bearer BEATS
@@ -112,7 +111,6 @@ const { appLayer, toWebHandler, mcpExport } = ExecutorApp.make({ · 39 unmodified lines
112111 failure: cloudIdentityFailureStrategy,
113112 // The MCP session Durable Object class — a top-level Workers export a Layer
114113 // can't return; surfaced so `server.ts` can re-export it.
115− mcpExport: McpSessionDOSqlite,
116114 },
117115 // The long-lived (boot-scoped) context provideMerge'd under everything: the
118116 // WorkOS control plane (the raw `WorkOSClient` + `ApiKeyService` the per-request
@@ -135,10 +133,7 @@ const { appLayer, toWebHandler, mcpExport } = ExecutorApp.make({ · 16 unmodified lines
135133 requestScoped: RequestScopedServicesLive,
136134 });
137135
138−export { McpSessionDOSqlite };
139−
140136 export const CloudAppLayer = appLayer;
141−export const cloudMcpExport = mcpExport;
142137
143138 // The unified cloud web handler: serves /api/* (incl. /api/billing/*, /api/docs),
144139 // /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