@henrylabs/mcp 0.2.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 (315) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +255 -0
  3. package/code-tool-paths.cjs +6 -0
  4. package/code-tool-paths.cjs.map +1 -0
  5. package/code-tool-paths.d.cts +2 -0
  6. package/code-tool-paths.d.cts.map +1 -0
  7. package/code-tool-types.d.mts +14 -0
  8. package/code-tool-types.d.mts.map +1 -0
  9. package/code-tool-types.d.ts +14 -0
  10. package/code-tool-types.d.ts.map +1 -0
  11. package/code-tool-types.js +4 -0
  12. package/code-tool-types.js.map +1 -0
  13. package/code-tool-types.mjs +3 -0
  14. package/code-tool-types.mjs.map +1 -0
  15. package/code-tool-worker.d.mts +5 -0
  16. package/code-tool-worker.d.mts.map +1 -0
  17. package/code-tool-worker.d.ts +5 -0
  18. package/code-tool-worker.d.ts.map +1 -0
  19. package/code-tool-worker.js +45 -0
  20. package/code-tool-worker.js.map +1 -0
  21. package/code-tool-worker.mjs +40 -0
  22. package/code-tool-worker.mjs.map +1 -0
  23. package/code-tool.d.mts +12 -0
  24. package/code-tool.d.mts.map +1 -0
  25. package/code-tool.d.ts +12 -0
  26. package/code-tool.d.ts.map +1 -0
  27. package/code-tool.js +158 -0
  28. package/code-tool.js.map +1 -0
  29. package/code-tool.mjs +122 -0
  30. package/code-tool.mjs.map +1 -0
  31. package/compat.d.mts +58 -0
  32. package/compat.d.mts.map +1 -0
  33. package/compat.d.ts +58 -0
  34. package/compat.d.ts.map +1 -0
  35. package/compat.js +387 -0
  36. package/compat.js.map +1 -0
  37. package/compat.mjs +378 -0
  38. package/compat.mjs.map +1 -0
  39. package/docs-search-tool.d.mts +44 -0
  40. package/docs-search-tool.d.mts.map +1 -0
  41. package/docs-search-tool.d.ts +44 -0
  42. package/docs-search-tool.d.ts.map +1 -0
  43. package/docs-search-tool.js +43 -0
  44. package/docs-search-tool.js.map +1 -0
  45. package/docs-search-tool.mjs +39 -0
  46. package/docs-search-tool.mjs.map +1 -0
  47. package/dynamic-tools.d.mts +12 -0
  48. package/dynamic-tools.d.mts.map +1 -0
  49. package/dynamic-tools.d.ts +12 -0
  50. package/dynamic-tools.d.ts.map +1 -0
  51. package/dynamic-tools.js +135 -0
  52. package/dynamic-tools.js.map +1 -0
  53. package/dynamic-tools.mjs +132 -0
  54. package/dynamic-tools.mjs.map +1 -0
  55. package/filtering.d.mts +2 -0
  56. package/filtering.d.mts.map +1 -0
  57. package/filtering.d.ts +2 -0
  58. package/filtering.d.ts.map +1 -0
  59. package/filtering.js +20 -0
  60. package/filtering.js.map +1 -0
  61. package/filtering.mjs +13 -0
  62. package/filtering.mjs.map +1 -0
  63. package/headers.d.mts +4 -0
  64. package/headers.d.mts.map +1 -0
  65. package/headers.d.ts +4 -0
  66. package/headers.d.ts.map +1 -0
  67. package/headers.js +13 -0
  68. package/headers.js.map +1 -0
  69. package/headers.mjs +9 -0
  70. package/headers.mjs.map +1 -0
  71. package/http.d.mts +9 -0
  72. package/http.d.mts.map +1 -0
  73. package/http.d.ts +9 -0
  74. package/http.d.ts.map +1 -0
  75. package/http.js +108 -0
  76. package/http.js.map +1 -0
  77. package/http.mjs +100 -0
  78. package/http.mjs.map +1 -0
  79. package/index.d.mts +3 -0
  80. package/index.d.mts.map +1 -0
  81. package/index.d.ts +3 -0
  82. package/index.d.ts.map +1 -0
  83. package/index.js +91 -0
  84. package/index.js.map +1 -0
  85. package/index.mjs +89 -0
  86. package/index.mjs.map +1 -0
  87. package/options.d.mts +20 -0
  88. package/options.d.mts.map +1 -0
  89. package/options.d.ts +20 -0
  90. package/options.d.ts.map +1 -0
  91. package/options.js +424 -0
  92. package/options.js.map +1 -0
  93. package/options.mjs +417 -0
  94. package/options.mjs.map +1 -0
  95. package/package.json +216 -0
  96. package/server.d.mts +35 -0
  97. package/server.d.mts.map +1 -0
  98. package/server.d.ts +35 -0
  99. package/server.d.ts.map +1 -0
  100. package/server.js +175 -0
  101. package/server.js.map +1 -0
  102. package/server.mjs +161 -0
  103. package/server.mjs.map +1 -0
  104. package/src/code-tool-paths.cts +3 -0
  105. package/src/code-tool-types.ts +14 -0
  106. package/src/code-tool-worker.ts +46 -0
  107. package/src/code-tool.ts +147 -0
  108. package/src/compat.ts +483 -0
  109. package/src/docs-search-tool.ts +48 -0
  110. package/src/dynamic-tools.ts +153 -0
  111. package/src/filtering.ts +14 -0
  112. package/src/headers.ts +14 -0
  113. package/src/http.ts +127 -0
  114. package/src/index.ts +108 -0
  115. package/src/options.ts +466 -0
  116. package/src/server.ts +208 -0
  117. package/src/stdio.ts +13 -0
  118. package/src/tools/cart/create-checkout-cart.ts +49 -0
  119. package/src/tools/cart/items/add-cart-items.ts +93 -0
  120. package/src/tools/cart/items/clear-cart-items.ts +47 -0
  121. package/src/tools/cart/items/list-cart-items.ts +47 -0
  122. package/src/tools/cart/items/remove-cart-items.ts +50 -0
  123. package/src/tools/checkout/session/confirm-checkout-checkout-session.ts +101 -0
  124. package/src/tools/checkout/session/create-quote-checkout-session.ts +96 -0
  125. package/src/tools/checkout/session/list-products-checkout-session.ts +47 -0
  126. package/src/tools/checkout/session/retrieve-shipping-info-checkout-session.ts +49 -0
  127. package/src/tools/index.ts +105 -0
  128. package/src/tools/merchants/check-status-merchants.ts +56 -0
  129. package/src/tools/merchants/get-shipping-info-merchants.ts +60 -0
  130. package/src/tools/merchants/list-supported-merchants.ts +52 -0
  131. package/src/tools/orders/retrieve-status-orders.ts +47 -0
  132. package/src/tools/products/retrieve-details-products.ts +48 -0
  133. package/src/tools/products/search-products.ts +78 -0
  134. package/src/tools/products/variant-check/create-products-variant-check.ts +85 -0
  135. package/src/tools/products/variant-check/retrieve-status-products-variant-check.ts +50 -0
  136. package/src/tools/types.ts +103 -0
  137. package/src/tools/wallet/create-card-collection-wallet.ts +49 -0
  138. package/src/tools.ts +1 -0
  139. package/src/tsconfig.json +11 -0
  140. package/stdio.d.mts +3 -0
  141. package/stdio.d.mts.map +1 -0
  142. package/stdio.d.ts +3 -0
  143. package/stdio.d.ts.map +1 -0
  144. package/stdio.js +14 -0
  145. package/stdio.js.map +1 -0
  146. package/stdio.mjs +10 -0
  147. package/stdio.mjs.map +1 -0
  148. package/tools/cart/create-checkout-cart.d.mts +45 -0
  149. package/tools/cart/create-checkout-cart.d.mts.map +1 -0
  150. package/tools/cart/create-checkout-cart.d.ts +45 -0
  151. package/tools/cart/create-checkout-cart.d.ts.map +1 -0
  152. package/tools/cart/create-checkout-cart.js +44 -0
  153. package/tools/cart/create-checkout-cart.js.map +1 -0
  154. package/tools/cart/create-checkout-cart.mjs +40 -0
  155. package/tools/cart/create-checkout-cart.mjs.map +1 -0
  156. package/tools/cart/items/add-cart-items.d.mts +45 -0
  157. package/tools/cart/items/add-cart-items.d.mts.map +1 -0
  158. package/tools/cart/items/add-cart-items.d.ts +45 -0
  159. package/tools/cart/items/add-cart-items.d.ts.map +1 -0
  160. package/tools/cart/items/add-cart-items.js +86 -0
  161. package/tools/cart/items/add-cart-items.js.map +1 -0
  162. package/tools/cart/items/add-cart-items.mjs +82 -0
  163. package/tools/cart/items/add-cart-items.mjs.map +1 -0
  164. package/tools/cart/items/clear-cart-items.d.mts +45 -0
  165. package/tools/cart/items/clear-cart-items.d.mts.map +1 -0
  166. package/tools/cart/items/clear-cart-items.d.ts +45 -0
  167. package/tools/cart/items/clear-cart-items.d.ts.map +1 -0
  168. package/tools/cart/items/clear-cart-items.js +42 -0
  169. package/tools/cart/items/clear-cart-items.js.map +1 -0
  170. package/tools/cart/items/clear-cart-items.mjs +38 -0
  171. package/tools/cart/items/clear-cart-items.mjs.map +1 -0
  172. package/tools/cart/items/list-cart-items.d.mts +45 -0
  173. package/tools/cart/items/list-cart-items.d.mts.map +1 -0
  174. package/tools/cart/items/list-cart-items.d.ts +45 -0
  175. package/tools/cart/items/list-cart-items.d.ts.map +1 -0
  176. package/tools/cart/items/list-cart-items.js +42 -0
  177. package/tools/cart/items/list-cart-items.js.map +1 -0
  178. package/tools/cart/items/list-cart-items.mjs +38 -0
  179. package/tools/cart/items/list-cart-items.mjs.map +1 -0
  180. package/tools/cart/items/remove-cart-items.d.mts +45 -0
  181. package/tools/cart/items/remove-cart-items.d.mts.map +1 -0
  182. package/tools/cart/items/remove-cart-items.d.ts +45 -0
  183. package/tools/cart/items/remove-cart-items.d.ts.map +1 -0
  184. package/tools/cart/items/remove-cart-items.js +45 -0
  185. package/tools/cart/items/remove-cart-items.js.map +1 -0
  186. package/tools/cart/items/remove-cart-items.mjs +41 -0
  187. package/tools/cart/items/remove-cart-items.mjs.map +1 -0
  188. package/tools/checkout/session/confirm-checkout-checkout-session.d.mts +45 -0
  189. package/tools/checkout/session/confirm-checkout-checkout-session.d.mts.map +1 -0
  190. package/tools/checkout/session/confirm-checkout-checkout-session.d.ts +45 -0
  191. package/tools/checkout/session/confirm-checkout-checkout-session.d.ts.map +1 -0
  192. package/tools/checkout/session/confirm-checkout-checkout-session.js +94 -0
  193. package/tools/checkout/session/confirm-checkout-checkout-session.js.map +1 -0
  194. package/tools/checkout/session/confirm-checkout-checkout-session.mjs +90 -0
  195. package/tools/checkout/session/confirm-checkout-checkout-session.mjs.map +1 -0
  196. package/tools/checkout/session/create-quote-checkout-session.d.mts +45 -0
  197. package/tools/checkout/session/create-quote-checkout-session.d.mts.map +1 -0
  198. package/tools/checkout/session/create-quote-checkout-session.d.ts +45 -0
  199. package/tools/checkout/session/create-quote-checkout-session.d.ts.map +1 -0
  200. package/tools/checkout/session/create-quote-checkout-session.js +91 -0
  201. package/tools/checkout/session/create-quote-checkout-session.js.map +1 -0
  202. package/tools/checkout/session/create-quote-checkout-session.mjs +87 -0
  203. package/tools/checkout/session/create-quote-checkout-session.mjs.map +1 -0
  204. package/tools/checkout/session/list-products-checkout-session.d.mts +45 -0
  205. package/tools/checkout/session/list-products-checkout-session.d.mts.map +1 -0
  206. package/tools/checkout/session/list-products-checkout-session.d.ts +45 -0
  207. package/tools/checkout/session/list-products-checkout-session.d.ts.map +1 -0
  208. package/tools/checkout/session/list-products-checkout-session.js +42 -0
  209. package/tools/checkout/session/list-products-checkout-session.js.map +1 -0
  210. package/tools/checkout/session/list-products-checkout-session.mjs +38 -0
  211. package/tools/checkout/session/list-products-checkout-session.mjs.map +1 -0
  212. package/tools/checkout/session/retrieve-shipping-info-checkout-session.d.mts +45 -0
  213. package/tools/checkout/session/retrieve-shipping-info-checkout-session.d.mts.map +1 -0
  214. package/tools/checkout/session/retrieve-shipping-info-checkout-session.d.ts +45 -0
  215. package/tools/checkout/session/retrieve-shipping-info-checkout-session.d.ts.map +1 -0
  216. package/tools/checkout/session/retrieve-shipping-info-checkout-session.js +42 -0
  217. package/tools/checkout/session/retrieve-shipping-info-checkout-session.js.map +1 -0
  218. package/tools/checkout/session/retrieve-shipping-info-checkout-session.mjs +38 -0
  219. package/tools/checkout/session/retrieve-shipping-info-checkout-session.mjs.map +1 -0
  220. package/tools/index.d.mts +10 -0
  221. package/tools/index.d.mts.map +1 -0
  222. package/tools/index.d.ts +10 -0
  223. package/tools/index.d.ts.map +1 -0
  224. package/tools/index.js +89 -0
  225. package/tools/index.js.map +1 -0
  226. package/tools/index.mjs +82 -0
  227. package/tools/index.mjs.map +1 -0
  228. package/tools/merchants/check-status-merchants.d.mts +45 -0
  229. package/tools/merchants/check-status-merchants.d.mts.map +1 -0
  230. package/tools/merchants/check-status-merchants.d.ts +45 -0
  231. package/tools/merchants/check-status-merchants.d.ts.map +1 -0
  232. package/tools/merchants/check-status-merchants.js +48 -0
  233. package/tools/merchants/check-status-merchants.js.map +1 -0
  234. package/tools/merchants/check-status-merchants.mjs +44 -0
  235. package/tools/merchants/check-status-merchants.mjs.map +1 -0
  236. package/tools/merchants/get-shipping-info-merchants.d.mts +45 -0
  237. package/tools/merchants/get-shipping-info-merchants.d.mts.map +1 -0
  238. package/tools/merchants/get-shipping-info-merchants.d.ts +45 -0
  239. package/tools/merchants/get-shipping-info-merchants.d.ts.map +1 -0
  240. package/tools/merchants/get-shipping-info-merchants.js +55 -0
  241. package/tools/merchants/get-shipping-info-merchants.js.map +1 -0
  242. package/tools/merchants/get-shipping-info-merchants.mjs +51 -0
  243. package/tools/merchants/get-shipping-info-merchants.mjs.map +1 -0
  244. package/tools/merchants/list-supported-merchants.d.mts +45 -0
  245. package/tools/merchants/list-supported-merchants.d.mts.map +1 -0
  246. package/tools/merchants/list-supported-merchants.d.ts +45 -0
  247. package/tools/merchants/list-supported-merchants.d.ts.map +1 -0
  248. package/tools/merchants/list-supported-merchants.js +47 -0
  249. package/tools/merchants/list-supported-merchants.js.map +1 -0
  250. package/tools/merchants/list-supported-merchants.mjs +43 -0
  251. package/tools/merchants/list-supported-merchants.mjs.map +1 -0
  252. package/tools/orders/retrieve-status-orders.d.mts +45 -0
  253. package/tools/orders/retrieve-status-orders.d.mts.map +1 -0
  254. package/tools/orders/retrieve-status-orders.d.ts +45 -0
  255. package/tools/orders/retrieve-status-orders.d.ts.map +1 -0
  256. package/tools/orders/retrieve-status-orders.js +42 -0
  257. package/tools/orders/retrieve-status-orders.js.map +1 -0
  258. package/tools/orders/retrieve-status-orders.mjs +38 -0
  259. package/tools/orders/retrieve-status-orders.mjs.map +1 -0
  260. package/tools/products/retrieve-details-products.d.mts +45 -0
  261. package/tools/products/retrieve-details-products.d.mts.map +1 -0
  262. package/tools/products/retrieve-details-products.d.ts +45 -0
  263. package/tools/products/retrieve-details-products.d.ts.map +1 -0
  264. package/tools/products/retrieve-details-products.js +43 -0
  265. package/tools/products/retrieve-details-products.js.map +1 -0
  266. package/tools/products/retrieve-details-products.mjs +39 -0
  267. package/tools/products/retrieve-details-products.mjs.map +1 -0
  268. package/tools/products/search-products.d.mts +45 -0
  269. package/tools/products/search-products.d.mts.map +1 -0
  270. package/tools/products/search-products.d.ts +45 -0
  271. package/tools/products/search-products.d.ts.map +1 -0
  272. package/tools/products/search-products.js +73 -0
  273. package/tools/products/search-products.js.map +1 -0
  274. package/tools/products/search-products.mjs +69 -0
  275. package/tools/products/search-products.mjs.map +1 -0
  276. package/tools/products/variant-check/create-products-variant-check.d.mts +45 -0
  277. package/tools/products/variant-check/create-products-variant-check.d.mts.map +1 -0
  278. package/tools/products/variant-check/create-products-variant-check.d.ts +45 -0
  279. package/tools/products/variant-check/create-products-variant-check.d.ts.map +1 -0
  280. package/tools/products/variant-check/create-products-variant-check.js +79 -0
  281. package/tools/products/variant-check/create-products-variant-check.js.map +1 -0
  282. package/tools/products/variant-check/create-products-variant-check.mjs +75 -0
  283. package/tools/products/variant-check/create-products-variant-check.mjs.map +1 -0
  284. package/tools/products/variant-check/retrieve-status-products-variant-check.d.mts +45 -0
  285. package/tools/products/variant-check/retrieve-status-products-variant-check.d.mts.map +1 -0
  286. package/tools/products/variant-check/retrieve-status-products-variant-check.d.ts +45 -0
  287. package/tools/products/variant-check/retrieve-status-products-variant-check.d.ts.map +1 -0
  288. package/tools/products/variant-check/retrieve-status-products-variant-check.js +43 -0
  289. package/tools/products/variant-check/retrieve-status-products-variant-check.js.map +1 -0
  290. package/tools/products/variant-check/retrieve-status-products-variant-check.mjs +39 -0
  291. package/tools/products/variant-check/retrieve-status-products-variant-check.mjs.map +1 -0
  292. package/tools/types.d.mts +51 -0
  293. package/tools/types.d.mts.map +1 -0
  294. package/tools/types.d.ts +51 -0
  295. package/tools/types.d.ts.map +1 -0
  296. package/tools/types.js +46 -0
  297. package/tools/types.js.map +1 -0
  298. package/tools/types.mjs +42 -0
  299. package/tools/types.mjs.map +1 -0
  300. package/tools/wallet/create-card-collection-wallet.d.mts +45 -0
  301. package/tools/wallet/create-card-collection-wallet.d.mts.map +1 -0
  302. package/tools/wallet/create-card-collection-wallet.d.ts +45 -0
  303. package/tools/wallet/create-card-collection-wallet.d.ts.map +1 -0
  304. package/tools/wallet/create-card-collection-wallet.js +44 -0
  305. package/tools/wallet/create-card-collection-wallet.js.map +1 -0
  306. package/tools/wallet/create-card-collection-wallet.mjs +40 -0
  307. package/tools/wallet/create-card-collection-wallet.mjs.map +1 -0
  308. package/tools.d.mts +2 -0
  309. package/tools.d.mts.map +1 -0
  310. package/tools.d.ts +2 -0
  311. package/tools.d.ts.map +1 -0
  312. package/tools.js +18 -0
  313. package/tools.js.map +1 -0
  314. package/tools.mjs +2 -0
  315. package/tools.mjs.map +1 -0
