Commit 1e95431
authored
fix: add edge runtime compatibility for Cloudflare Workers (#17)
* fix: add edge runtime compatibility for Cloudflare Workers
Make the SDK compatible with edge runtimes (Cloudflare Workers, Vercel Edge,
Deno Deploy) by gracefully handling missing Node.js APIs:
- Lazy-load fs module for context_line extraction in exceptions.ts
- Guard process.once signal handlers in eventQueue.ts
- Lazy-load fs/os/path modules in logging.ts with console fallback
- Guard process.cwd() calls which may not exist in edge environments
- Update mcpcat-api dependency to 0.1.6
Add comprehensive test suite for edge runtime compatibility scenarios.
* chore: bump version to 0.1.9
* fix: add Zod v3/v4 compatibility for MCP SDK 1.23.0
MCP SDK 1.23.0 now supports both Zod v3 and v4, which have different
internal structures. This caused context parameter injection to fail.
Changes:
- Add zod-compat.ts with version-agnostic detection and utilities
- Update context-parameters.ts to use zod-compat utilities
- Update tracingV2.ts to use zod-compat for schema shape access
- Update Zod dependency to support both v3 and v4
- Add comprehensive tests for zod-compat utilities
Tested with MCP SDK versions 1.21.2 and 1.23.0.1 parent ac96b3c commit 1e95431
File tree
10 files changed
+1005
-108
lines changed- src
- modules
- tests
10 files changed
+1005
-108
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
| 76 | + | |
77 | 77 | | |
78 | | - | |
| 78 | + | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
24 | 10 | | |
25 | 11 | | |
26 | 12 | | |
| |||
43 | 29 | | |
44 | 30 | | |
45 | 31 | | |
46 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
47 | 36 | | |
48 | 37 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
| 38 | + | |
53 | 39 | | |
54 | 40 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
76 | 51 | | |
77 | 52 | | |
78 | 53 | | |
| |||
84 | 59 | | |
85 | 60 | | |
86 | 61 | | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
93 | 66 | | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
99 | 71 | | |
100 | 72 | | |
101 | 73 | | |
| |||
115 | 87 | | |
116 | 88 | | |
117 | 89 | | |
118 | | - | |
119 | | - | |
| 90 | + | |
120 | 91 | | |
121 | 92 | | |
122 | 93 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
192 | | - | |
193 | | - | |
194 | | - | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
195 | 204 | | |
196 | 205 | | |
197 | 206 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
3 | 19 | | |
4 | 20 | | |
5 | 21 | | |
| |||
120 | 136 | | |
121 | 137 | | |
122 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
123 | 145 | | |
124 | | - | |
| 146 | + | |
125 | 147 | | |
126 | 148 | | |
127 | 149 | | |
| |||
635 | 657 | | |
636 | 658 | | |
637 | 659 | | |
638 | | - | |
639 | | - | |
640 | | - | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
641 | 672 | | |
642 | 673 | | |
643 | 674 | | |
| |||
0 commit comments