Skip to content

Commit 484768c

Browse files
Fix sandbox proxy ready detection in simple-host example (#47)
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 <[email protected]>
1 parent 5e78a1e commit 484768c

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

examples/simple-host/src/app-host-utils.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { McpUiSandboxProxyReadyNotificationSchema } from "@modelcontextprotocol/ext-apps";
1+
import type { McpUiSandboxProxyReadyNotification } from "@modelcontextprotocol/ext-apps";
22
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
33
import { Tool } from "@modelcontextprotocol/sdk/types.js";
44

@@ -8,6 +8,9 @@ export async function setupSandboxProxyIframe(sandboxProxyUrl: URL): Promise<{
88
iframe: HTMLIFrameElement;
99
onReady: Promise<void>;
1010
}> {
11+
const SANDBOX_PROXY_READY_METHOD: McpUiSandboxProxyReadyNotification["method"] =
12+
"ui/notifications/sandbox-proxy-ready";
13+
1114
const iframe = document.createElement("iframe");
1215
iframe.style.width = "100%";
1316
iframe.style.height = "600px";
@@ -18,11 +21,7 @@ export async function setupSandboxProxyIframe(sandboxProxyUrl: URL): Promise<{
1821
const onReady = new Promise<void>((resolve, _reject) => {
1922
const initialListener = async (event: MessageEvent) => {
2023
if (event.source === iframe.contentWindow) {
21-
if (
22-
event.data &&
23-
event.data.method ===
24-
McpUiSandboxProxyReadyNotificationSchema.shape.method._def.value
25-
) {
24+
if (event.data && event.data.method === SANDBOX_PROXY_READY_METHOD) {
2625
window.removeEventListener("message", initialListener);
2726
resolve();
2827
}

0 commit comments

Comments
 (0)