History

Revert the outbound MCP SDK v2 migration (#1697)

* Revert the outbound MCP SDK v2 migration * Drop the v2 MCP packages from the lockfile

Rhys Sullivan committed 2 months ago

Commit a5800a11 parent 54cde5e91 files · +5838 −10032Browse files

Showing the changes to apps/cloud/src/server.ts (1 of 91 files). Show all

Unified · Split

apps/cloud/src/server.ts+10−9
@@ -17,10 +17,7 @@ import { passthroughResponse } from "./edge/passthrough"; · 16 unmodified lines
1717 import { makeCloudMcpAgentHandler } from "./mcp/agent-handler";
1818 import { classifyMcpPath, prepareMcpOrgScope } from "./mcp/mount";
1919 import { parseTraceparent } from "./mcp/traceparent";
20−import {
21− makeCloudModernMcpServerBuilder,
22− McpSessionDOSqlite as McpSessionDOBase,
23−} from "./mcp/session-durable-object";
20+import { McpSessionDOSqlite as McpSessionDOBase } from "./mcp/session-durable-object";
2421 import {
2522 beforeSendWithOtelCorrelation,
2623 captureCause,
@@ -187,10 +184,7 @@ const traceCloudMcpRequest = async ( · 160 unmodified lines
187184 );
188185 };
189186
190−const mcpAgentHandler = makeCloudMcpAgentHandler({
191− makeModernServerBuilder: makeCloudModernMcpServerBuilder,
192− traceRequest: traceCloudMcpRequest,
193−});
187+const mcpAgentHandler = makeCloudMcpAgentHandler();
194188
195189 // ---------------------------------------------------------------------------
196190 // Isolate lifecycle signals
@@ -264,7 +258,14 @@ const cloudflareHandler: ExportedHandler<Env> = { · 67 unmodified lines
264258 // to pass authenticated session props into the hibernatable DO.
265259 // Discovery docs still flow through the app-level MCP envelope.
266260 const forwarded = prepareMcpOrgScope(request);
267− return mcpAgentHandler(forwarded, env, ctx);
261+ // /mcp leaves the Effect app for the Agents bridge, so no downstream
262+ // HttpMiddleware.tracer opens the request envelope — this worker span is
263+ // THE `http.server` span for MCP traffic, and its context is stamped onto
264+ // the forwarded traceparent so the agent handler and session DO parent
265+ // under it instead of exporting orphaned roots.
266+ return traceCloudMcpRequest(forwarded, env, ctx, (tracedRequest) =>
267+ Promise.resolve(mcpAgentHandler(tracedRequest, env, ctx)),
268+ );
268269 }
269270 const tracingInstalled = installTracerProvider();
270271 // Join the caller's W3C trace when the request carries one — the web UI