package/code-tool.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { Endpoint } from "./tools/types.js";
2
+ /**
3
+ * A tool that runs code against a copy of the SDK.
4
+ *
5
+ * Instead of exposing every endpoint as it's own tool, which uses up too many tokens for LLMs to use at once,
6
+ * we expose a single tool that can be used to search for endpoints by name, resource, operation, or tag, and then
7
+ * a generic endpoint that can be used to invoke any endpoint with the provided arguments.
8
+ *
9
+ * @param endpoints - The endpoints to include in the list.
10
+ */
11
+ export declare function codeTool(): Promise<Endpoint>;
12
+ //# sourceMappingURL=code-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tool.d.ts","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"OAKO,EAAE,QAAQ,EAA0B;AAM3C;;;;;;;;GAQG;AACH,wBAAsB,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC,CA8HlD"}
package/code-tool.js ADDED
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.codeTool = codeTool;
38
+ const node_path_1 = require("node:path");
39
+ const node_url_1 = require("node:url");
40
+ /**
41
+ * A tool that runs code against a copy of the SDK.
42
+ *
43
+ * Instead of exposing every endpoint as it's own tool, which uses up too many tokens for LLMs to use at once,
44
+ * we expose a single tool that can be used to search for endpoints by name, resource, operation, or tag, and then
45
+ * a generic endpoint that can be used to invoke any endpoint with the provided arguments.
46
+ *
47
+ * @param endpoints - The endpoints to include in the list.
48
+ */
49
+ async function codeTool() {
50
+ const metadata = { resource: 'all', operation: 'write', tags: [] };
51
+ const tool = {
52
+ name: 'execute',
53
+ description: 'Runs Typescript code to interact with the API.\nYou are a skilled programmer writing code to interface with the service.\nDefine an async function named "run" that takes a single parameter of an initialized client, and it will be run.\nDo not initialize a client, but instead use the client that you are given as a parameter.\nYou will be returned anything that your function returns, plus the results of any console.log statements.\nIf any code triggers an error, the tool will return an error response, so you do not need to add error handling unless you want to output something more helpful than the raw error.\nIt is not necessary to add comments to code, unless by adding those comments you believe that you can generate better code.\nThis code will run in a container, and you will not be able to use fetch or otherwise interact with the network calls other than through the client you are given.\nAny variables you define won\'t live between successive uses of this call, so make sure to return or log any data you might need later.',
54
+ inputSchema: { type: 'object', properties: { code: { type: 'string' } } },
55
+ };
56
+ // Import dynamically to avoid failing at import time in cases where the environment is not well-supported.
57
+ const { newDenoHTTPWorker } = await Promise.resolve().then(() => __importStar(require('@valtown/deno-http-worker')));
58
+ const { workerPath } = await Promise.resolve().then(() => __importStar(require('./code-tool-paths.cjs')));
59
+ const handler = async (client, args) => {
60
+ const baseURLHostname = new URL(client.baseURL).hostname;
61
+ const { code } = args;
62
+ const worker = await newDenoHTTPWorker((0, node_url_1.pathToFileURL)(workerPath), {
63
+ runFlags: [
64
+ `--node-modules-dir=manual`,
65
+ `--allow-read=code-tool-worker.mjs,${workerPath.replace(/([\/\\]node_modules)[\/\\].+$/, '$1')}/`,
66
+ `--allow-net=${baseURLHostname}`,
67
+ // Allow environment variables because instantiating the client will try to read from them,
68
+ // even though they are not set.
69
+ '--allow-env',
70
+ ],
71
+ printOutput: true,
72
+ spawnOptions: {
73
+ cwd: (0, node_path_1.dirname)(workerPath),
74
+ },
75
+ });
76
+ try {
77
+ const resp = await new Promise((resolve, reject) => {
78
+ worker.addEventListener('exit', (exitCode) => {
79
+ reject(new Error(`Worker exited with code ${exitCode}`));
80
+ });
81
+ const opts = {
82
+ baseURL: client.baseURL,
83
+ apiKey: client.apiKey,
84
+ accessToken: client.accessToken,
85
+ defaultHeaders: {
86
+ 'X-Stainless-MCP': 'true',
87
+ },
88
+ };
89
+ const req = worker.request('http://localhost', {
90
+ headers: {
91
+ 'content-type': 'application/json',
92
+ },
93
+ method: 'POST',
94
+ }, (resp) => {
95
+ const body = [];
96
+ resp.on('error', (err) => {
97
+ reject(err);
98
+ });
99
+ resp.on('data', (chunk) => {
100
+ body.push(chunk);
101
+ });
102
+ resp.on('end', () => {
103
+ resolve(new Response(Buffer.concat(body).toString(), {
104
+ status: resp.statusCode ?? 200,
105
+ headers: resp.headers,
106
+ }));
107
+ });
108
+ });
109
+ const body = JSON.stringify({
110
+ opts,
111
+ code,
112
+ });
113
+ req.write(body, (err) => {
114
+ if (err !== null && err !== undefined) {
115
+ reject(err);
116
+ }
117
+ });
118
+ req.end();
119
+ });
120
+ if (resp.status === 200) {
121
+ const { result, logLines, errLines } = (await resp.json());
122
+ const returnOutput = result === null ? null
123
+ : result === undefined ? null
124
+ : {
125
+ type: 'text',
126
+ text: typeof result === 'string' ? result : JSON.stringify(result),
127
+ };
128
+ const logOutput = logLines.length === 0 ?
129
+ null
130
+ : {
131
+ type: 'text',
132
+ text: logLines.join('\n'),
133
+ };
134
+ const errOutput = errLines.length === 0 ?
135
+ null
136
+ : {
137
+ type: 'text',
138
+ text: 'Error output:\n' + errLines.join('\n'),
139
+ };
140
+ return {
141
+ content: [returnOutput, logOutput, errOutput].filter((block) => block !== null),
142
+ };
143
+ }
144
+ else {
145
+ const { message } = (await resp.json());
146
+ throw new Error(message);
147
+ }
148
+ }
149
+ catch (e) {
150
+ throw e;
151
+ }
152
+ finally {
153
+ worker.terminate();
154
+ }
155
+ };
156
+ return { metadata, tool, handler };
157
+ }
158
+ //# sourceMappingURL=code-tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tool.js","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBtF,4BA8HC;AAhJD,yCAAoC;AACpC,uCAAyC;AAQzC;;;;;;;;GAQG;AACI,KAAK,UAAU,QAAQ;IAC5B,MAAM,QAAQ,GAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;IAC7E,MAAM,IAAI,GAAS;QACjB,IAAI,EAAE,SAAS;QACf,WAAW,EACT,khCAAkhC;QACphC,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE;KAC1E,CAAC;IAEF,2GAA2G;IAC3G,MAAM,EAAE,iBAAiB,EAAE,GAAG,wDAAa,2BA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AQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACrC,CAAC"}
package/code-tool.mjs ADDED
@@ -0,0 +1,122 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+ import { dirname } from 'node:path';
3
+ import { pathToFileURL } from 'node:url';
4
+ /**
5
+ * A tool that runs code against a copy of the SDK.
6
+ *
7
+ * Instead of exposing every endpoint as it's own tool, which uses up too many tokens for LLMs to use at once,
8
+ * we expose a single tool that can be used to search for endpoints by name, resource, operation, or tag, and then
9
+ * a generic endpoint that can be used to invoke any endpoint with the provided arguments.
10
+ *
11
+ * @param endpoints - The endpoints to include in the list.
12
+ */
13
+ export async function codeTool() {
14
+ const metadata = { resource: 'all', operation: 'write', tags: [] };
15
+ const tool = {
16
+ name: 'execute',
17
+ description: 'Runs Typescript code to interact with the API.\nYou are a skilled programmer writing code to interface with the service.\nDefine an async function named "run" that takes a single parameter of an initialized client, and it will be run.\nDo not initialize a client, but instead use the client that you are given as a parameter.\nYou will be returned anything that your function returns, plus the results of any console.log statements.\nIf any code triggers an error, the tool will return an error response, so you do not need to add error handling unless you want to output something more helpful than the raw error.\nIt is not necessary to add comments to code, unless by adding those comments you believe that you can generate better code.\nThis code will run in a container, and you will not be able to use fetch or otherwise interact with the network calls other than through the client you are given.\nAny variables you define won\'t live between successive uses of this call, so make sure to return or log any data you might need later.',
18
+ inputSchema: { type: 'object', properties: { code: { type: 'string' } } },
19
+ };
20
+ // Import dynamically to avoid failing at import time in cases where the environment is not well-supported.
21
+ const { newDenoHTTPWorker } = await import('@valtown/deno-http-worker');
22
+ const { workerPath } = await import('./code-tool-paths.cjs');
23
+ const handler = async (client, args) => {
24
+ const baseURLHostname = new URL(client.baseURL).hostname;
25
+ const { code } = args;
26
+ const worker = await newDenoHTTPWorker(pathToFileURL(workerPath), {
27
+ runFlags: [
28
+ `--node-modules-dir=manual`,
29
+ `--allow-read=code-tool-worker.mjs,${workerPath.replace(/([\/\\]node_modules)[\/\\].+$/, '$1')}/`,
30
+ `--allow-net=${baseURLHostname}`,
31
+ // Allow environment variables because instantiating the client will try to read from them,
32
+ // even though they are not set.
33
+ '--allow-env',
34
+ ],
35
+ printOutput: true,
36
+ spawnOptions: {
37
+ cwd: dirname(workerPath),
38
+ },
39
+ });
40
+ try {
41
+ const resp = await new Promise((resolve, reject) => {
42
+ worker.addEventListener('exit', (exitCode) => {
43
+ reject(new Error(`Worker exited with code ${exitCode}`));
44
+ });
45
+ const opts = {
46
+ baseURL: client.baseURL,
47
+ apiKey: client.apiKey,
48
+ accessToken: client.accessToken,
49
+ defaultHeaders: {
50
+ 'X-Stainless-MCP': 'true',
51
+ },
52
+ };
53
+ const req = worker.request('http://localhost', {
54
+ headers: {
55
+ 'content-type': 'application/json',
56
+ },
57
+ method: 'POST',
58
+ }, (resp) => {
59
+ const body = [];
60
+ resp.on('error', (err) => {
61
+ reject(err);
62
+ });
63
+ resp.on('data', (chunk) => {
64
+ body.push(chunk);
65
+ });
66
+ resp.on('end', () => {
67
+ resolve(new Response(Buffer.concat(body).toString(), {
68
+ status: resp.statusCode ?? 200,
69
+ headers: resp.headers,
70
+ }));
71
+ });
72
+ });
73
+ const body = JSON.stringify({
74
+ opts,
75
+ code,
76
+ });
77
+ req.write(body, (err) => {
78
+ if (err !== null && err !== undefined) {
79
+ reject(err);
80
+ }
81
+ });
82
+ req.end();
83
+ });
84
+ if (resp.status === 200) {
85
+ const { result, logLines, errLines } = (await resp.json());
86
+ const returnOutput = result === null ? null
87
+ : result === undefined ? null
88
+ : {
89
+ type: 'text',
90
+ text: typeof result === 'string' ? result : JSON.stringify(result),
91
+ };
92
+ const logOutput = logLines.length === 0 ?
93
+ null
94
+ : {
95
+ type: 'text',
96
+ text: logLines.join('\n'),
97
+ };
98
+ const errOutput = errLines.length === 0 ?
99
+ null
100
+ : {
101
+ type: 'text',
102
+ text: 'Error output:\n' + errLines.join('\n'),
103
+ };
104
+ return {
105
+ content: [returnOutput, logOutput, errOutput].filter((block) => block !== null),
106
+ };
107
+ }
108
+ else {
109
+ const { message } = (await resp.json());
110
+ throw new Error(message);
111
+ }
112
+ }
113
+ catch (e) {
114
+ throw e;
115
+ }
116
+ finally {
117
+ worker.terminate();
118
+ }
119
+ };
120
+ return { metadata, tool, handler };
121
+ }
122
+ //# sourceMappingURL=code-tool.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tool.mjs","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,OAAO,EAAE,MAAM,WAAW;OAC5B,EAAE,aAAa,EAAE,MAAM,UAAU;AAQxC;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ;IAC5B,MAAM,QAAQ,GAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;IAC7E,MAAM,IAAI,GAAS;QACjB,IAAI,EAAE,SAAS;QACf,WAAW,EACT,khCAAkhC;QACphC,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE;KAC1E,CAAC;IAEF,2GAA2G;IAC3G,MAAM,EAAE,iBAAiB,EAAE,GAAG,MAAM,MAAM,CAAC,2BAA2B,CAAC,CAAC;IACxE,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC,uBAAuB,CAAC,CAAC;IAE7D,MAAM,OAAO,GAAG,KAAK,EAAE,MAAgB,EAAE,IAAa,EAAE,EAAE;QACxD,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC;QACzD,MAAM,EAAE,IAAI,EAAE,GAAG,IAAwB,CAAC;QAE1C,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE;YAChE,QAAQ,EAAE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AC;oBACrB,IAAI;oBACN,CAAC,CAAC;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;qBAC1B,CAAC;gBACN,MAAM,SAAS,GACb,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC;oBACrB,IAAI;oBACN,CAAC,CAAC;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,iBAAiB,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;qBAC9C,CAAC;gBACN,OAAO;oBACL,OAAO,EAAE,CAAC,YAAY,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC;iBAChF,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAgB,CAAC;gBACvD,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,CAAC,CAAC;QACV,CAAC;gBAAS,CAAC;YACT,MAAM,CAAC,SAAS,EAAE,CAAC;QACrB,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACrC,CAAC"}
package/compat.d.mts ADDED
@@ -0,0 +1,58 @@
1
+ import { Tool } from '@modelcontextprotocol/sdk/types.js';
2
+ import { z } from 'zod';
3
+ import { Endpoint } from "./tools.mjs";
4
+ export interface ClientCapabilities {
5
+ topLevelUnions: boolean;
6
+ validJson: boolean;
7
+ refs: boolean;
8
+ unions: boolean;
9
+ formats: boolean;
10
+ toolNameLength: number | undefined;
11
+ }
12
+ export declare const defaultClientCapabilities: ClientCapabilities;
13
+ export declare const ClientType: z.ZodEnum<["openai-agents", "claude", "claude-code", "cursor", "infer"]>;
14
+ export type ClientType = z.infer<typeof ClientType>;
15
+ export declare const knownClients: Record<Exclude<ClientType, 'infer'>, ClientCapabilities>;
16
+ /**
17
+ * Attempts to parse strings into JSON objects
18
+ */
19
+ export declare function parseEmbeddedJSON(args: Record<string, unknown>, schema: Record<string, unknown>): Record<string, unknown>;
20
+ export type JSONSchema = {
21
+ type?: string;
22
+ properties?: Record<string, JSONSchema>;
23
+ required?: string[];
24
+ anyOf?: JSONSchema[];
25
+ $ref?: string;
26
+ $defs?: Record<string, JSONSchema>;
27
+ [key: string]: any;
28
+ };
29
+ /**
30
+ * Truncates tool names to the specified length while ensuring uniqueness.
31
+ * If truncation would cause duplicate names, appends a number to make them unique.
32
+ */
33
+ export declare function truncateToolNames(names: string[], maxLength: number): Map<string, string>;
34
+ /**
35
+ * Removes top-level unions from a tool by splitting it into multiple tools,
36
+ * one for each variant in the union.
37
+ */
38
+ export declare function removeTopLevelUnions(tool: Tool): Tool[];
39
+ declare function findUsedDefs(schema: JSONSchema, defs: Record<string, JSONSchema>, visited?: Set<string>): Record<string, JSONSchema>;
40
+ export { findUsedDefs };
41
+ /**
42
+ * Inlines all $refs in a schema, eliminating $defs.
43
+ * If a circular reference is detected, the circular property is removed.
44
+ */
45
+ export declare function inlineRefs(schema: JSONSchema): JSONSchema;
46
+ /**
47
+ * Removes anyOf fields from a schema, using only the first variant.
48
+ */
49
+ export declare function removeAnyOf(schema: JSONSchema): JSONSchema;
50
+ /**
51
+ * Removes format fields from a schema and appends them to the description.
52
+ */
53
+ export declare function removeFormats(schema: JSONSchema, formatsCapability: boolean): JSONSchema;
54
+ /**
55
+ * Applies all compatibility transformations to the endpoints based on the provided capabilities.
56
+ */
57
+ export declare function applyCompatibilityTransformations(endpoints: Endpoint[], capabilities: ClientCapabilities): Endpoint[];
58
+ //# sourceMappingURL=compat.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compat.d.mts","sourceRoot":"","sources":["src/compat.ts"],"names":[],"mappings":"O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MAAM,EAAE,MAAM,CAAC,CAwCzF;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,CAyCvD;AAED,iBAAS,YAAY,CACnB,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,EAChC,OAAO,GAAE,GAAG,CAAC,MAAM,CAAa,GAC/B,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CA6B5B;AAGD,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB;;;GAGG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAazD;AAoED;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CA0C1D;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,UAAU,EAAE,iBAAiB,EAAE,OAAO,GAAG,UAAU,CAkCxF;AAED;;GAEG;AACH,wBAAgB,iCAAiC,CAC/C,SAAS,EAAE,QAAQ,EAAE,EACrB,YAAY,EAAE,kBAAkB,GAC/B,QAAQ,EAAE,CAiEZ"}
package/compat.d.ts ADDED
@@ -0,0 +1,58 @@
1
+ import { Tool } from '@modelcontextprotocol/sdk/types.js';
2
+ import { z } from 'zod';
3
+ import { Endpoint } from "./tools.js";
4
+ export interface ClientCapabilities {
5
+ topLevelUnions: boolean;
6
+ validJson: boolean;
7
+ refs: boolean;
8
+ unions: boolean;
9
+ formats: boolean;
10
+ toolNameLength: number | undefined;
11
+ }
12
+ export declare const defaultClientCapabilities: ClientCapabilities;
13
+ export declare const ClientType: z.ZodEnum<["openai-agents", "claude", "claude-code", "cursor", "infer"]>;
14
+ export type ClientType = z.infer<typeof ClientType>;
15
+ export declare const knownClients: Record<Exclude<ClientType, 'infer'>, ClientCapabilities>;
16
+ /**
17
+ * Attempts to parse strings into JSON objects
18
+ */
19
+ export declare function parseEmbeddedJSON(args: Record<string, unknown>, schema: Record<string, unknown>): Record<string, unknown>;
20
+ export type JSONSchema = {
21
+ type?: string;
22
+ properties?: Record<string, JSONSchema>;
23
+ required?: string[];
24
+ anyOf?: JSONSchema[];
25
+ $ref?: string;
26
+ $defs?: Record<string, JSONSchema>;
27
+ [key: string]: any;
28
+ };
29
+ /**
30
+ * Truncates tool names to the specified length while ensuring uniqueness.
31
+ * If truncation would cause duplicate names, appends a number to make them unique.
32
+ */
33
+ export declare function truncateToolNames(names: string[], maxLength: number): Map<string, string>;
34
+ /**
35
+ * Removes top-level unions from a tool by splitting it into multiple tools,
36
+ * one for each variant in the union.
37
+ */
38
+ export declare function removeTopLevelUnions(tool: Tool): Tool[];
39
+ declare function findUsedDefs(schema: JSONSchema, defs: Record<string, JSONSchema>, visited?: Set<string>): Record<string, JSONSchema>;
40
+ export { findUsedDefs };
41
+ /**
42
+ * Inlines all $refs in a schema, eliminating $defs.
43
+ * If a circular reference is detected, the circular property is removed.
44
+ */
45
+ export declare function inlineRefs(schema: JSONSchema): JSONSchema;
46
+ /**
47
+ * Removes anyOf fields from a schema, using only the first variant.
48
+ */
49
+ export declare function removeAnyOf(schema: JSONSchema): JSONSchema;
50
+ /**
51
+ * Removes format fields from a schema and appends them to the description.
52
+ */
53
+ export declare function removeFormats(schema: JSONSchema, formatsCapability: boolean): JSONSchema;
54
+ /**
55
+ * Applies all compatibility transformations to the endpoints based on the provided capabilities.
56
+ */
57
+ export declare function applyCompatibilityTransformations(endpoints: Endpoint[], capabilities: ClientCapabilities): Endpoint[];
58
+ //# sourceMappingURL=compat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compat.d.ts","sourceRoot":"","sources":["src/compat.ts"],"names":[],"mappings":"OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC;OAClD,EAAE,CAAC,EAAE,MAAM,KAAK;OAChB,EAAE,QAAQ,EAAE;AAEnB,MAAM,WAAW,kBAAkB;IACjC,cAAc,EAAE,OAAO,CAAC;IACxB,SAAS,EAAE,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