Commit 22b5946
authored
fix(cloudflare): use Worker-safe validation for MCP (#236)
## Summary
- configure the Cloudflare MCP client to use the MCP SDK's
`CfWorkerJsonSchemaValidator`
- add a regression test that disables string-based code generation while
validating advertised MCP tool output schemas
## Root cause
The MCP SDK client defaults to AJV for JSON Schema validation. When
Cloudflare's MCP server advertises tool `outputSchema` values, AJV
compiles them with `new Function(...)`. Cloudflare Workers disallow
runtime code generation from strings, so credential validation and MCP
requests fail with:
```text
Cloudflare MCP request failed: Code generation from strings disallowed for this context
```
The SDK's Cloudflare-specific validator uses `@cfworker/json-schema` and
performs validation without `eval` or `new Function`.
## Impact
Cloudflare-hosted Open Connector deployments can validate Cloudflare MCP
credentials and invoke its tools. Node deployments retain the same
behavior.
Because the provider is currently broken on Cloudflare in v1.3.3, could
this be included in a patch release after review?
## Validation
- `node scripts/typecheck.ts src scripts-all examples`
- `vitest run` (61 files, 590 tests)
- dedicated regression test with `Function` disabled and MCP
`outputSchema` values present1 parent a332575 commit 22b5946
2 files changed
Lines changed: 22 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
4 | 8 | | |
5 | 9 | | |
6 | 10 | | |
| |||
39 | 43 | | |
40 | 44 | | |
41 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
42 | 56 | | |
43 | 57 | | |
44 | 58 | | |
| |||
78 | 92 | | |
79 | 93 | | |
80 | 94 | | |
| 95 | + | |
81 | 96 | | |
82 | 97 | | |
83 | 98 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
102 | 104 | | |
103 | 105 | | |
104 | 106 | | |
105 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
106 | 111 | | |
107 | 112 | | |
108 | 113 | | |
| |||
0 commit comments