Error compiling schema.
Closed this issue · 3 comments
Describe the bug
When using typescript-sdk on restricted javascript execution environments we get the following error:

This is because restricted javascript environments, like cloudflare workers or deno deploy do not accept eval, or new Function constructions. Since ajv.compile requires these dinamic evaluations, this error is logged to the console.
To Reproduce
Steps to reproduce the behavior:
- Run the server on restricted JS envs like cloudflare workers (wrangler to test it locally)
- Add tools and try to connect to the server. You'll see this error popup
Expected behavior
No error log to be logged to the console if these primitives are not available.
Additional context
Places that should be, somehow, guarded
typescript-sdk/src/server/index.ts
Line 358 in bf81793
typescript-sdk/src/client/index.ts
Line 487 in bf81793
this is making our error logs go crazy 🔥
Made a small patch. Just use this class while this issue is open
class CustomClient extends Client {
constructor(_clientInfo: Implementation, options?: ClientOptions) {
super(_clientInfo, options);
}
override async listTools(
params?: ListToolsRequest["params"],
options?: RequestOptions,
) {
const result = await this.request(
{ method: "tools/list", params },
ListToolsResultSchema,
options,
);
// Cache the tools and their output schemas for future validation
// this.cacheToolOutputSchemas(result.tools);
return result;
}
}