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/host-selfhost/src (6 of 91 files). Show all

Unified · Split

6 files
  1. apps/host-selfhost/src/app.ts +2 −12
  2. apps/host-selfhost/src/config.ts +0 −3
  3. apps/host-selfhost/src/mcp/index.ts +2 −11
  4. apps/host-selfhost/src/mcp/mcp.test.ts +0 −35
  5. apps/host-selfhost/src/mcp/session-store.ts +3 −21
  6. apps/host-selfhost/src/testing/test-app.ts +0 −2
apps/host-selfhost/src/app.ts+2−12
@@ -78,12 +78,7 @@ export const makeSelfHostApp = async (options: MakeSelfHostAppOptions = {}) => { · 77 unmodified lines
7878 // ---- the in-process MCP serving seams (+ shutdown hook) ----------------
7979 // Pass the pinned public origin so browser-approval URLs are reachable behind
8080 // a reverse proxy (not the internal 127.0.0.1 bind from the request URL).
81− const mcp = makeSelfHostMcpSeams(
82− dbHandle,
83− betterAuth,
84− config.webBaseUrl,
85− config.mcp20260728Enabled,
86− );
81+ const mcp = makeSelfHostMcpSeams(dbHandle, betterAuth, config.webBaseUrl);
8782
8883 // CLI device-login discovery (`executor login`). Points the CLI at Better
8984 // Auth's device endpoints; `requestFormat: "json"` because those endpoints
@@ -115,12 +110,7 @@ export const makeSelfHostApp = async (options: MakeSelfHostAppOptions = {}) => { · 25 unmodified lines
115110 // plane's decorator is wired in mcp/session-store.ts's stack layer).
116111 decorator: SelfHostAnalyticsEngineDecorator,
117112 },
118− mcp: {
119− auth: mcp.auth,
120− sessions: mcp.sessions,
121− modern: mcp.modern,
122− reporter: mcp.reporter,
123− },
113+ mcp: { auth: mcp.auth, sessions: mcp.sessions, reporter: mcp.reporter },
124114 plugins: { provider: SelfHostPluginsProvider, config: SelfHostHostConfig },
125115 errorCapture: ErrorCaptureLive,
126116 },
apps/host-selfhost/src/config.ts+0−3
@@ -32,8 +32,6 @@ export interface SelfHostConfig { · 31 unmodified lines
3232 * internal network unless an operator opts in.
3333 */
3434 readonly allowLocalNetwork: boolean;
35− /** Emergency rollback for inbound MCP 2026-07-28 traffic only. */
36− readonly mcp20260728Enabled: boolean;
3735 // Better Auth session secret. Always resolved (env, else generated + persisted
3836 // under the data dir) so a single-container deploy boots with no env; the auth
3937 // layer still validates an explicitly-set env secret is long enough.
@@ -152,7 +150,6 @@ export const loadConfig = (): SelfHostConfig => { · 112 unmodified lines
152150 dbPath: process.env.EXECUTOR_DB_PATH ?? join(dataDir, "data.db"),
153151 webBaseUrl: resolveWebBaseUrl(port),
154152 allowLocalNetwork: process.env.EXECUTOR_ALLOW_LOCAL_NETWORK === "true",
155− mcp20260728Enabled: process.env.MCP_2026_07_28_ENABLED !== "false",
156153 authSecret: resolveAuthSecret(),
157154 bootstrapAdminEmail: process.env.EXECUTOR_BOOTSTRAP_ADMIN_EMAIL,
158155 bootstrapAdminPassword: process.env.EXECUTOR_BOOTSTRAP_ADMIN_PASSWORD,
apps/host-selfhost/src/mcp/index.ts+2−11
@@ -4,7 +4,6 @@ import { IdentityProvider } from "@executor-js/api/server"; · 3 unmodified lines
44 import type {
55 McpAuthProvider,
66 McpErrorReporter,
7− McpModernServerBuilder,
87 McpSessionStore,
98 Principal,
109 } from "@executor-js/host-mcp";
@@ -14,7 +13,6 @@ import type { SelfHostDbHandle } from "../db/self-host-db"; · 3 unmodified lines
1413 import { selfHostMcpAuth } from "./auth";
1514 import {
1615 makeSelfHostMcpSessionStore,
17− makeSelfHostMcpModernServerBuilder,
1816 selfHostMcpReporter,
1917 selfHostMcpSessions,
2018 } from "./session-store";
@@ -22,7 +20,6 @@ import { · 1 unmodified line
2220 export { selfHostMcpAuth } from "./auth";
2321 export {
2422 makeSelfHostMcpSessionStore,
25− makeSelfHostMcpModernServerBuilder,
2623 selfHostMcpReporter,
2724 selfHostMcpSessions,
2825 McpEngineBuildError,
@@ -37,15 +34,13 @@ export { · 8 unmodified lines
3734 // own auth + session handling and is mounted OUTSIDE the API's execution
3835 // middleware, like /api/auth.
3936 //
40−// Self-host provides both era seams plus auth and an error-reporter override:
37+// Self-host provides the TWO envelope seams plus an error-reporter override:
4138 // - McpAuthProvider -> `selfHostMcpAuth` (Better Auth mcp() OAuth). It still
4239 // requires `IdentityProvider`, which `make` provides from
4340 // the resolved identity seam.
4441 // - McpSessionStore -> `selfHostMcpSessions`: in-process Map. The store owns
4542 // dispatch (create + forward + ownership) and builds its
4643 // engine internally over the shared SelfHostDb.
47−// - McpModernServerBuilder -> one stateless MCP server per request over
48−// the same scoped execution stack and tool config.
4944 // - McpErrorReporter -> `selfHostMcpReporter`: route 500 defects through the
5045 // host's console capture.
5146 //
@@ -58,8 +53,6 @@ export interface SelfHostMcpSeams { · 6 unmodified lines
5853 readonly auth: Layer.Layer<McpAuthProvider, never, IdentityProvider>;
5954 /** The in-process session store seam (dispatch + lifetime). */
6055 readonly sessions: Layer.Layer<McpSessionStore>;
61− /** Stateless MCP server construction for modern requests. */
62− readonly modern: Layer.Layer<McpModernServerBuilder>;
6356 /** Route 500 defects through the host's console `ErrorCapture`. */
6457 readonly reporter: Layer.Layer<McpErrorReporter>;
6558 /**
@@ -133,14 +126,13 @@ const makeApprovalHandler = · 67 unmodified lines
133126 * Build the self-host MCP serving seams over the long-lived DB handle. The auth
134127 * seam is `selfHostMcpAuth` (Better Auth mcp() OAuth), with the Better Auth
135128 * instance provided; it still requires `IdentityProvider` from the resolved
136− * identity seam. Returns the four seam Layers plus the `close()` lifetime hook
129+ * identity seam. Returns the three seam Layers plus the `close()` lifetime hook
137130 * the app wires into shutdown.
138131 */
139132 export const makeSelfHostMcpSeams = (
140133 dbHandle: SelfHostDbHandle,
141134 betterAuth: BetterAuthHandle,
142135 webBaseUrl?: string,
143− modernEnabled = true,
144136 ): SelfHostMcpSeams => {
145137 const sessionStore = makeSelfHostMcpSessionStore(dbHandle, webBaseUrl);
146138 const auth: Layer.Layer<McpAuthProvider, never, IdentityProvider> = selfHostMcpAuth.pipe(
@@ -149,7 +141,6 @@ export const makeSelfHostMcpSeams = ( · 2 unmodified lines
149141 return {
150142 auth,
151143 sessions: selfHostMcpSessions(sessionStore),
152− modern: makeSelfHostMcpModernServerBuilder(dbHandle, modernEnabled),
153144 reporter: selfHostMcpReporter,
154145 approvalHandler: makeApprovalHandler(sessionStore, betterAuth),
155146 close: sessionStore.close,
apps/host-selfhost/src/mcp/mcp.test.ts+0−35
@@ -3,7 +3,6 @@ import { tmpdir } from "node:os"; · 2 unmodified lines
33 import { join } from "node:path";
44
55 import { afterAll, expect, test } from "@effect/vitest";
6−import { Client, StreamableHTTPClientTransport } from "@modelcontextprotocol/client";
76
87 import { mintInviteCode } from "../testing/mint-invite";
98
@@ -88,40 +87,6 @@ test("an authenticated MCP client initializes, lists tools, and executes code", · 78 unmodified lines
8887 expect(JSON.stringify(await call.json())).toContain("42");
8988 });
9089
91−test("an authenticated modern MCP client discovers, lists tools, and executes code", async () => {
92− const token = await signUp("modern@mcp.test");
93− const seenMethods: string[] = [];
94− const transport = new StreamableHTTPClientTransport(new URL(`${BASE}/mcp`), {
95− fetch: async (input, init) => {
96− const request =
97− input instanceof Request ? new Request(input, init) : new Request(input.toString(), init);
98− const body = (await request.clone().json()) as { readonly method?: string };
99− if (body.method) seenMethods.push(body.method);
100− const headers = new Headers(request.headers);
101− headers.set("authorization", `Bearer ${token}`);
102− return handler(new Request(request, { headers }));
103− },
104− });
105− const client = new Client(
106− { name: "selfhost-modern-test", version: "1.0.0" },
107− { capabilities: {}, versionNegotiation: { mode: { pin: "2026-07-28" } } },
108− );
109−
110− await client.connect(transport);
111− // oxlint-disable-next-line executor/no-try-catch-or-throw -- test boundary: always close the authenticated modern client
112− try {
113− expect(seenMethods).toContain("server/discover");
114− expect((await client.listTools()).tools.map(({ name }) => name)).toContain("execute");
115− const result = await client.callTool({
116− name: "execute",
117− arguments: { code: "export default 6 * 7" },
118− });
119− expect(JSON.stringify(result)).toContain("42");
120− } finally {
121− await client.close();
122− }
123−});
124−
12590 test("an MCP session cannot be reused by another user, and unauth is rejected", async () => {
12691 const alice = await signUp("alice2@mcp.test");
12792 const bob = await signUp("bob2@mcp.test");
apps/host-selfhost/src/mcp/session-store.ts+3−21
@@ -1,7 +1,7 @@
11 import { Layer } from "effect";
22
33 import { makeConsoleMcpErrorReporter, makeMcpBuildServer } from "@executor-js/api/server";
4−import { McpModernServerBuilder, type McpErrorReporter } from "@executor-js/host-mcp";
4+import type { McpErrorReporter } from "@executor-js/host-mcp";
55 import {
66 inMemoryMcpSessionsLayer,
77 makeInMemoryMcpSessionStore,
@@ -19,8 +19,8 @@ import { SelfHostExecutionStackLayer } from "../execution"; · 11 unmodified lines
1919 // ALL shared (`@executor-js/host-mcp/in-memory-session-store` + `makeMcpBuildServer`
2020 // / `makeConsoleMcpErrorReporter` in `@executor-js/api/server`). Self-host
2121 // supplies only its fully-provided execution-stack layer (QuickJS over the
22−// long-lived `SelfHostDb`) and its `ErrorCapture`; the builder creates the
23−// connection-lifetime assembly used by the shared store.
22+// long-lived `SelfHostDb`) and its `ErrorCapture`. The Cloudflare host wires the
23+// identical seam with its own stack layer.
2424 // ---------------------------------------------------------------------------
2525
2626 import { loadMcpAppsShellHtml } from "@executor-js/mcp-apps-shell";
@@ -51,24 +51,6 @@ export const makeSelfHostMcpSessionStore = ( · 24 unmodified lines
5151 { webBaseUrl },
5252 );
5353
54−/** Build the stateless MCP server seam over the same self-host stack/config. */
55−export const makeSelfHostMcpModernServerBuilder = (
56− db: SelfHostDbHandle,
57− enabled = true,
58−): Layer.Layer<McpModernServerBuilder> =>
59− Layer.succeed(McpModernServerBuilder)({
60− enabled,
61− build: makeMcpBuildServer(
62− SelfHostExecutionStackLayer.pipe(Layer.provide(Layer.succeed(SelfHostDb)(db))),
63− {
64− loadAppShellHtml: loadMcpAppsShellHtml,
65− smokeRenderArtifact,
66− onArtifactUsage: (action) =>
67− selfHostAnalytics.record(`artifact_${action}`, { via: "agent" }),
68− },
69− ),
70− });
71−
7254 /** The `McpSessionStore` envelope seam over a freshly built in-process store. */
7355 export const selfHostMcpSessions = inMemoryMcpSessionsLayer;
7456
apps/host-selfhost/src/testing/test-app.ts+0−2
@@ -28,7 +28,6 @@ import { · 27 unmodified lines
2828 import executorConfig from "../../executor.config";
2929 import { loadConfig, SELF_HOST_NAMESPACE, SELF_HOST_SCHEMA_VERSION } from "../config";
3030 import {
31− makeSelfHostMcpModernServerBuilder,
3231 makeSelfHostMcpSessionStore,
3332 selfHostMcpReporter,
3433 selfHostMcpSessions,
@@ -237,7 +236,6 @@ export const makeSelfHostTestApp = async ( · 202 unmodified lines
237236 mcp: {
238237 auth: stubMcpAuth,
239238 sessions: selfHostMcpSessions(sessionStore),
240− modern: makeSelfHostMcpModernServerBuilder(dbHandle),
241239 reporter: selfHostMcpReporter,
242240 },
243241 plugins: { provider: pluginsProvider, config: SelfHostHostConfig },

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