Skip to content

Commit 95c7568

Browse files
committed
fix: disable Zod JIT in App so Views run under strict CSP
Zod v4's object parser compiles a fast path with new Function(), which violates script-src CSP without unsafe-eval. Hosts that enforce the spec's default CSP (e.g. VS Code) cannot load any View that parses an incoming message. Set z.config({ jitless: true }) at the top of the App entry so the interpreter path is used instead. Applies to every View bundle, not just map-server. Addresses #374. Relevant to #199.
1 parent 01d826a commit 95c7568

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/app.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ import {
6060
McpUiRequestDisplayModeResultSchema,
6161
} from "./types";
6262
import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
63+
import { z } from "zod/v4";
64+
65+
// Disable Zod's JIT compiler (which uses `new Function()`) so Views can run
66+
// under a strict CSP without `unsafe-eval`. See #374, #199, zod#4461.
67+
z.config({ jitless: true });
6368

6469
export { PostMessageTransport } from "./message-transport";
6570
export * from "./types";

0 commit comments

Comments
 (0)