modelcontextprotocol / modelcontextprotocol/ext-apps

unsafe-eval warning is thrown from AJV via @modelcontextprotocol/sdk dependency

Open
#652 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
2.9k
Forks
387
Avg merge
3h 21m
Merged PRs (30d)
6

Description

Describe the bug

This is a similar issue as #618 , except the warning is thrown from from AJV instead of Zod . It uses the new Function() constructor which is equivalent to eval .

https://github.com/ajv-validator/ajv/blob/f177fe323420ccb23e1a79445fd470cbf80aee7c/lib/compile/index.ts#L171

The @modelcontextprotocol/sdk@1.29.0 dependency uses AJV 8 (ajv@^8.17.1) to validate JSON schemas at runtime. AJV 8 generates validator functions by calling new Function() (equivalent to eval)

This throws an error when running MCP apps in MCP app hosts that implements CSP policies, including Goose 1.33.1 and Cursor Version: 3.2.16 (Universal)

Unfortunately unlike Zod, there isn't a runtime flag for disabling the constructor, so removing this warning log is more involved.

To Reproduce

  1. Open any app that uses the ext-apps SDK @1.7.1, and check the developer tools, there will be a warning
Image

Expected behavior

Importing the ext-apps wouldn't introduce unsafe-eval warnings

Additional context

It's possible this issue could be opened in typescript-sdk too, but this might be a better fit since typescript-sdk can be used client-side and need not avoid unsafe-eval warnings, whereas MCP apps are meant to run in environments with security guardrails in place.

https://github.com/modelcontextprotocol/typescript-sdk/issues?q=is%3Aissue%20state%3Aclosed%20unsafe-eval

Potential fix

AJV allows compiling a function that will validate the schema in advance, see https://github.com/ajv-validator/ajv/issues/406 / https://ajv.js.org/security.html#content-security-policy

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the ext-apps SDK import path and the AJV 8 validation path described in the issue, including AJV's linked lib/compile/index.ts reference. Review the linked AJV CSP guidance and issue #406. Done means importing ext-apps no longer emits unsafe-eval warnings in CSP-constrained hosts such as Goose and Cursor while schema validation still works.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.