Skip to content

fix(server,client): use the cf-worker validator on Node when code generation is disallowed - #2941

Open
mertcanaltin wants to merge 1 commit into
modelcontextprotocol:mainfrom
mertcanaltin:node-codegen-fallback
Open

mertcanaltin wants to merge 1 commit into
modelcontextprotocol:mainfrom
mertcanaltin:node-codegen-fallback

Conversation

@mertcanaltin

Copy link
Copy Markdown

When Node runs with --disallow-code-generation-from-strings, the server crashes on startup with an EvalError, because the node shim always picks Ajv and Ajv uses new Function. The workerd and browser shims already use the cf-worker validator, so I made the node shim fall back to it when new Function isn't allowed. Nothing changes for normal Node. Added tests for both packages and checked it with the real flag.

@mertcanaltin
mertcanaltin requested a review from a team as a code owner October 2, 2026 19:21
@changeset-bot

changeset-bot Bot commented Oct 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5eacc18

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@modelcontextprotocol/server Patch
@modelcontextprotocol/client Patch
@modelcontextprotocol/codemod Patch
@modelcontextprotocol/core Patch
@modelcontextprotocol/server-legacy Patch
@modelcontextprotocol/core-internal Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Oct 2, 2026

Copy link
Copy Markdown

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/@modelcontextprotocol/client@2941

@modelcontextprotocol/codemod

npm i https://pkg.pr.new/@modelcontextprotocol/codemod@2941

@modelcontextprotocol/core

npm i https://pkg.pr.new/@modelcontextprotocol/core@2941

@modelcontextprotocol/server

npm i https://pkg.pr.new/@modelcontextprotocol/server@2941

@modelcontextprotocol/server-legacy

npm i https://pkg.pr.new/@modelcontextprotocol/server-legacy@2941

@modelcontextprotocol/express

npm i https://pkg.pr.new/@modelcontextprotocol/express@2941

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/@modelcontextprotocol/fastify@2941

@modelcontextprotocol/hono

npm i https://pkg.pr.new/@modelcontextprotocol/hono@2941

@modelcontextprotocol/node

npm i https://pkg.pr.new/@modelcontextprotocol/node@2941

commit: 5eacc18

@claude claude Bot added the v2 Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes label Oct 3, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2 Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant