@toolgrain/mcp 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (248) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +85 -2
  3. package/dist/auth/abort.d.ts +3 -0
  4. package/dist/auth/abort.d.ts.map +1 -0
  5. package/dist/auth/abort.js +14 -0
  6. package/dist/auth/abort.js.map +1 -0
  7. package/dist/auth/audience.d.ts +3 -0
  8. package/dist/auth/audience.d.ts.map +1 -0
  9. package/dist/auth/audience.js +17 -0
  10. package/dist/auth/audience.js.map +1 -0
  11. package/dist/auth/authorization.d.ts +7 -0
  12. package/dist/auth/authorization.d.ts.map +1 -0
  13. package/dist/auth/authorization.js +58 -0
  14. package/dist/auth/authorization.js.map +1 -0
  15. package/dist/auth/context.d.ts +8 -0
  16. package/dist/auth/context.d.ts.map +1 -0
  17. package/dist/auth/context.js +37 -0
  18. package/dist/auth/context.js.map +1 -0
  19. package/dist/auth/errors.d.ts +14 -0
  20. package/dist/auth/errors.d.ts.map +1 -0
  21. package/dist/auth/errors.js +23 -0
  22. package/dist/auth/errors.js.map +1 -0
  23. package/dist/auth/types.d.ts +28 -0
  24. package/dist/auth/types.d.ts.map +1 -0
  25. package/dist/auth/types.js +2 -0
  26. package/dist/auth/types.js.map +1 -0
  27. package/dist/auth/url.d.ts +3 -0
  28. package/dist/auth/url.d.ts.map +1 -0
  29. package/dist/auth/url.js +18 -0
  30. package/dist/auth/url.js.map +1 -0
  31. package/dist/connection.d.ts +12 -0
  32. package/dist/connection.d.ts.map +1 -0
  33. package/dist/connection.js +151 -0
  34. package/dist/connection.js.map +1 -0
  35. package/dist/context/access.d.ts +7 -0
  36. package/dist/context/access.d.ts.map +1 -0
  37. package/dist/context/access.js +22 -0
  38. package/dist/context/access.js.map +1 -0
  39. package/dist/context/definition.d.ts +24 -0
  40. package/dist/context/definition.d.ts.map +1 -0
  41. package/dist/context/definition.js +57 -0
  42. package/dist/context/definition.js.map +1 -0
  43. package/dist/context/registry.d.ts +5 -0
  44. package/dist/context/registry.d.ts.map +1 -0
  45. package/dist/context/registry.js +15 -0
  46. package/dist/context/registry.js.map +1 -0
  47. package/dist/context/scope.d.ts +5 -0
  48. package/dist/context/scope.d.ts.map +1 -0
  49. package/dist/context/scope.js +56 -0
  50. package/dist/context/scope.js.map +1 -0
  51. package/dist/diagnostics.d.ts +10 -0
  52. package/dist/diagnostics.d.ts.map +1 -0
  53. package/dist/diagnostics.js +13 -0
  54. package/dist/diagnostics.js.map +1 -0
  55. package/dist/dispatcher.d.ts +19 -0
  56. package/dist/dispatcher.d.ts.map +1 -0
  57. package/dist/dispatcher.js +23 -0
  58. package/dist/dispatcher.js.map +1 -0
  59. package/dist/execute-request.d.ts +7 -0
  60. package/dist/execute-request.d.ts.map +1 -0
  61. package/dist/execute-request.js +20 -0
  62. package/dist/execute-request.js.map +1 -0
  63. package/dist/index.d.ts +22 -0
  64. package/dist/index.d.ts.map +1 -0
  65. package/dist/index.js +12 -0
  66. package/dist/index.js.map +1 -0
  67. package/dist/legacy/connection.d.ts +26 -0
  68. package/dist/legacy/connection.d.ts.map +1 -0
  69. package/dist/legacy/connection.js +73 -0
  70. package/dist/legacy/connection.js.map +1 -0
  71. package/dist/legacy/dispatcher.d.ts +10 -0
  72. package/dist/legacy/dispatcher.d.ts.map +1 -0
  73. package/dist/legacy/dispatcher.js +41 -0
  74. package/dist/legacy/dispatcher.js.map +1 -0
  75. package/dist/legacy/handlers.d.ts +12 -0
  76. package/dist/legacy/handlers.d.ts.map +1 -0
  77. package/dist/legacy/handlers.js +44 -0
  78. package/dist/legacy/handlers.js.map +1 -0
  79. package/dist/legacy/messages.d.ts +31 -0
  80. package/dist/legacy/messages.d.ts.map +1 -0
  81. package/dist/legacy/messages.js +27 -0
  82. package/dist/legacy/messages.js.map +1 -0
  83. package/dist/legacy/responses.d.ts +5 -0
  84. package/dist/legacy/responses.d.ts.map +1 -0
  85. package/dist/legacy/responses.js +8 -0
  86. package/dist/legacy/responses.js.map +1 -0
  87. package/dist/legacy/results.d.ts +5 -0
  88. package/dist/legacy/results.d.ts.map +1 -0
  89. package/dist/legacy/results.js +19 -0
  90. package/dist/legacy/results.js.map +1 -0
  91. package/dist/modern/dispatcher.d.ts +7 -0
  92. package/dist/modern/dispatcher.d.ts.map +1 -0
  93. package/dist/modern/dispatcher.js +37 -0
  94. package/dist/modern/dispatcher.js.map +1 -0
  95. package/dist/modern/handlers.d.ts +9 -0
  96. package/dist/modern/handlers.d.ts.map +1 -0
  97. package/dist/modern/handlers.js +36 -0
  98. package/dist/modern/handlers.js.map +1 -0
  99. package/dist/modern/messages.d.ts +142 -0
  100. package/dist/modern/messages.d.ts.map +1 -0
  101. package/dist/modern/messages.js +14 -0
  102. package/dist/modern/messages.js.map +1 -0
  103. package/dist/modern/metadata.d.ts +45 -0
  104. package/dist/modern/metadata.d.ts.map +1 -0
  105. package/dist/modern/metadata.js +49 -0
  106. package/dist/modern/metadata.js.map +1 -0
  107. package/dist/modern/responses.d.ts +3 -0
  108. package/dist/modern/responses.d.ts.map +1 -0
  109. package/dist/modern/responses.js +15 -0
  110. package/dist/modern/responses.js.map +1 -0
  111. package/dist/modern/results.d.ts +4 -0
  112. package/dist/modern/results.d.ts.map +1 -0
  113. package/dist/modern/results.js +4 -0
  114. package/dist/modern/results.js.map +1 -0
  115. package/dist/pending-requests.d.ts +12 -0
  116. package/dist/pending-requests.d.ts.map +1 -0
  117. package/dist/pending-requests.js +30 -0
  118. package/dist/pending-requests.js.map +1 -0
  119. package/dist/protocol/decode.d.ts +21 -0
  120. package/dist/protocol/decode.d.ts.map +1 -0
  121. package/dist/protocol/decode.js +40 -0
  122. package/dist/protocol/decode.js.map +1 -0
  123. package/dist/protocol/icon.d.ts +11 -0
  124. package/dist/protocol/icon.d.ts.map +1 -0
  125. package/dist/protocol/icon.js +8 -0
  126. package/dist/protocol/icon.js.map +1 -0
  127. package/dist/protocol/messages.d.ts +19 -0
  128. package/dist/protocol/messages.d.ts.map +1 -0
  129. package/dist/protocol/messages.js +21 -0
  130. package/dist/protocol/messages.js.map +1 -0
  131. package/dist/protocol/responses.d.ts +9 -0
  132. package/dist/protocol/responses.d.ts.map +1 -0
  133. package/dist/protocol/responses.js +20 -0
  134. package/dist/protocol/responses.js.map +1 -0
  135. package/dist/protocol/version-metadata.d.ts +7 -0
  136. package/dist/protocol/version-metadata.d.ts.map +1 -0
  137. package/dist/protocol/version-metadata.js +21 -0
  138. package/dist/protocol/version-metadata.js.map +1 -0
  139. package/dist/server.d.ts +35 -0
  140. package/dist/server.d.ts.map +1 -0
  141. package/dist/server.js +101 -0
  142. package/dist/server.js.map +1 -0
  143. package/dist/tools/adapter.d.ts +12 -0
  144. package/dist/tools/adapter.d.ts.map +1 -0
  145. package/dist/tools/adapter.js +45 -0
  146. package/dist/tools/adapter.js.map +1 -0
  147. package/dist/tools/call.d.ts +8 -0
  148. package/dist/tools/call.d.ts.map +1 -0
  149. package/dist/tools/call.js +9 -0
  150. package/dist/tools/call.js.map +1 -0
  151. package/dist/tools/content.d.ts +181 -0
  152. package/dist/tools/content.d.ts.map +1 -0
  153. package/dist/tools/content.js +54 -0
  154. package/dist/tools/content.js.map +1 -0
  155. package/dist/tools/context.d.ts +36 -0
  156. package/dist/tools/context.d.ts.map +1 -0
  157. package/dist/tools/context.js +50 -0
  158. package/dist/tools/context.js.map +1 -0
  159. package/dist/tools/definition.d.ts +55 -0
  160. package/dist/tools/definition.d.ts.map +1 -0
  161. package/dist/tools/definition.js +44 -0
  162. package/dist/tools/definition.js.map +1 -0
  163. package/dist/tools/errors.d.ts +11 -0
  164. package/dist/tools/errors.d.ts.map +1 -0
  165. package/dist/tools/errors.js +19 -0
  166. package/dist/tools/errors.js.map +1 -0
  167. package/dist/tools/json-value.d.ts +15 -0
  168. package/dist/tools/json-value.d.ts.map +1 -0
  169. package/dist/tools/json-value.js +42 -0
  170. package/dist/tools/json-value.js.map +1 -0
  171. package/dist/tools/name.d.ts +6 -0
  172. package/dist/tools/name.d.ts.map +1 -0
  173. package/dist/tools/name.js +13 -0
  174. package/dist/tools/name.js.map +1 -0
  175. package/dist/tools/registry.d.ts +14 -0
  176. package/dist/tools/registry.d.ts.map +1 -0
  177. package/dist/tools/registry.js +31 -0
  178. package/dist/tools/registry.js.map +1 -0
  179. package/dist/tools/results.d.ts +14 -0
  180. package/dist/tools/results.d.ts.map +1 -0
  181. package/dist/tools/results.js +71 -0
  182. package/dist/tools/results.js.map +1 -0
  183. package/dist/tools/rich-result.d.ts +44 -0
  184. package/dist/tools/rich-result.d.ts.map +1 -0
  185. package/dist/tools/rich-result.js +24 -0
  186. package/dist/tools/rich-result.js.map +1 -0
  187. package/dist/tools/schema.d.ts +18 -0
  188. package/dist/tools/schema.d.ts.map +1 -0
  189. package/dist/tools/schema.js +70 -0
  190. package/dist/tools/schema.js.map +1 -0
  191. package/dist/transport-ownership.d.ts +4 -0
  192. package/dist/transport-ownership.d.ts.map +1 -0
  193. package/dist/transport-ownership.js +13 -0
  194. package/dist/transport-ownership.js.map +1 -0
  195. package/dist/transport.d.ts +24 -0
  196. package/dist/transport.d.ts.map +1 -0
  197. package/dist/transport.js +4 -0
  198. package/dist/transport.js.map +1 -0
  199. package/package.json +65 -4
  200. package/src/auth/abort.ts +14 -0
  201. package/src/auth/audience.ts +22 -0
  202. package/src/auth/authorization.ts +81 -0
  203. package/src/auth/context.ts +43 -0
  204. package/src/auth/errors.ts +35 -0
  205. package/src/auth/types.ts +34 -0
  206. package/src/auth/url.ts +22 -0
  207. package/src/connection.ts +207 -0
  208. package/src/context/access.ts +36 -0
  209. package/src/context/definition.ts +100 -0
  210. package/src/context/registry.ts +25 -0
  211. package/src/context/scope.ts +82 -0
  212. package/src/diagnostics.ts +25 -0
  213. package/src/dispatcher.ts +70 -0
  214. package/src/execute-request.ts +35 -0
  215. package/src/index.ts +41 -0
  216. package/src/legacy/connection.ts +101 -0
  217. package/src/legacy/dispatcher.ts +72 -0
  218. package/src/legacy/handlers.ts +76 -0
  219. package/src/legacy/messages.ts +27 -0
  220. package/src/legacy/responses.ts +20 -0
  221. package/src/legacy/results.ts +20 -0
  222. package/src/modern/dispatcher.ts +77 -0
  223. package/src/modern/handlers.ts +55 -0
  224. package/src/modern/messages.ts +14 -0
  225. package/src/modern/metadata.ts +49 -0
  226. package/src/modern/responses.ts +25 -0
  227. package/src/modern/results.ts +6 -0
  228. package/src/pending-requests.ts +30 -0
  229. package/src/protocol/decode.ts +69 -0
  230. package/src/protocol/icon.ts +8 -0
  231. package/src/protocol/messages.ts +29 -0
  232. package/src/protocol/responses.ts +27 -0
  233. package/src/protocol/version-metadata.ts +42 -0
  234. package/src/server.ts +164 -0
  235. package/src/tools/adapter.ts +76 -0
  236. package/src/tools/call.ts +18 -0
  237. package/src/tools/content.ts +57 -0
  238. package/src/tools/context.ts +119 -0
  239. package/src/tools/definition.ts +144 -0
  240. package/src/tools/errors.ts +21 -0
  241. package/src/tools/json-value.ts +81 -0
  242. package/src/tools/name.ts +13 -0
  243. package/src/tools/registry.ts +52 -0
  244. package/src/tools/results.ts +100 -0
  245. package/src/tools/rich-result.ts +70 -0
  246. package/src/tools/schema.ts +86 -0
  247. package/src/transport-ownership.ts +17 -0
  248. package/src/transport.ts +34 -0
@@ -0,0 +1,181 @@
1
+ import { z } from "zod";
2
+ export declare const contentBlock: z.ZodDiscriminatedUnion<[z.ZodObject<{
3
+ annotations: z.ZodOptional<z.ZodObject<{
4
+ audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
5
+ assistant: "assistant";
6
+ user: "user";
7
+ }>>>;
8
+ priority: z.ZodOptional<z.ZodNumber>;
9
+ lastModified: z.ZodOptional<z.ZodString>;
10
+ }, z.core.$loose>>;
11
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
12
+ type: z.ZodLiteral<"text">;
13
+ text: z.ZodString;
14
+ }, z.core.$loose>, z.ZodObject<{
15
+ annotations: z.ZodOptional<z.ZodObject<{
16
+ audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
17
+ assistant: "assistant";
18
+ user: "user";
19
+ }>>>;
20
+ priority: z.ZodOptional<z.ZodNumber>;
21
+ lastModified: z.ZodOptional<z.ZodString>;
22
+ }, z.core.$loose>>;
23
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
24
+ type: z.ZodLiteral<"image">;
25
+ data: z.ZodString;
26
+ mimeType: z.ZodString;
27
+ }, z.core.$loose>, z.ZodObject<{
28
+ annotations: z.ZodOptional<z.ZodObject<{
29
+ audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
30
+ assistant: "assistant";
31
+ user: "user";
32
+ }>>>;
33
+ priority: z.ZodOptional<z.ZodNumber>;
34
+ lastModified: z.ZodOptional<z.ZodString>;
35
+ }, z.core.$loose>>;
36
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
37
+ type: z.ZodLiteral<"audio">;
38
+ data: z.ZodString;
39
+ mimeType: z.ZodString;
40
+ }, z.core.$loose>, z.ZodObject<{
41
+ annotations: z.ZodOptional<z.ZodObject<{
42
+ audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
43
+ assistant: "assistant";
44
+ user: "user";
45
+ }>>>;
46
+ priority: z.ZodOptional<z.ZodNumber>;
47
+ lastModified: z.ZodOptional<z.ZodString>;
48
+ }, z.core.$loose>>;
49
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
50
+ type: z.ZodLiteral<"resource_link">;
51
+ uri: z.ZodString;
52
+ name: z.ZodString;
53
+ title: z.ZodOptional<z.ZodString>;
54
+ description: z.ZodOptional<z.ZodString>;
55
+ mimeType: z.ZodOptional<z.ZodString>;
56
+ size: z.ZodOptional<z.ZodNumber>;
57
+ icons: z.ZodOptional<z.ZodArray<z.ZodObject<{
58
+ src: z.ZodString;
59
+ mimeType: z.ZodOptional<z.ZodString>;
60
+ sizes: z.ZodOptional<z.ZodArray<z.ZodString>>;
61
+ theme: z.ZodOptional<z.ZodEnum<{
62
+ dark: "dark";
63
+ light: "light";
64
+ }>>;
65
+ }, z.core.$loose>>>;
66
+ }, z.core.$loose>, z.ZodObject<{
67
+ annotations: z.ZodOptional<z.ZodObject<{
68
+ audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
69
+ assistant: "assistant";
70
+ user: "user";
71
+ }>>>;
72
+ priority: z.ZodOptional<z.ZodNumber>;
73
+ lastModified: z.ZodOptional<z.ZodString>;
74
+ }, z.core.$loose>>;
75
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
76
+ type: z.ZodLiteral<"resource">;
77
+ resource: z.ZodUnion<readonly [z.ZodObject<{
78
+ uri: z.ZodString;
79
+ mimeType: z.ZodOptional<z.ZodString>;
80
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
81
+ text: z.ZodString;
82
+ }, z.core.$loose>, z.ZodObject<{
83
+ uri: z.ZodString;
84
+ mimeType: z.ZodOptional<z.ZodString>;
85
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
86
+ blob: z.ZodString;
87
+ }, z.core.$loose>]>;
88
+ }, z.core.$loose>], "type">;
89
+ export declare const explicitResult: z.ZodObject<{
90
+ content: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
91
+ annotations: z.ZodOptional<z.ZodObject<{
92
+ audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
93
+ assistant: "assistant";
94
+ user: "user";
95
+ }>>>;
96
+ priority: z.ZodOptional<z.ZodNumber>;
97
+ lastModified: z.ZodOptional<z.ZodString>;
98
+ }, z.core.$loose>>;
99
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
100
+ type: z.ZodLiteral<"text">;
101
+ text: z.ZodString;
102
+ }, z.core.$loose>, z.ZodObject<{
103
+ annotations: z.ZodOptional<z.ZodObject<{
104
+ audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
105
+ assistant: "assistant";
106
+ user: "user";
107
+ }>>>;
108
+ priority: z.ZodOptional<z.ZodNumber>;
109
+ lastModified: z.ZodOptional<z.ZodString>;
110
+ }, z.core.$loose>>;
111
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
112
+ type: z.ZodLiteral<"image">;
113
+ data: z.ZodString;
114
+ mimeType: z.ZodString;
115
+ }, z.core.$loose>, z.ZodObject<{
116
+ annotations: z.ZodOptional<z.ZodObject<{
117
+ audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
118
+ assistant: "assistant";
119
+ user: "user";
120
+ }>>>;
121
+ priority: z.ZodOptional<z.ZodNumber>;
122
+ lastModified: z.ZodOptional<z.ZodString>;
123
+ }, z.core.$loose>>;
124
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
125
+ type: z.ZodLiteral<"audio">;
126
+ data: z.ZodString;
127
+ mimeType: z.ZodString;
128
+ }, z.core.$loose>, z.ZodObject<{
129
+ annotations: z.ZodOptional<z.ZodObject<{
130
+ audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
131
+ assistant: "assistant";
132
+ user: "user";
133
+ }>>>;
134
+ priority: z.ZodOptional<z.ZodNumber>;
135
+ lastModified: z.ZodOptional<z.ZodString>;
136
+ }, z.core.$loose>>;
137
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
138
+ type: z.ZodLiteral<"resource_link">;
139
+ uri: z.ZodString;
140
+ name: z.ZodString;
141
+ title: z.ZodOptional<z.ZodString>;
142
+ description: z.ZodOptional<z.ZodString>;
143
+ mimeType: z.ZodOptional<z.ZodString>;
144
+ size: z.ZodOptional<z.ZodNumber>;
145
+ icons: z.ZodOptional<z.ZodArray<z.ZodObject<{
146
+ src: z.ZodString;
147
+ mimeType: z.ZodOptional<z.ZodString>;
148
+ sizes: z.ZodOptional<z.ZodArray<z.ZodString>>;
149
+ theme: z.ZodOptional<z.ZodEnum<{
150
+ dark: "dark";
151
+ light: "light";
152
+ }>>;
153
+ }, z.core.$loose>>>;
154
+ }, z.core.$loose>, z.ZodObject<{
155
+ annotations: z.ZodOptional<z.ZodObject<{
156
+ audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
157
+ assistant: "assistant";
158
+ user: "user";
159
+ }>>>;
160
+ priority: z.ZodOptional<z.ZodNumber>;
161
+ lastModified: z.ZodOptional<z.ZodString>;
162
+ }, z.core.$loose>>;
163
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
164
+ type: z.ZodLiteral<"resource">;
165
+ resource: z.ZodUnion<readonly [z.ZodObject<{
166
+ uri: z.ZodString;
167
+ mimeType: z.ZodOptional<z.ZodString>;
168
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
169
+ text: z.ZodString;
170
+ }, z.core.$loose>, z.ZodObject<{
171
+ uri: z.ZodString;
172
+ mimeType: z.ZodOptional<z.ZodString>;
173
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
174
+ blob: z.ZodString;
175
+ }, z.core.$loose>]>;
176
+ }, z.core.$loose>], "type">>;
177
+ structuredContent: z.ZodOptional<z.ZodUnknown>;
178
+ isError: z.ZodOptional<z.ZodBoolean>;
179
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
180
+ }, z.core.$strict>;
181
+ //# sourceMappingURL=content.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../src/tools/content.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAoBxB,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BA6BvB,CAAC;AAEH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAKzB,CAAC"}
@@ -0,0 +1,54 @@
1
+ import { z } from "zod";
2
+ import { icon } from "../protocol/icon.js";
3
+ import { object } from "../protocol/messages.js";
4
+ const annotations = z.looseObject({
5
+ audience: z.array(z.enum(["user", "assistant"])).optional(),
6
+ priority: z.number().min(0).max(1).optional(),
7
+ lastModified: z.string().optional(),
8
+ });
9
+ const common = z.looseObject({
10
+ annotations: annotations.optional(),
11
+ _meta: object.optional(),
12
+ });
13
+ const resourceContents = z.looseObject({
14
+ uri: z.string(),
15
+ mimeType: z.string().optional(),
16
+ _meta: object.optional(),
17
+ });
18
+ export const contentBlock = z.discriminatedUnion("type", [
19
+ common.extend({ type: z.literal("text"), text: z.string() }),
20
+ common.extend({
21
+ type: z.literal("image"),
22
+ data: z.string(),
23
+ mimeType: z.string(),
24
+ }),
25
+ common.extend({
26
+ type: z.literal("audio"),
27
+ data: z.string(),
28
+ mimeType: z.string(),
29
+ }),
30
+ common.extend({
31
+ type: z.literal("resource_link"),
32
+ uri: z.string(),
33
+ name: z.string(),
34
+ title: z.string().optional(),
35
+ description: z.string().optional(),
36
+ mimeType: z.string().optional(),
37
+ size: z.number().optional(),
38
+ icons: z.array(icon).optional(),
39
+ }),
40
+ common.extend({
41
+ type: z.literal("resource"),
42
+ resource: z.union([
43
+ resourceContents.extend({ text: z.string() }),
44
+ resourceContents.extend({ blob: z.string() }),
45
+ ]),
46
+ }),
47
+ ]);
48
+ export const explicitResult = z.strictObject({
49
+ content: z.array(contentBlock),
50
+ structuredContent: z.unknown().optional(),
51
+ isError: z.boolean().optional(),
52
+ _meta: object.optional(),
53
+ });
54
+ //# sourceMappingURL=content.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.js","sourceRoot":"","sources":["../../src/tools/content.ts"],"names":[],"mappings":"AAAA,OAAO,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O,EAAE,CAAC,QAAQ,EAAE;IACzC,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC/B,KAAK,EAAE,MAAM,CAAC,QAAQ,EAAE;CACzB,CAAC,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { type ClientCapabilities, type Implementation, type RequestId, type SupportedProtocolVersion } from "@toolgrain/protocol";
2
+ import type { ClientCapabilities as LegacyClientCapabilities, Implementation as LegacyImplementation } from "@toolgrain/protocol/2025-06-18";
3
+ import type { AuthIdentity } from "../auth/types.js";
4
+ import type { RegisteredContextProvider } from "../context/definition.js";
5
+ import { type ContextRegistry } from "../context/registry.js";
6
+ import type { DeepReadonly } from "./json-value.js";
7
+ /** What the client reported about itself; unverified, so not a basis for security decisions. */
8
+ export interface ToolClient {
9
+ readonly info?: DeepReadonly<Implementation | LegacyImplementation>;
10
+ readonly capabilities?: DeepReadonly<ClientCapabilities | LegacyClientCapabilities>;
11
+ }
12
+ export interface ToolRequest {
13
+ readonly id: RequestId;
14
+ readonly protocolVersion: SupportedProtocolVersion;
15
+ /** Absent when the era and transport carry no client information, such as legacy HTTP. */
16
+ readonly client?: ToolClient;
17
+ /** A deeply frozen copy of the request's `_meta`; empty when the request carried none. */
18
+ readonly meta: Readonly<Record<string, unknown>>;
19
+ }
20
+ export interface ToolContext {
21
+ /** Aborts when the client cancels or disconnects, or the transport or server closes. */
22
+ readonly signal: AbortSignal;
23
+ readonly request: ToolRequest;
24
+ }
25
+ export interface ToolContextOptions {
26
+ signal?: AbortSignal;
27
+ request?: Partial<ToolRequest>;
28
+ context?: readonly RegisteredContextProvider[];
29
+ }
30
+ /** Build a context for calling a definition's `execute` directly, for example in tests. */
31
+ export declare function toolContext(options?: ToolContextOptions): ToolContext;
32
+ /** Each request gets its own deeply frozen copies, so handlers cannot affect one another. */
33
+ export declare function createToolContext(signal: AbortSignal, { client, ...request }: ToolRequest, auth?: AuthIdentity, providers?: ContextRegistry): ToolContext;
34
+ /** Omit absent fields so the client matches its optional-property types. */
35
+ export declare function toolClient(info: ToolClient["info"], capabilities: ToolClient["capabilities"]): ToolClient;
36
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/tools/context.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EAEnB,KAAK,SAAS,EACd,KAAK,wBAAwB,EAC9B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EACV,kBAAkB,IAAI,wBAAwB,EAC9C,cAAc,IAAI,oBAAoB,EACvC,MAAM,gCAAgC,CAAC;AAExC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAC1E,OAAO,EACL,KAAK,eAAe,EAErB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,gGAAgG;AAChG,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC,cAAc,GAAG,oBAAoB,CAAC,CAAC;IACpE,QAAQ,CAAC,YAAY,CAAC,EAAE,YAAY,CAClC,kBAAkB,GAAG,wBAAwB,CAC9C,CAAC;CACH;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,EAAE,SAAS,CAAC;IACvB,QAAQ,CAAC,eAAe,EAAE,wBAAwB,CAAC;IACnD,0FAA0F;IAC1F,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC;IAC7B,0FAA0F;IAC1F,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAClD;AAED,MAAM,WAAW,WAAW;IAC1B,wFAAwF;IACxF,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;CAC/B;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IAC/B,OAAO,CAAC,EAAE,SAAS,yBAAyB,EAAE,CAAC;CAChD;AAED,2FAA2F;AAC3F,wBAAgB,WAAW,CAAC,OAAO,GAAE,kBAAuB,GAAG,WAAW,CAmBzE;AAED,6FAA6F;AAC7F,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,WAAW,EACnB,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,EAAE,WAAW,EACnC,IAAI,CAAC,EAAE,YAAY,EACnB,SAAS,GAAE,eAAyC,GACnD,WAAW,CAiBb;AAED,4EAA4E;AAC5E,wBAAgB,UAAU,CACxB,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,EACxB,YAAY,EAAE,UAAU,CAAC,cAAc,CAAC,GACvC,UAAU,CAKZ"}
@@ -0,0 +1,50 @@
1
+ import { PROTOCOL_VERSION, } from "@toolgrain/protocol";
2
+ import { attachAuth } from "../auth/context.js";
3
+ import { createContextRegistry, } from "../context/registry.js";
4
+ import { createContextScope } from "../context/scope.js";
5
+ /** Build a context for calling a definition's `execute` directly, for example in tests. */
6
+ export function toolContext(options = {}) {
7
+ // Default each field separately so an explicit undefined cannot replace a default.
8
+ const { id = 0, protocolVersion = PROTOCOL_VERSION, client, meta = {}, } = options.request ?? {};
9
+ return createToolContext(options.signal ?? new AbortController().signal, {
10
+ id,
11
+ protocolVersion,
12
+ ...(client === undefined ? {} : { client }),
13
+ meta,
14
+ }, undefined, createContextRegistry(options.context));
15
+ }
16
+ /** Each request gets its own deeply frozen copies, so handlers cannot affect one another. */
17
+ export function createToolContext(signal, { client, ...request }, auth, providers = createContextRegistry()) {
18
+ const ctx = attachAuth({
19
+ signal,
20
+ request: Object.freeze({
21
+ ...request,
22
+ ...(client === undefined
23
+ ? {}
24
+ : {
25
+ client: frozenCopy(toolClient(client.info, client.capabilities)),
26
+ }),
27
+ meta: frozenCopy(request.meta),
28
+ }),
29
+ }, auth);
30
+ return createContextScope(ctx, providers);
31
+ }
32
+ /** Omit absent fields so the client matches its optional-property types. */
33
+ export function toolClient(info, capabilities) {
34
+ return {
35
+ ...(info === undefined ? {} : { info }),
36
+ ...(capabilities === undefined ? {} : { capabilities }),
37
+ };
38
+ }
39
+ function frozenCopy(value) {
40
+ return deepFreeze(structuredClone(value));
41
+ }
42
+ function deepFreeze(value) {
43
+ if (typeof value === "object" && value !== null) {
44
+ Object.freeze(value);
45
+ for (const child of Object.values(value))
46
+ deepFreeze(child);
47
+ }
48
+ return value;
49
+ }
50
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/tools/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,gBAAgB,GAGjB,MAAM,qBAAqB,CAAC;AAK7B,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,OAAO,EAEL,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAgCzD,2FAA2F;AAC3F,MAAM,UAAU,WAAW,CAAC,OAAO,GAAuB,EAAE;IAC1D,mFAAmF;IACnF,MAAM,EACJ,EAAE,GAAG,CAAC,EACN,eAAe,GAAG,gBAAgB,EAClC,MAAM,EACN,IAAI,GAAG,EAAE,GACV,GAAG,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;IAC1B,OAAO,iBAAiB,CACtB,OAAO,CAAC,MAAM,IAAI,IAAI,eAAe,EAAE,CAAC,MAAM,EAC9C;QACE,EAAE;QACF,eAAe;QACf,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC;QAC3C,IAAI;KACL,EACD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CAAC;QACrB,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;YAAE,UAAU,CAAC,KAAK,CAAC,CAAC;IAC9D,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,55 @@
1
+ import type { Tool as ProtocolTool } from "@toolgrain/protocol";
2
+ import type * as core from "zod/v4/core";
3
+ import type { ToolContext } from "./context.js";
4
+ import type { DeepReadonly, IsJsonCompatible, JsonCompatible } from "./json-value.js";
5
+ import type { McpErrorResult, McpResult, McpStructuredResult } from "./rich-result.js";
6
+ export declare const TOOL_METADATA_KEYS: readonly ["title", "description", "annotations", "icons", "_meta"];
7
+ export type ToolMetadata = DeepReadonly<Pick<ProtocolTool, (typeof TOOL_METADATA_KEYS)[number]>>;
8
+ export interface ToolDefinition<Schema extends core.$ZodType, Result, Output extends core.$ZodType = never> extends ToolMetadata {
9
+ readonly input: Schema;
10
+ readonly output?: Output;
11
+ /** Raw handler; server invocation performs validation and result conversion. */
12
+ readonly execute: (input: core.output<Schema>, ctx: ToolContext) => Result;
13
+ }
14
+ /** Internal erased type for heterogeneous, schema-checked registrations. */
15
+ export declare abstract class RegisteredTool {
16
+ abstract readonly input: core.$ZodType;
17
+ abstract readonly output?: core.$ZodType;
18
+ abstract readonly execute: (input: never, ctx: ToolContext) => unknown;
19
+ abstract readonly title?: string;
20
+ abstract readonly description?: string;
21
+ abstract readonly annotations?: NonNullable<ToolMetadata["annotations"]>;
22
+ abstract readonly icons?: NonNullable<ToolMetadata["icons"]>;
23
+ abstract readonly _meta?: NonNullable<ToolMetadata["_meta"]>;
24
+ /**
25
+ * Structural brand shared by package copies. Object spreads drop prototype
26
+ * methods, so modified spreads must pass through tool() again.
27
+ */
28
+ "~toolgrain"(): "tool@1";
29
+ }
30
+ /** Recognize definitions created by any compatible copy of this package. */
31
+ export declare function isRegisteredTool(value: unknown): value is RegisteredTool;
32
+ export declare class Tool<Schema extends core.$ZodType, Result, Output extends core.$ZodType = core.$ZodType> extends RegisteredTool {
33
+ readonly input: Schema;
34
+ readonly output?: Output;
35
+ readonly execute: (input: core.output<Schema>, ctx: ToolContext) => Result;
36
+ readonly title?: string;
37
+ readonly description?: string;
38
+ readonly annotations?: NonNullable<ToolMetadata["annotations"]>;
39
+ readonly icons?: NonNullable<ToolMetadata["icons"]>;
40
+ readonly _meta?: NonNullable<ToolMetadata["_meta"]>;
41
+ constructor(definition: ToolDefinition<Schema, Result, core.$ZodType>);
42
+ }
43
+ type OutputResult<Output extends core.$ZodType> = core.input<Output> | McpStructuredResult<core.input<Output>> | McpErrorResult<core.input<Output>>;
44
+ type JsonSafeOutput<Result> = Result extends PromiseLike<infer Resolved> ? PromiseLike<JsonSafeOutput<Resolved>> : Result extends McpResult<infer Structured> ? IsJsonCompatible<Structured> extends true ? Result : never : JsonCompatible<Result>;
45
+ type ToolDefinitionWithoutOutput<Schema extends core.$ZodType, Result> = Omit<ToolDefinition<Schema, Result>, "execute"> & {
46
+ readonly execute: (input: core.output<Schema>, ctx: ToolContext) => Result & JsonSafeOutput<Result>;
47
+ };
48
+ export declare function tool<Schema extends core.$ZodType, Output extends core.$ZodType, Result extends OutputResult<NoInfer<Output>> | PromiseLike<OutputResult<NoInfer<Output>>>>(definition: ToolDefinition<Schema, Result, Output> & {
49
+ readonly output: Output;
50
+ }): Tool<Schema, Result, Output> & {
51
+ readonly output: Output;
52
+ };
53
+ export declare function tool<Schema extends core.$ZodType, Result>(definition: ToolDefinitionWithoutOutput<Schema, Result>): Tool<Schema, Result, never>;
54
+ export {};
55
+ //# sourceMappingURL=definition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../src/tools/definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,KAAK,KAAK,IAAI,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,EAAE,WA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MAAM,CAAA;CAAE,CAAC;AAC9D,wBAAgB,IAAI,CAAC,MAAM,SAAS,IAAI,CAAC,QAAQ,EAAE,MAAM,EACvD,UAAU,EAAE,2BAA2B,CAAC,MAAM,EAAE,MAAM,CAAC,GACtD,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC"}
@@ -0,0 +1,44 @@
1
+ export const TOOL_METADATA_KEYS = [
2
+ "title",
3
+ "description",
4
+ "annotations",
5
+ "icons",
6
+ "_meta",
7
+ ];
8
+ // Registered symbols let duplicate package copies recognize each other's tools.
9
+ const TOOL_BRAND = Symbol.for("@toolgrain/mcp/tool@1");
10
+ /** Internal erased type for heterogeneous, schema-checked registrations. */
11
+ export class RegisteredTool {
12
+ /**
13
+ * Structural brand shared by package copies. Object spreads drop prototype
14
+ * methods, so modified spreads must pass through tool() again.
15
+ */
16
+ "~toolgrain"() {
17
+ return "tool@1";
18
+ }
19
+ }
20
+ Object.defineProperty(RegisteredTool.prototype, TOOL_BRAND, { value: true });
21
+ /** Recognize definitions created by any compatible copy of this package. */
22
+ export function isRegisteredTool(value) {
23
+ return (typeof value === "object" &&
24
+ value !== null &&
25
+ value[TOOL_BRAND] === true);
26
+ }
27
+ export class Tool extends RegisteredTool {
28
+ constructor(definition) {
29
+ super();
30
+ this.input = definition.input;
31
+ this.execute = definition.execute;
32
+ for (const key of ["output", ...TOOL_METADATA_KEYS]) {
33
+ const value = definition[key];
34
+ if (value !== undefined)
35
+ Object.defineProperty(this, key, { value, enumerable: true });
36
+ }
37
+ Object.freeze(this);
38
+ }
39
+ }
40
+ /** Define a reusable MCP tool. Its execute property remains the raw handler. */
41
+ export function tool(definition) {
42
+ return new Tool(definition);
43
+ }
44
+ //# sourceMappingURL=definition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definition.js","sourceRoot":"","sources":["../../src/tools/definition.ts"],"names":[],"mappings":"AAcA,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,OAAO;IACP,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zod/v4/core";
2
+ export declare class UnknownToolError extends Error {
3
+ readonly toolName: string;
4
+ constructor(toolName: string);
5
+ }
6
+ export declare class ToolInputError extends Error {
7
+ readonly toolName: string;
8
+ readonly issues: core.$ZodError["issues"];
9
+ constructor(toolName: string, cause: core.$ZodError);
10
+ }
11
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/tools/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,IAAI,MAAM,aAAa,CAAC;AAEzC,qBAAa,gBAAiB,SAAQ,KAAK;aACb,QAAQ,EAAE,MAAM;IAA5C,YAA4B,QAAQ,EAAE,MAAM,EAG3C;CACF;AAED,qBAAa,cAAe,SAAQ,KAAK;aAIrB,QAAQ,EAAE,MAAM;IAHlC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IAE1C,YACkB,QAAQ,EAAE,MAAM,EAChC,KAAK,EAAE,IAAI,CAAC,SAAS,EAKtB;CACF"}
@@ -0,0 +1,19 @@
1
+ export class UnknownToolError extends Error {
2
+ toolName;
3
+ constructor(toolName) {
4
+ super(`Unknown tool: ${toolName}`);
5
+ this.toolName = toolName;
6
+ this.name = "UnknownToolError";
7
+ }
8
+ }
9
+ export class ToolInputError extends Error {
10
+ toolName;
11
+ issues;
12
+ constructor(toolName, cause) {
13
+ super(`Invalid input for tool: ${toolName}`, { cause });
14
+ this.toolName = toolName;
15
+ this.name = "ToolInputError";
16
+ this.issues = cause.issues;
17
+ }
18
+ }
19
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/tools/errors.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACb,QAAQ;IAApC,YAA4B,QAAgB;QAC1C,KAAK,CAAC,iBAAiB,QAAQ,EAAE,CAAC,CAAC;wBADT,QAAQ;QAElC,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF;AAED,MAAM,OAAO,cAAe,SAAQ,KAAK;IAIrB,QAAQ;IAHjB,MAAM,CAA2B;IAE1C,YACkB,QAAgB,EAChC,KAAqB;QAErB,KAAK,CAAC,2BAA2B,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;wBAHxC,QAAQ;QAIxB,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAC7B,CAAC;CACF"}
@@ -0,0 +1,15 @@
1
+ import type { JSONValue } from "@toolgrain/protocol";
2
+ /** Readonly authoring views of protocol data; wire types remain unchanged. */
3
+ export type DeepReadonly<T> = T extends readonly (infer Item)[] ? readonly DeepReadonly<Item>[] : T extends object ? {
4
+ readonly [Key in keyof T]: DeepReadonly<T[Key]>;
5
+ } : T;
6
+ export type JsonCompatible<Value> = Value extends string | number | boolean | null ? Value : Value extends (...args: never[]) => unknown ? never : Value extends readonly (infer Item)[] ? readonly JsonCompatible<Item>[] : Value extends object ? {
7
+ [Key in keyof Value]: JsonCompatible<Value[Key]>;
8
+ } : never;
9
+ export type IsJsonCompatible<Value> = [Value] extends [JsonCompatible<Value>] ? true : false;
10
+ export interface AssertJSONOptions {
11
+ /** Treat undefined object properties as absent, matching JSON serialization. */
12
+ readonly omitUndefined?: boolean;
13
+ }
14
+ export declare function assertJSON(value: unknown, options?: AssertJSONOptions, ancestors?: Set<object>): asserts value is JSONValue;
15
+ //# sourceMappingURL=json-value.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-value.d.ts","sourceRoot":"","sources":["../../src/tools/json-value.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,8EAA8E;AAC9E,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,CAAC,MAAM,IAAI,CAAC,EAAE,GAC3D,SAAS,YAAY,CAAC,IAAI,CAAC,EAAE,GAC7B,CAAC,SAAS,MAAM,GACd;IAAE,QAAQ,EAAE,GAAG,IAAI,MAAM,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;CAAE,GACnD,CAAC,CAAC;AAER,MAAM,MAAM,cAAc,CAAC,KAAK,IAAI,KAAK,SACrC,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,KAAK,GACL,KAAK,SAAS,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,GACzC,KAAK,GACL,KAAK,SAAS,SAAS,CAAC,MAAM,IAAI,CAAC,EAAE,GACnC,SAAS,cAAc,CAAC,IAAI,CAAC,EAAE,GAC/B,KAAK,SAAS,MAAM,GAClB;KAAG,GAAG,IAAI,MAAM,KAAK,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;CAAE,GACpD,KAAK,CAAC;AAEhB,MAAM,MAAM,gBAAgB,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,GACzE,IAAI,GACJ,KAAK,CAAC;AAEV,MAAM,WAAW,iBAAiB;IAChC,gFAAgF;IAChF,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,wBAAgB,UAAU,CACxB,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,iBAAsB,EAC/B,SAAS,cAAoB,GAC5B,OAAO,CAAC,KAAK,IAAI,SAAS,CA4C5B"}
@@ -0,0 +1,42 @@
1
+ export function assertJSON(value, options = {}, ancestors = new Set()) {
2
+ if (value === null || typeof value === "string" || typeof value === "boolean")
3
+ return;
4
+ if (typeof value === "number" && Number.isFinite(value))
5
+ return;
6
+ if (typeof value !== "object" || value === null)
7
+ throw new Error("Tool output must be a JSON value");
8
+ if (ancestors.has(value))
9
+ throw new Error("Tool output contains a cycle");
10
+ const prototype = Object.getPrototypeOf(value);
11
+ if (!Array.isArray(value) &&
12
+ prototype !== Object.prototype &&
13
+ prototype !== null)
14
+ throw new Error("Tool output contains a non-JSON object instance");
15
+ ancestors.add(value);
16
+ try {
17
+ const keys = Reflect.ownKeys(value);
18
+ for (const key of keys) {
19
+ if (Array.isArray(value) && key === "length")
20
+ continue;
21
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
22
+ if (typeof key !== "string" ||
23
+ !descriptor?.enumerable ||
24
+ !("value" in descriptor))
25
+ throw new Error("Tool output contains a non-JSON property");
26
+ if (Array.isArray(value) &&
27
+ (!/^(0|[1-9]\d*)$/.test(key) || Number(key) >= value.length))
28
+ throw new Error("Tool output contains a non-JSON array property");
29
+ if (options.omitUndefined &&
30
+ !Array.isArray(value) &&
31
+ descriptor.value === undefined)
32
+ continue;
33
+ assertJSON(descriptor.value, options, ancestors);
34
+ }
35
+ if (Array.isArray(value) && keys.length !== value.length + 1)
36
+ throw new Error("Tool output contains a sparse array");
37
+ }
38
+ finally {
39
+ ancestors.delete(value);
40
+ }
41
+ }
42
+ //# sourceMappingURL=json-value.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-value.js","sourceRoot":"","sources":["../../src/tools/json-value.ts"],"names":[],"mappings":"AAgCA,MAAM,UAAU,UAAU,CACxB,KAAc,EACd,OAAO,GAAsB,EAAE,EAC/B,SAAS,GAAG,IAAI,GAAG,EAAU;IAE7B,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS;QAC3E,OAAO;IACT,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO;IAChE,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAC7C,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACtD,IAAI,SAAS,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CAAC,CAAC;QACnD,CAAC;QACD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,GAAG,CAAC;YAC1D,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IAC3D,CAAC;YAAS,CAAC;QACT,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;AACH,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare class ToolNameError extends Error {
2
+ readonly toolName: string;
3
+ constructor(toolName: string);
4
+ }
5
+ export declare function validateToolName(name: string): void;
6
+ //# sourceMappingURL=name.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"name.d.ts","sourceRoot":"","sources":["../../src/tools/name.ts"],"names":[],"mappings":"AAAA,qBAAa,aAAc,SAAQ,KAAK;aACV,QAAQ,EAAE,MAAM;IAA5C,YAA4B,QAAQ,EAAE,MAAM,EAK3C;CACF;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAGnD"}
@@ -0,0 +1,13 @@
1
+ export class ToolNameError extends Error {
2
+ toolName;
3
+ constructor(toolName) {
4
+ super(`Invalid MCP tool name: ${JSON.stringify(toolName)}. Use 1–128 ASCII letters, digits, underscores, hyphens, or dots.`);
5
+ this.toolName = toolName;
6
+ this.name = "ToolNameError";
7
+ }
8
+ }
9
+ export function validateToolName(name) {
10
+ if (name.length < 1 || name.length > 128 || /[^A-Za-z0-9_.-]/.test(name))
11
+ throw new ToolNameError(name);
12
+ }
13
+ //# sourceMappingURL=name.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"name.js","sourceRoot":"","sources":["../../src/tools/name.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,aAAc,SAAQ,KAAK;IACV,QAAQ;IAApC,YAA4B,QAAgB;QAC1C,KAAK,CACH,0BAA0B,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,mEAAmE,CACtH,CAAC;wBAHwB,QAAQ;QAIlC,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AAED,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,GAAG,IAAI,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC;QACtE,MAAM,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { ToolContext } from "./context.js";
2
+ import { type RegisteredTool, type ToolMetadata } from "./definition.js";
3
+ export type ToolMap = Record<string, RegisteredTool>;
4
+ export interface ToolEntry extends ToolMetadata {
5
+ name: string;
6
+ input: RegisteredTool["input"];
7
+ output?: NonNullable<RegisteredTool["output"]>;
8
+ }
9
+ export interface Registry {
10
+ list(): ToolEntry[];
11
+ execute(name: string, input: unknown, ctx: ToolContext): Promise<unknown>;
12
+ }
13
+ export declare function createRegistry(tools: ToolMap): Registry;
14
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/tools/registry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,YAAY,EAClB,MAAM,iBAAiB,CAAC;AAGzB,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AAErD,MAAM,WAAW,SAAU,SAAQ,YAAY;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;IAC/B,MAAM,CAAC,EAAE,WAAW,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;CAChD;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,IAAI,SAAS,EAAE,CAAC;IACpB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC3E;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,QAAQ,CA6BvD"}