From 484768c3d10672e4c37da26488e47fde62b7c4b3 Mon Sep 17 00:00:00 2001 From: Jonathan Hefner Date: Mon, 1 Dec 2025 14:07:40 -0600 Subject: [PATCH] Fix sandbox proxy ready detection in simple-host example (#47) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace Zod schema's internal _def.value access with a direct string literal. The previous approach failed due to multiple Zod instances being bundled, causing schema.shape.method._def.value to return undefined. The fix uses a typed string constant that provides compile-time safety via McpUiSandboxProxyReadyNotification["method"] while avoiding runtime dependency on Zod internals. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude --- examples/simple-host/src/app-host-utils.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/simple-host/src/app-host-utils.ts b/examples/simple-host/src/app-host-utils.ts index a13701d..bf8dd40 100644 --- a/examples/simple-host/src/app-host-utils.ts +++ b/examples/simple-host/src/app-host-utils.ts @@ -1,4 +1,4 @@ -import { McpUiSandboxProxyReadyNotificationSchema } from "@modelcontextprotocol/ext-apps"; +import type { McpUiSandboxProxyReadyNotification } from "@modelcontextprotocol/ext-apps"; import { Client } from "@modelcontextprotocol/sdk/client/index.js"; import { Tool } from "@modelcontextprotocol/sdk/types.js"; @@ -8,6 +8,9 @@ export async function setupSandboxProxyIframe(sandboxProxyUrl: URL): Promise<{ iframe: HTMLIFrameElement; onReady: Promise; }> { + const SANDBOX_PROXY_READY_METHOD: McpUiSandboxProxyReadyNotification["method"] = + "ui/notifications/sandbox-proxy-ready"; + const iframe = document.createElement("iframe"); iframe.style.width = "100%"; iframe.style.height = "600px"; @@ -18,11 +21,7 @@ export async function setupSandboxProxyIframe(sandboxProxyUrl: URL): Promise<{ const onReady = new Promise((resolve, _reject) => { const initialListener = async (event: MessageEvent) => { if (event.source === iframe.contentWindow) { - if ( - event.data && - event.data.method === - McpUiSandboxProxyReadyNotificationSchema.shape.method._def.value - ) { + if (event.data && event.data.method === SANDBOX_PROXY_READY_METHOD) { window.removeEventListener("message", initialListener); resolve(); }