-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix: elicitation json schema validation in Cloudflare Worker #1012
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: elicitation json schema validation in Cloudflare Worker #1012
Conversation
Elicitation can't work on cloudflare workers at all because it requires a second request from the client to resolve the first request and that's impossible in cloudflare architecture |
Hey, I'm working on this at Cloudflare at the moment. We use a Durable Object to keep the state during the elicitation (and for all stateful MCP interactions). Multiple requests from the client can hit the same Durable Object :) You can read more about it here |
@mattzcarey i used the same approach but was still stopped by cloudflare...would you be available for a quick chat some of those days? |
Sure. I'm still very new (I started yesterday) but it's my job to get this working. |
@mattzcarey do you have discord or where can I contact you? |
I'm in the cloudflare discord :) |
I don't think it is the correct move to fully switch over to I am pushing for the library to move away from these hard-coded dependencies (Ajv, Zod, etc) to a flexible core with the ability to inject them, allowing developers to choose what is best for their use case. I created a fork @enth/mcp-sdk that allows you to use the any JSON schema validator (including pre-compiled ones) or schema definition library. Would love to hear your thoughts on it and if that approach would work for your use case. |
Hey @jake-danton awesome work on the fork. I ran some benchmarks on this change with some simple examples. I can imagine with deeply nested schemas this gap would widen.
Slower sure, but I'm not sure this constitutes a completely new dev experience. There are other efficiencies that are lower hanging fruit in the SDK nevermind the fact that an LLM is always going to be the slowest part of this system. There is ongoing chat about this internally, we could support AJV in its current form but the validator would have to be declared in the global scope for the I'll check out your repo and benchmarks more tomorrow, it is definitely cool work. |
Fixes #689 by removing AJV in favour of @cfworker/json-schema library which works on edge runtimes natively.
Motivation and Context
AJV consistently causes issues in Workers due to its use of
eval
. You can see a repro of this using the latest v8 version and other related bugs hereHow Has This Been Tested?
This is tested against a non exhaustive set of json schema 2020-12 spec (in prep for SEP-1330) and the limited set of features supported here
Breaking Changes
This is not breaking and should not be noticed by users unless it unblocks them on edge runtimes.
Types of changes
Checklist
Additional context