* Revert the outbound MCP SDK v2 migration * Drop the v2 MCP packages from the lockfile
Showing the changes to apps/host-selfhost/src (6 of 91 files). Show all
Unified · Split
| @@ -78,12 +78,7 @@ export const makeSelfHostApp = async (options: MakeSelfHostAppOptions = {}) => { · 77 unmodified lines | ||
| 78 | 78 | // ---- the in-process MCP serving seams (+ shutdown hook) ---------------- |
| 79 | 79 | // Pass the pinned public origin so browser-approval URLs are reachable behind |
| 80 | 80 | // 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); | |
| 87 | 82 | |
| 88 | 83 | // CLI device-login discovery (`executor login`). Points the CLI at Better |
| 89 | 84 | // Auth's device endpoints; `requestFormat: "json"` because those endpoints |
| @@ -115,12 +110,7 @@ export const makeSelfHostApp = async (options: MakeSelfHostAppOptions = {}) => { · 25 unmodified lines | ||
| 115 | 110 | // plane's decorator is wired in mcp/session-store.ts's stack layer). |
| 116 | 111 | decorator: SelfHostAnalyticsEngineDecorator, |
| 117 | 112 | }, |
| 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 }, | |
| 124 | 114 | plugins: { provider: SelfHostPluginsProvider, config: SelfHostHostConfig }, |
| 125 | 115 | errorCapture: ErrorCaptureLive, |
| 126 | 116 | }, |
| @@ -32,8 +32,6 @@ export interface SelfHostConfig { · 31 unmodified lines | ||
| 32 | 32 | * internal network unless an operator opts in. |
| 33 | 33 | */ |
| 34 | 34 | readonly allowLocalNetwork: boolean; |
| 35 | − /** Emergency rollback for inbound MCP 2026-07-28 traffic only. */ | |
| 36 | − readonly mcp20260728Enabled: boolean; | |
| 37 | 35 | // Better Auth session secret. Always resolved (env, else generated + persisted |
| 38 | 36 | // under the data dir) so a single-container deploy boots with no env; the auth |
| 39 | 37 | // layer still validates an explicitly-set env secret is long enough. |
| @@ -152,7 +150,6 @@ export const loadConfig = (): SelfHostConfig => { · 112 unmodified lines | ||
| 152 | 150 | dbPath: process.env.EXECUTOR_DB_PATH ?? join(dataDir, "data.db"), |
| 153 | 151 | webBaseUrl: resolveWebBaseUrl(port), |
| 154 | 152 | allowLocalNetwork: process.env.EXECUTOR_ALLOW_LOCAL_NETWORK === "true", |
| 155 | − mcp20260728Enabled: process.env.MCP_2026_07_28_ENABLED !== "false", | |
| 156 | 153 | authSecret: resolveAuthSecret(), |
| 157 | 154 | bootstrapAdminEmail: process.env.EXECUTOR_BOOTSTRAP_ADMIN_EMAIL, |
| 158 | 155 | bootstrapAdminPassword: process.env.EXECUTOR_BOOTSTRAP_ADMIN_PASSWORD, |
| @@ -4,7 +4,6 @@ import { IdentityProvider } from "@executor-js/api/server"; · 3 unmodified lines | ||
| 4 | 4 | import type { |
| 5 | 5 | McpAuthProvider, |
| 6 | 6 | McpErrorReporter, |
| 7 | − McpModernServerBuilder, | |
| 8 | 7 | McpSessionStore, |
| 9 | 8 | Principal, |
| 10 | 9 | } from "@executor-js/host-mcp"; |
| @@ -14,7 +13,6 @@ import type { SelfHostDbHandle } from "../db/self-host-db"; · 3 unmodified lines | ||
| 14 | 13 | import { selfHostMcpAuth } from "./auth"; |
| 15 | 14 | import { |
| 16 | 15 | makeSelfHostMcpSessionStore, |
| 17 | − makeSelfHostMcpModernServerBuilder, | |
| 18 | 16 | selfHostMcpReporter, |
| 19 | 17 | selfHostMcpSessions, |
| 20 | 18 | } from "./session-store"; |
| @@ -22,7 +20,6 @@ import { · 1 unmodified line | ||
| 22 | 20 | export { selfHostMcpAuth } from "./auth"; |
| 23 | 21 | export { |
| 24 | 22 | makeSelfHostMcpSessionStore, |
| 25 | − makeSelfHostMcpModernServerBuilder, | |
| 26 | 23 | selfHostMcpReporter, |
| 27 | 24 | selfHostMcpSessions, |
| 28 | 25 | McpEngineBuildError, |
| @@ -37,15 +34,13 @@ export { · 8 unmodified lines | ||
| 37 | 34 | // own auth + session handling and is mounted OUTSIDE the API's execution |
| 38 | 35 | // middleware, like /api/auth. |
| 39 | 36 | // |
| 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: | |
| 41 | 38 | // - McpAuthProvider -> `selfHostMcpAuth` (Better Auth mcp() OAuth). It still |
| 42 | 39 | // requires `IdentityProvider`, which `make` provides from |
| 43 | 40 | // the resolved identity seam. |
| 44 | 41 | // - McpSessionStore -> `selfHostMcpSessions`: in-process Map. The store owns |
| 45 | 42 | // dispatch (create + forward + ownership) and builds its |
| 46 | 43 | // engine internally over the shared SelfHostDb. |
| 47 | −// - McpModernServerBuilder -> one stateless MCP server per request over | |
| 48 | −// the same scoped execution stack and tool config. | |
| 49 | 44 | // - McpErrorReporter -> `selfHostMcpReporter`: route 500 defects through the |
| 50 | 45 | // host's console capture. |
| 51 | 46 | // |
| @@ -58,8 +53,6 @@ export interface SelfHostMcpSeams { · 6 unmodified lines | ||
| 58 | 53 | readonly auth: Layer.Layer<McpAuthProvider, never, IdentityProvider>; |
| 59 | 54 | /** The in-process session store seam (dispatch + lifetime). */ |
| 60 | 55 | readonly sessions: Layer.Layer<McpSessionStore>; |
| 61 | − /** Stateless MCP server construction for modern requests. */ | |
| 62 | − readonly modern: Layer.Layer<McpModernServerBuilder>; | |
| 63 | 56 | /** Route 500 defects through the host's console `ErrorCapture`. */ |
| 64 | 57 | readonly reporter: Layer.Layer<McpErrorReporter>; |
| 65 | 58 | /** |
| @@ -133,14 +126,13 @@ const makeApprovalHandler = · 67 unmodified lines | ||
| 133 | 126 | * Build the self-host MCP serving seams over the long-lived DB handle. The auth |
| 134 | 127 | * seam is `selfHostMcpAuth` (Better Auth mcp() OAuth), with the Better Auth |
| 135 | 128 | * 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 | |
| 137 | 130 | * the app wires into shutdown. |
| 138 | 131 | */ |
| 139 | 132 | export const makeSelfHostMcpSeams = ( |
| 140 | 133 | dbHandle: SelfHostDbHandle, |
| 141 | 134 | betterAuth: BetterAuthHandle, |
| 142 | 135 | webBaseUrl?: string, |
| 143 | − modernEnabled = true, | |
| 144 | 136 | ): SelfHostMcpSeams => { |
| 145 | 137 | const sessionStore = makeSelfHostMcpSessionStore(dbHandle, webBaseUrl); |
| 146 | 138 | const auth: Layer.Layer<McpAuthProvider, never, IdentityProvider> = selfHostMcpAuth.pipe( |
| @@ -149,7 +141,6 @@ export const makeSelfHostMcpSeams = ( · 2 unmodified lines | ||
| 149 | 141 | return { |
| 150 | 142 | auth, |
| 151 | 143 | sessions: selfHostMcpSessions(sessionStore), |
| 152 | − modern: makeSelfHostMcpModernServerBuilder(dbHandle, modernEnabled), | |
| 153 | 144 | reporter: selfHostMcpReporter, |
| 154 | 145 | approvalHandler: makeApprovalHandler(sessionStore, betterAuth), |
| 155 | 146 | close: sessionStore.close, |
| @@ -3,7 +3,6 @@ import { tmpdir } from "node:os"; · 2 unmodified lines | ||
| 3 | 3 | import { join } from "node:path"; |
| 4 | 4 | |
| 5 | 5 | import { afterAll, expect, test } from "@effect/vitest"; |
| 6 | −import { Client, StreamableHTTPClientTransport } from "@modelcontextprotocol/client"; | |
| 7 | 6 | |
| 8 | 7 | import { mintInviteCode } from "../testing/mint-invite"; |
| 9 | 8 | |
| @@ -88,40 +87,6 @@ test("an authenticated MCP client initializes, lists tools, and executes code", · 78 unmodified lines | ||
| 88 | 87 | expect(JSON.stringify(await call.json())).toContain("42"); |
| 89 | 88 | }); |
| 90 | 89 | |
| 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 | − | |
| 125 | 90 | test("an MCP session cannot be reused by another user, and unauth is rejected", async () => { |
| 126 | 91 | const alice = await signUp("alice2@mcp.test"); |
| 127 | 92 | const bob = await signUp("bob2@mcp.test"); |
| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | import { Layer } from "effect"; |
| 2 | 2 | |
| 3 | 3 | 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"; | |
| 5 | 5 | import { |
| 6 | 6 | inMemoryMcpSessionsLayer, |
| 7 | 7 | makeInMemoryMcpSessionStore, |
| @@ -19,8 +19,8 @@ import { SelfHostExecutionStackLayer } from "../execution"; · 11 unmodified lines | ||
| 19 | 19 | // ALL shared (`@executor-js/host-mcp/in-memory-session-store` + `makeMcpBuildServer` |
| 20 | 20 | // / `makeConsoleMcpErrorReporter` in `@executor-js/api/server`). Self-host |
| 21 | 21 | // 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. | |
| 24 | 24 | // --------------------------------------------------------------------------- |
| 25 | 25 | |
| 26 | 26 | import { loadMcpAppsShellHtml } from "@executor-js/mcp-apps-shell"; |
| @@ -51,24 +51,6 @@ export const makeSelfHostMcpSessionStore = ( · 24 unmodified lines | ||
| 51 | 51 | { webBaseUrl }, |
| 52 | 52 | ); |
| 53 | 53 | |
| 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 | − | |
| 72 | 54 | /** The `McpSessionStore` envelope seam over a freshly built in-process store. */ |
| 73 | 55 | export const selfHostMcpSessions = inMemoryMcpSessionsLayer; |
| 74 | 56 | |
| @@ -28,7 +28,6 @@ import { · 27 unmodified lines | ||
| 28 | 28 | import executorConfig from "../../executor.config"; |
| 29 | 29 | import { loadConfig, SELF_HOST_NAMESPACE, SELF_HOST_SCHEMA_VERSION } from "../config"; |
| 30 | 30 | import { |
| 31 | − makeSelfHostMcpModernServerBuilder, | |
| 32 | 31 | makeSelfHostMcpSessionStore, |
| 33 | 32 | selfHostMcpReporter, |
| 34 | 33 | selfHostMcpSessions, |
| @@ -237,7 +236,6 @@ export const makeSelfHostTestApp = async ( · 202 unmodified lines | ||
| 237 | 236 | mcp: { |
| 238 | 237 | auth: stubMcpAuth, |
| 239 | 238 | sessions: selfHostMcpSessions(sessionStore), |
| 240 | − modern: makeSelfHostMcpModernServerBuilder(dbHandle), | |
| 241 | 239 | reporter: selfHostMcpReporter, |
| 242 | 240 | }, |
| 243 | 241 | plugins: { provider: pluginsProvider, config: SelfHostHostConfig }, |