@beeper/desktop-mcp 4.2.2 → 4.6.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 (384) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +28 -173
  3. package/auth.d.mts +6 -0
  4. package/auth.d.mts.map +1 -0
  5. package/auth.d.ts +6 -0
  6. package/auth.d.ts.map +1 -0
  7. package/auth.js +37 -0
  8. package/auth.js.map +1 -0
  9. package/auth.mjs +32 -0
  10. package/auth.mjs.map +1 -0
  11. package/code-tool-types.d.mts +7 -7
  12. package/code-tool-types.d.mts.map +1 -1
  13. package/code-tool-types.d.ts +7 -7
  14. package/code-tool-types.d.ts.map +1 -1
  15. package/code-tool-worker.d.mts.map +1 -1
  16. package/code-tool-worker.d.ts.map +1 -1
  17. package/code-tool-worker.js +215 -13
  18. package/code-tool-worker.js.map +1 -1
  19. package/code-tool-worker.mjs +215 -13
  20. package/code-tool-worker.mjs.map +1 -1
  21. package/code-tool.d.mts +13 -4
  22. package/code-tool.d.mts.map +1 -1
  23. package/code-tool.d.ts +13 -4
  24. package/code-tool.d.ts.map +1 -1
  25. package/code-tool.js +279 -100
  26. package/code-tool.js.map +1 -1
  27. package/code-tool.mjs +276 -100
  28. package/code-tool.mjs.map +1 -1
  29. package/http.d.mts +6 -9
  30. package/http.d.mts.map +1 -1
  31. package/http.d.ts +6 -9
  32. package/http.d.ts.map +1 -1
  33. package/http.js +81 -47
  34. package/http.js.map +1 -1
  35. package/http.mjs +80 -43
  36. package/http.mjs.map +1 -1
  37. package/index.js +19 -50
  38. package/index.js.map +1 -1
  39. package/index.mjs +19 -50
  40. package/index.mjs.map +1 -1
  41. package/instructions.d.mts +2 -0
  42. package/instructions.d.mts.map +1 -0
  43. package/instructions.d.ts +2 -0
  44. package/instructions.d.ts.map +1 -0
  45. package/instructions.js +48 -0
  46. package/instructions.js.map +1 -0
  47. package/instructions.mjs +45 -0
  48. package/instructions.mjs.map +1 -0
  49. package/logger.d.mts +7 -0
  50. package/logger.d.mts.map +1 -0
  51. package/logger.d.ts +7 -0
  52. package/logger.d.ts.map +1 -0
  53. package/logger.js +29 -0
  54. package/logger.js.map +1 -0
  55. package/logger.mjs +22 -0
  56. package/logger.mjs.map +1 -0
  57. package/methods.d.mts +10 -0
  58. package/methods.d.mts.map +1 -0
  59. package/methods.d.ts +10 -0
  60. package/methods.d.ts.map +1 -0
  61. package/methods.js +203 -0
  62. package/methods.js.map +1 -0
  63. package/methods.mjs +199 -0
  64. package/methods.mjs.map +1 -0
  65. package/options.d.mts +9 -10
  66. package/options.d.mts.map +1 -1
  67. package/options.d.ts +9 -10
  68. package/options.d.ts.map +1 -1
  69. package/options.js +52 -360
  70. package/options.js.map +1 -1
  71. package/options.mjs +52 -360
  72. package/options.mjs.map +1 -1
  73. package/package.json +70 -82
  74. package/server.d.mts +10 -16
  75. package/server.d.mts.map +1 -1
  76. package/server.d.ts +10 -16
  77. package/server.d.ts.map +1 -1
  78. package/server.js +82 -105
  79. package/server.js.map +1 -1
  80. package/server.mjs +81 -100
  81. package/server.mjs.map +1 -1
  82. package/src/auth.ts +42 -0
  83. package/src/code-tool-types.ts +8 -5
  84. package/src/code-tool-worker.ts +265 -18
  85. package/src/code-tool.ts +360 -118
  86. package/src/http.ts +99 -50
  87. package/src/index.ts +22 -63
  88. package/src/instructions.ts +67 -0
  89. package/src/logger.ts +28 -0
  90. package/src/methods.ts +224 -0
  91. package/src/options.ts +70 -384
  92. package/src/server.ts +95 -121
  93. package/src/stdio.ts +6 -5
  94. package/src/{tools/types.ts → types.ts} +25 -5
  95. package/src/util.ts +25 -0
  96. package/stdio.d.mts +1 -1
  97. package/stdio.d.mts.map +1 -1
  98. package/stdio.d.ts +1 -1
  99. package/stdio.d.ts.map +1 -1
  100. package/stdio.js +5 -4
  101. package/stdio.js.map +1 -1
  102. package/stdio.mjs +5 -4
  103. package/stdio.mjs.map +1 -1
  104. package/{tools/types.d.mts → types.d.mts} +10 -2
  105. package/types.d.mts.map +1 -0
  106. package/{tools/types.d.ts → types.d.ts} +10 -2
  107. package/types.d.ts.map +1 -0
  108. package/{tools/types.js → types.js} +12 -0
  109. package/types.js.map +1 -0
  110. package/{tools/types.mjs → types.mjs} +11 -0
  111. package/types.mjs.map +1 -0
  112. package/util.d.mts +4 -0
  113. package/util.d.mts.map +1 -0
  114. package/util.d.ts +4 -0
  115. package/util.d.ts.map +1 -0
  116. package/util.js +30 -0
  117. package/util.js.map +1 -0
  118. package/util.mjs +24 -0
  119. package/util.mjs.map +1 -0
  120. package/compat.d.mts +0 -58
  121. package/compat.d.mts.map +0 -1
  122. package/compat.d.ts +0 -58
  123. package/compat.d.ts.map +0 -1
  124. package/compat.js +0 -387
  125. package/compat.js.map +0 -1
  126. package/compat.mjs +0 -378
  127. package/compat.mjs.map +0 -1
  128. package/docs-search-tool.d.mts +0 -44
  129. package/docs-search-tool.d.mts.map +0 -1
  130. package/docs-search-tool.d.ts +0 -44
  131. package/docs-search-tool.d.ts.map +0 -1
  132. package/docs-search-tool.js +0 -43
  133. package/docs-search-tool.js.map +0 -1
  134. package/docs-search-tool.mjs +0 -39
  135. package/docs-search-tool.mjs.map +0 -1
  136. package/dynamic-tools.d.mts +0 -12
  137. package/dynamic-tools.d.mts.map +0 -1
  138. package/dynamic-tools.d.ts +0 -12
  139. package/dynamic-tools.d.ts.map +0 -1
  140. package/dynamic-tools.js +0 -135
  141. package/dynamic-tools.js.map +0 -1
  142. package/dynamic-tools.mjs +0 -132
  143. package/dynamic-tools.mjs.map +0 -1
  144. package/filtering.d.mts +0 -2
  145. package/filtering.d.mts.map +0 -1
  146. package/filtering.d.ts +0 -2
  147. package/filtering.d.ts.map +0 -1
  148. package/filtering.js +0 -20
  149. package/filtering.js.map +0 -1
  150. package/filtering.mjs +0 -13
  151. package/filtering.mjs.map +0 -1
  152. package/handlers/get-accounts.d.mts +0 -3
  153. package/handlers/get-accounts.d.mts.map +0 -1
  154. package/handlers/get-accounts.d.ts +0 -3
  155. package/handlers/get-accounts.d.ts.map +0 -1
  156. package/handlers/get-accounts.js +0 -32
  157. package/handlers/get-accounts.js.map +0 -1
  158. package/handlers/get-accounts.mjs +0 -28
  159. package/handlers/get-accounts.mjs.map +0 -1
  160. package/handlers/get-chat.d.mts +0 -3
  161. package/handlers/get-chat.d.mts.map +0 -1
  162. package/handlers/get-chat.d.ts +0 -3
  163. package/handlers/get-chat.d.ts.map +0 -1
  164. package/handlers/get-chat.js +0 -20
  165. package/handlers/get-chat.js.map +0 -1
  166. package/handlers/get-chat.mjs +0 -16
  167. package/handlers/get-chat.mjs.map +0 -1
  168. package/handlers/index.d.mts +0 -3
  169. package/handlers/index.d.mts.map +0 -1
  170. package/handlers/index.d.ts +0 -3
  171. package/handlers/index.d.ts.map +0 -1
  172. package/handlers/index.js +0 -30
  173. package/handlers/index.js.map +0 -1
  174. package/handlers/index.mjs +0 -27
  175. package/handlers/index.mjs.map +0 -1
  176. package/handlers/list-chats.d.mts +0 -3
  177. package/handlers/list-chats.d.mts.map +0 -1
  178. package/handlers/list-chats.d.ts +0 -3
  179. package/handlers/list-chats.d.ts.map +0 -1
  180. package/handlers/list-chats.js +0 -46
  181. package/handlers/list-chats.js.map +0 -1
  182. package/handlers/list-chats.mjs +0 -42
  183. package/handlers/list-chats.mjs.map +0 -1
  184. package/handlers/list-messages.d.mts +0 -3
  185. package/handlers/list-messages.d.mts.map +0 -1
  186. package/handlers/list-messages.d.ts +0 -3
  187. package/handlers/list-messages.d.ts.map +0 -1
  188. package/handlers/list-messages.js +0 -34
  189. package/handlers/list-messages.js.map +0 -1
  190. package/handlers/list-messages.mjs +0 -30
  191. package/handlers/list-messages.mjs.map +0 -1
  192. package/handlers/open-app.d.mts +0 -3
  193. package/handlers/open-app.d.mts.map +0 -1
  194. package/handlers/open-app.d.ts +0 -3
  195. package/handlers/open-app.d.ts.map +0 -1
  196. package/handlers/open-app.js +0 -26
  197. package/handlers/open-app.js.map +0 -1
  198. package/handlers/open-app.mjs +0 -22
  199. package/handlers/open-app.mjs.map +0 -1
  200. package/handlers/search-chats.d.mts +0 -3
  201. package/handlers/search-chats.d.mts.map +0 -1
  202. package/handlers/search-chats.d.ts +0 -3
  203. package/handlers/search-chats.d.ts.map +0 -1
  204. package/handlers/search-chats.js +0 -38
  205. package/handlers/search-chats.js.map +0 -1
  206. package/handlers/search-chats.mjs +0 -34
  207. package/handlers/search-chats.mjs.map +0 -1
  208. package/handlers/search-messages.d.mts +0 -3
  209. package/handlers/search-messages.d.mts.map +0 -1
  210. package/handlers/search-messages.d.ts +0 -3
  211. package/handlers/search-messages.d.ts.map +0 -1
  212. package/handlers/search-messages.js +0 -11
  213. package/handlers/search-messages.js.map +0 -1
  214. package/handlers/search-messages.mjs +0 -7
  215. package/handlers/search-messages.mjs.map +0 -1
  216. package/handlers/search.d.mts +0 -3
  217. package/handlers/search.d.mts.map +0 -1
  218. package/handlers/search.d.ts +0 -3
  219. package/handlers/search.d.ts.map +0 -1
  220. package/handlers/search.js +0 -29
  221. package/handlers/search.js.map +0 -1
  222. package/handlers/search.mjs +0 -25
  223. package/handlers/search.mjs.map +0 -1
  224. package/handlers/send-message.d.mts +0 -3
  225. package/handlers/send-message.d.mts.map +0 -1
  226. package/handlers/send-message.d.ts +0 -3
  227. package/handlers/send-message.d.ts.map +0 -1
  228. package/handlers/send-message.js +0 -20
  229. package/handlers/send-message.js.map +0 -1
  230. package/handlers/send-message.mjs +0 -16
  231. package/handlers/send-message.mjs.map +0 -1
  232. package/handlers/utils.d.mts +0 -29
  233. package/handlers/utils.d.mts.map +0 -1
  234. package/handlers/utils.d.ts +0 -29
  235. package/handlers/utils.d.ts.map +0 -1
  236. package/handlers/utils.js +0 -296
  237. package/handlers/utils.js.map +0 -1
  238. package/handlers/utils.mjs +0 -282
  239. package/handlers/utils.mjs.map +0 -1
  240. package/headers.d.mts +0 -4
  241. package/headers.d.mts.map +0 -1
  242. package/headers.d.ts +0 -4
  243. package/headers.d.ts.map +0 -1
  244. package/headers.js +0 -22
  245. package/headers.js.map +0 -1
  246. package/headers.mjs +0 -18
  247. package/headers.mjs.map +0 -1
  248. package/src/compat.ts +0 -483
  249. package/src/docs-search-tool.ts +0 -48
  250. package/src/dynamic-tools.ts +0 -159
  251. package/src/filtering.ts +0 -14
  252. package/src/handlers/get-accounts.ts +0 -28
  253. package/src/handlers/get-chat.ts +0 -18
  254. package/src/handlers/index.ts +0 -29
  255. package/src/handlers/list-chats.ts +0 -47
  256. package/src/handlers/list-messages.ts +0 -33
  257. package/src/handlers/open-app.ts +0 -20
  258. package/src/handlers/search-chats.ts +0 -39
  259. package/src/handlers/search-messages.ts +0 -8
  260. package/src/handlers/search.ts +0 -24
  261. package/src/handlers/send-message.ts +0 -17
  262. package/src/handlers/utils.ts +0 -381
  263. package/src/headers.ts +0 -23
  264. package/src/tools/accounts/get-accounts.ts +0 -34
  265. package/src/tools/chats/archive-chat.ts +0 -43
  266. package/src/tools/chats/get-chat.ts +0 -45
  267. package/src/tools/chats/reminders/clear-chat-reminder.ts +0 -41
  268. package/src/tools/chats/reminders/set-chat-reminder.ts +0 -54
  269. package/src/tools/chats/search-chats.ts +0 -104
  270. package/src/tools/index.ts +0 -92
  271. package/src/tools/messages/list-messages.ts +0 -51
  272. package/src/tools/messages/search-messages.ts +0 -123
  273. package/src/tools/messages/send-message.ts +0 -47
  274. package/src/tools/top-level/focus-app.ts +0 -52
  275. package/src/tools/top-level/search.ts +0 -41
  276. package/src/tools.ts +0 -1
  277. package/tools/accounts/get-accounts.d.mts +0 -45
  278. package/tools/accounts/get-accounts.d.mts.map +0 -1
  279. package/tools/accounts/get-accounts.d.ts +0 -45
  280. package/tools/accounts/get-accounts.d.ts.map +0 -1
  281. package/tools/accounts/get-accounts.js +0 -31
  282. package/tools/accounts/get-accounts.js.map +0 -1
  283. package/tools/accounts/get-accounts.mjs +0 -27
  284. package/tools/accounts/get-accounts.mjs.map +0 -1
  285. package/tools/chats/archive-chat.d.mts +0 -45
  286. package/tools/chats/archive-chat.d.mts.map +0 -1
  287. package/tools/chats/archive-chat.d.ts +0 -45
  288. package/tools/chats/archive-chat.d.ts.map +0 -1
  289. package/tools/chats/archive-chat.js +0 -40
  290. package/tools/chats/archive-chat.js.map +0 -1
  291. package/tools/chats/archive-chat.mjs +0 -36
  292. package/tools/chats/archive-chat.mjs.map +0 -1
  293. package/tools/chats/get-chat.d.mts +0 -45
  294. package/tools/chats/get-chat.d.mts.map +0 -1
  295. package/tools/chats/get-chat.d.ts +0 -45
  296. package/tools/chats/get-chat.d.ts.map +0 -1
  297. package/tools/chats/get-chat.js +0 -41
  298. package/tools/chats/get-chat.js.map +0 -1
  299. package/tools/chats/get-chat.mjs +0 -37
  300. package/tools/chats/get-chat.mjs.map +0 -1
  301. package/tools/chats/reminders/clear-chat-reminder.d.mts +0 -45
  302. package/tools/chats/reminders/clear-chat-reminder.d.mts.map +0 -1
  303. package/tools/chats/reminders/clear-chat-reminder.d.ts +0 -45
  304. package/tools/chats/reminders/clear-chat-reminder.d.ts.map +0 -1
  305. package/tools/chats/reminders/clear-chat-reminder.js +0 -38
  306. package/tools/chats/reminders/clear-chat-reminder.js.map +0 -1
  307. package/tools/chats/reminders/clear-chat-reminder.mjs +0 -34
  308. package/tools/chats/reminders/clear-chat-reminder.mjs.map +0 -1
  309. package/tools/chats/reminders/set-chat-reminder.d.mts +0 -45
  310. package/tools/chats/reminders/set-chat-reminder.d.mts.map +0 -1
  311. package/tools/chats/reminders/set-chat-reminder.d.ts +0 -45
  312. package/tools/chats/reminders/set-chat-reminder.d.ts.map +0 -1
  313. package/tools/chats/reminders/set-chat-reminder.js +0 -51
  314. package/tools/chats/reminders/set-chat-reminder.js.map +0 -1
  315. package/tools/chats/reminders/set-chat-reminder.mjs +0 -47
  316. package/tools/chats/reminders/set-chat-reminder.mjs.map +0 -1
  317. package/tools/chats/search-chats.d.mts +0 -45
  318. package/tools/chats/search-chats.d.mts.map +0 -1
  319. package/tools/chats/search-chats.d.ts +0 -45
  320. package/tools/chats/search-chats.d.ts.map +0 -1
  321. package/tools/chats/search-chats.js +0 -92
  322. package/tools/chats/search-chats.js.map +0 -1
  323. package/tools/chats/search-chats.mjs +0 -88
  324. package/tools/chats/search-chats.mjs.map +0 -1
  325. package/tools/index.d.mts +0 -10
  326. package/tools/index.d.mts.map +0 -1
  327. package/tools/index.d.ts +0 -10
  328. package/tools/index.d.ts.map +0 -1
  329. package/tools/index.js +0 -76
  330. package/tools/index.js.map +0 -1
  331. package/tools/index.mjs +0 -69
  332. package/tools/index.mjs.map +0 -1
  333. package/tools/messages/list-messages.d.mts +0 -45
  334. package/tools/messages/list-messages.d.mts.map +0 -1
  335. package/tools/messages/list-messages.d.ts +0 -45
  336. package/tools/messages/list-messages.d.ts.map +0 -1
  337. package/tools/messages/list-messages.js +0 -47
  338. package/tools/messages/list-messages.js.map +0 -1
  339. package/tools/messages/list-messages.mjs +0 -43
  340. package/tools/messages/list-messages.mjs.map +0 -1
  341. package/tools/messages/search-messages.d.mts +0 -45
  342. package/tools/messages/search-messages.d.mts.map +0 -1
  343. package/tools/messages/search-messages.d.ts +0 -45
  344. package/tools/messages/search-messages.d.ts.map +0 -1
  345. package/tools/messages/search-messages.js +0 -110
  346. package/tools/messages/search-messages.js.map +0 -1
  347. package/tools/messages/search-messages.mjs +0 -106
  348. package/tools/messages/search-messages.mjs.map +0 -1
  349. package/tools/messages/send-message.d.mts +0 -45
  350. package/tools/messages/send-message.d.mts.map +0 -1
  351. package/tools/messages/send-message.d.ts +0 -45
  352. package/tools/messages/send-message.d.ts.map +0 -1
  353. package/tools/messages/send-message.js +0 -43
  354. package/tools/messages/send-message.js.map +0 -1
  355. package/tools/messages/send-message.mjs +0 -39
  356. package/tools/messages/send-message.mjs.map +0 -1
  357. package/tools/top-level/focus-app.d.mts +0 -45
  358. package/tools/top-level/focus-app.d.mts.map +0 -1
  359. package/tools/top-level/focus-app.d.ts +0 -45
  360. package/tools/top-level/focus-app.d.ts.map +0 -1
  361. package/tools/top-level/focus-app.js +0 -47
  362. package/tools/top-level/focus-app.js.map +0 -1
  363. package/tools/top-level/focus-app.mjs +0 -43
  364. package/tools/top-level/focus-app.mjs.map +0 -1
  365. package/tools/top-level/search.d.mts +0 -45
  366. package/tools/top-level/search.d.mts.map +0 -1
  367. package/tools/top-level/search.d.ts +0 -45
  368. package/tools/top-level/search.d.ts.map +0 -1
  369. package/tools/top-level/search.js +0 -37
  370. package/tools/top-level/search.js.map +0 -1
  371. package/tools/top-level/search.mjs +0 -33
  372. package/tools/top-level/search.mjs.map +0 -1
  373. package/tools/types.d.mts.map +0 -1
  374. package/tools/types.d.ts.map +0 -1
  375. package/tools/types.js.map +0 -1
  376. package/tools/types.mjs.map +0 -1
  377. package/tools.d.mts +0 -2
  378. package/tools.d.mts.map +0 -1
  379. package/tools.d.ts +0 -2
  380. package/tools.d.ts.map +0 -1
  381. package/tools.js +0 -18
  382. package/tools.js.map +0 -1
  383. package/tools.mjs +0 -2
  384. package/tools.mjs.map +0 -1
package/src/options.ts CHANGED
@@ -1,140 +1,85 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
1
3
  import qs from 'qs';
2
4
  import yargs from 'yargs';
3
5
  import { hideBin } from 'yargs/helpers';
4
6
  import z from 'zod';
5
- import { endpoints, Filter } from './tools';
6
- import { ClientCapabilities, knownClients, ClientType } from './compat';
7
+ import { readEnv } from './util';
7
8
 
8
9
  export type CLIOptions = McpOptions & {
9
- list: boolean;
10
+ debug: boolean;
11
+ logFormat: 'json' | 'pretty';
10
12
  transport: 'stdio' | 'http';
11
13
  port: number | undefined;
12
14
  socket: string | undefined;
13
15
  };
14
16
 
15
17
  export type McpOptions = {
16
- client?: ClientType | undefined;
17
- includeDynamicTools?: boolean | undefined;
18
- includeAllTools?: boolean | undefined;
19
- includeCodeTools?: boolean | undefined;
20
- includeDocsTools?: boolean | undefined;
21
- filters?: Filter[] | undefined;
22
- capabilities?: Partial<ClientCapabilities> | undefined;
18
+ includeCodeTool?: boolean | undefined;
19
+ stainlessApiKey?: string | undefined;
20
+ codeAllowHttpGets?: boolean | undefined;
21
+ codeAllowedMethods?: string[] | undefined;
22
+ codeBlockedMethods?: string[] | undefined;
23
+ codeExecutionMode: McpCodeExecutionMode;
23
24
  };
24
25
 
25
- const CAPABILITY_CHOICES = [
26
- 'top-level-unions',
27
- 'valid-json',
28
- 'refs',
29
- 'unions',
30
- 'formats',
31
- 'tool-name-length',
32
- ] as const;
33
-
34
- type Capability = (typeof CAPABILITY_CHOICES)[number];
35
-
36
- function parseCapabilityValue(cap: string): { name: Capability; value?: number } {
37
- if (cap.startsWith('tool-name-length=')) {
38
- const parts = cap.split('=');
39
- if (parts.length === 2) {
40
- const length = parseInt(parts[1]!, 10);
41
- if (!isNaN(length)) {
42
- return { name: 'tool-name-length', value: length };
43
- }
44
- throw new Error(`Invalid tool-name-length value: ${parts[1]}. Expected a number.`);
45
- }
46
- throw new Error(`Invalid format for tool-name-length. Expected tool-name-length=N.`);
47
- }
48
- if (!CAPABILITY_CHOICES.includes(cap as Capability)) {
49
- throw new Error(`Unknown capability: ${cap}. Valid capabilities are: ${CAPABILITY_CHOICES.join(', ')}`);
50
- }
51
- return { name: cap as Capability };
52
- }
26
+ export type McpCodeExecutionMode = 'stainless-sandbox' | 'local';
53
27
 
54
28
  export function parseCLIOptions(): CLIOptions {
55
29
  const opts = yargs(hideBin(process.argv))
56
- .option('tools', {
57
- type: 'string',
58
- array: true,
59
- choices: ['dynamic', 'all', 'code', 'docs'],
60
- description: 'Use dynamic tools or all tools',
61
- })
62
- .option('no-tools', {
63
- type: 'string',
64
- array: true,
65
- choices: ['dynamic', 'all', 'code', 'docs'],
66
- description: 'Do not use any dynamic or all tools',
67
- })
68
- .option('tool', {
69
- type: 'string',
70
- array: true,
71
- description: 'Include tools matching the specified names',
72
- })
73
- .option('resource', {
74
- type: 'string',
75
- array: true,
76
- description: 'Include tools matching the specified resources',
77
- })
78
- .option('operation', {
79
- type: 'string',
80
- array: true,
81
- choices: ['read', 'write'],
82
- description: 'Include tools matching the specified operations',
30
+ .option('code-allow-http-gets', {
31
+ type: 'boolean',
32
+ description:
33
+ 'Allow all code tool methods that map to HTTP GET operations. If all code-allow-* flags are unset, then everything is allowed.',
83
34
  })
84
- .option('tag', {
35
+ .option('code-allowed-methods', {
85
36
  type: 'string',
86
37
  array: true,
87
- description: 'Include tools with the specified tags',
38
+ description:
39
+ 'Methods to explicitly allow for code tool. Evaluated as regular expressions against method fully qualified names. If all code-allow-* flags are unset, then everything is allowed.',
88
40
  })
89
- .option('no-tool', {
41
+ .option('code-blocked-methods', {
90
42
  type: 'string',
91
43
  array: true,
92
- description: 'Exclude tools matching the specified names',
44
+ description:
45
+ 'Methods to explicitly block for code tool. Evaluated as regular expressions against method fully qualified names. If all code-allow-* flags are unset, then everything is allowed.',
93
46
  })
94
- .option('no-resource', {
47
+ .option('code-execution-mode', {
95
48
  type: 'string',
96
- array: true,
97
- description: 'Exclude tools matching the specified resources',
49
+ choices: ['stainless-sandbox', 'local'],
50
+ default: 'stainless-sandbox',
51
+ description:
52
+ "Where to run code execution in code tool; 'stainless-sandbox' will execute code in Stainless-hosted sandboxes whereas 'local' will execute code locally on the MCP server machine.",
98
53
  })
99
- .option('no-operation', {
54
+ .option('debug', { type: 'boolean', description: 'Enable debug logging' })
55
+ .option('log-format', {
100
56
  type: 'string',
101
- array: true,
102
- description: 'Exclude tools matching the specified operations',
57
+ choices: ['json', 'pretty'],
58
+ description: 'Format for log output; defaults to json unless tty is detected',
103
59
  })
104
- .option('no-tag', {
60
+ .option('no-tools', {
105
61
  type: 'string',
106
62
  array: true,
107
- description: 'Exclude tools with the specified tags',
108
- })
109
- .option('list', {
110
- type: 'boolean',
111
- description: 'List all tools and exit',
63
+ choices: ['code'],
64
+ description: 'Tools to explicitly disable',
112
65
  })
113
- .option('client', {
114
- type: 'string',
115
- choices: Object.keys(knownClients),
116
- description: 'Specify the MCP client being used',
66
+ .option('port', {
67
+ type: 'number',
68
+ default: 3000,
69
+ description: 'Port to serve on if using http transport',
117
70
  })
118
- .option('capability', {
71
+ .option('socket', { type: 'string', description: 'Unix socket to serve on if using http transport' })
72
+ .option('stainless-api-key', {
119
73
  type: 'string',
120
- array: true,
121
- description: 'Specify client capabilities',
122
- coerce: (values: string[]) => {
123
- return values.flatMap((v) => v.split(','));
124
- },
74
+ default: readEnv('STAINLESS_API_KEY'),
75
+ description:
76
+ 'API key for Stainless. Used to authenticate requests to Stainless-hosted tools endpoints.',
125
77
  })
126
- .option('no-capability', {
78
+ .option('tools', {
127
79
  type: 'string',
128
80
  array: true,
129
- description: 'Unset client capabilities',
130
- choices: CAPABILITY_CHOICES,
131
- coerce: (values: string[]) => {
132
- return values.flatMap((v) => v.split(','));
133
- },
134
- })
135
- .option('describe-capabilities', {
136
- type: 'boolean',
137
- description: 'Print detailed explanation of client capabilities and exit',
81
+ choices: ['code'],
82
+ description: 'Tools to explicitly enable',
138
83
  })
139
84
  .option('transport', {
140
85
  type: 'string',
@@ -142,133 +87,35 @@ export function parseCLIOptions(): CLIOptions {
142
87
  default: 'stdio',
143
88
  description: 'What transport to use; stdio for local servers or http for remote servers',
144
89
  })
145
- .option('port', {
146
- type: 'number',
147
- description: 'Port to serve on if using http transport',
148
- })
149
- .option('socket', {
150
- type: 'string',
151
- description: 'Unix socket to serve on if using http transport',
152
- })
90
+ .env('MCP_SERVER')
91
+ .version(true)
153
92
  .help();
154
93
 
155
- for (const [command, desc] of examples()) {
156
- opts.example(command, desc);
157
- }
158
-
159
94
  const argv = opts.parseSync();
160
95
 
161
- // Handle describe-capabilities flag
162
- if (argv.describeCapabilities) {
163
- console.log(getCapabilitiesExplanation());
164
- process.exit(0);
165
- }
166
-
167
- const filters: Filter[] = [];
168
-
169
- // Helper function to support comma-separated values
170
- const splitValues = (values: string[] | undefined): string[] => {
171
- if (!values) return [];
172
- return values.flatMap((v) => v.split(','));
173
- };
174
-
175
- for (const tag of splitValues(argv.tag)) {
176
- filters.push({ type: 'tag', op: 'include', value: tag });
177
- }
178
-
179
- for (const tag of splitValues(argv.noTag)) {
180
- filters.push({ type: 'tag', op: 'exclude', value: tag });
181
- }
182
-
183
- for (const resource of splitValues(argv.resource)) {
184
- filters.push({ type: 'resource', op: 'include', value: resource });
185
- }
186
-
187
- for (const resource of splitValues(argv.noResource)) {
188
- filters.push({ type: 'resource', op: 'exclude', value: resource });
189
- }
190
-
191
- for (const tool of splitValues(argv.tool)) {
192
- filters.push({ type: 'tool', op: 'include', value: tool });
193
- }
194
-
195
- for (const tool of splitValues(argv.noTool)) {
196
- filters.push({ type: 'tool', op: 'exclude', value: tool });
197
- }
198
-
199
- for (const operation of splitValues(argv.operation)) {
200
- filters.push({ type: 'operation', op: 'include', value: operation });
201
- }
202
-
203
- for (const operation of splitValues(argv.noOperation)) {
204
- filters.push({ type: 'operation', op: 'exclude', value: operation });
205
- }
206
-
207
- // Parse client capabilities
208
- const clientCapabilities: Partial<ClientCapabilities> = {};
209
-
210
- // Apply individual capability overrides
211
- if (Array.isArray(argv.capability)) {
212
- for (const cap of argv.capability) {
213
- const parsedCap = parseCapabilityValue(cap);
214
- if (parsedCap.name === 'top-level-unions') {
215
- clientCapabilities.topLevelUnions = true;
216
- } else if (parsedCap.name === 'valid-json') {
217
- clientCapabilities.validJson = true;
218
- } else if (parsedCap.name === 'refs') {
219
- clientCapabilities.refs = true;
220
- } else if (parsedCap.name === 'unions') {
221
- clientCapabilities.unions = true;
222
- } else if (parsedCap.name === 'formats') {
223
- clientCapabilities.formats = true;
224
- } else if (parsedCap.name === 'tool-name-length') {
225
- clientCapabilities.toolNameLength = parsedCap.value;
226
- }
227
- }
228
- }
229
-
230
- // Handle no-capability options to unset capabilities
231
- if (Array.isArray(argv.noCapability)) {
232
- for (const cap of argv.noCapability) {
233
- if (cap === 'top-level-unions') {
234
- clientCapabilities.topLevelUnions = false;
235
- } else if (cap === 'valid-json') {
236
- clientCapabilities.validJson = false;
237
- } else if (cap === 'refs') {
238
- clientCapabilities.refs = false;
239
- } else if (cap === 'unions') {
240
- clientCapabilities.unions = false;
241
- } else if (cap === 'formats') {
242
- clientCapabilities.formats = false;
243
- } else if (cap === 'tool-name-length') {
244
- clientCapabilities.toolNameLength = undefined;
245
- }
246
- }
247
- }
248
-
249
- const shouldIncludeToolType = (toolType: 'dynamic' | 'all' | 'code' | 'docs') =>
96
+ const shouldIncludeToolType = (toolType: 'code') =>
250
97
  argv.noTools?.includes(toolType) ? false
251
98
  : argv.tools?.includes(toolType) ? true
252
99
  : undefined;
253
100
 
254
- const includeDynamicTools = shouldIncludeToolType('dynamic');
255
- const includeAllTools = shouldIncludeToolType('all');
256
- const includeCodeTools = shouldIncludeToolType('code');
257
- const includeDocsTools = shouldIncludeToolType('docs');
101
+ const includeCodeTool = shouldIncludeToolType('code');
258
102
 
259
103
  const transport = argv.transport as 'stdio' | 'http';
104
+ const logFormat =
105
+ argv.logFormat ? (argv.logFormat as 'json' | 'pretty')
106
+ : process.stderr.isTTY ? 'pretty'
107
+ : 'json';
260
108
 
261
- const client = argv.client as ClientType;
262
109
  return {
263
- client: client && client !== 'infer' && knownClients[client] ? client : undefined,
264
- includeDynamicTools,
265
- includeAllTools,
266
- includeCodeTools,
267
- includeDocsTools,
268
- filters,
269
- capabilities: clientCapabilities,
270
- list: argv.list || false,
110
+ ...(includeCodeTool !== undefined && { includeCodeTool }),
111
+ debug: !!argv.debug,
112
+ stainlessApiKey: argv.stainlessApiKey,
113
+ codeAllowHttpGets: argv.codeAllowHttpGets,
114
+ codeAllowedMethods: argv.codeAllowedMethods,
115
+ codeBlockedMethods: argv.codeBlockedMethods,
116
+ codeExecutionMode: argv.codeExecutionMode as McpCodeExecutionMode,
271
117
  transport,
118
+ logFormat,
272
119
  port: argv.port,
273
120
  socket: argv.socket,
274
121
  };
@@ -284,183 +131,22 @@ const coerceArray = <T extends z.ZodTypeAny>(zodType: T) =>
284
131
  );
285
132
 
286
133
  const QueryOptions = z.object({
287
- tools: coerceArray(z.enum(['dynamic', 'all', 'docs'])).describe('Use dynamic tools or all tools'),
288
- no_tools: coerceArray(z.enum(['dynamic', 'all', 'docs'])).describe('Do not use dynamic tools or all tools'),
134
+ tools: coerceArray(z.enum(['code'])).describe('Specify which MCP tools to use'),
135
+ no_tools: coerceArray(z.enum(['code'])).describe('Specify which MCP tools to not use.'),
289
136
  tool: coerceArray(z.string()).describe('Include tools matching the specified names'),
290
- resource: coerceArray(z.string()).describe('Include tools matching the specified resources'),
291
- operation: coerceArray(z.enum(['read', 'write'])).describe(
292
- 'Include tools matching the specified operations',
293
- ),
294
- tag: coerceArray(z.string()).describe('Include tools with the specified tags'),
295
- no_tool: coerceArray(z.string()).describe('Exclude tools matching the specified names'),
296
- no_resource: coerceArray(z.string()).describe('Exclude tools matching the specified resources'),
297
- no_operation: coerceArray(z.enum(['read', 'write'])).describe(
298
- 'Exclude tools matching the specified operations',
299
- ),
300
- no_tag: coerceArray(z.string()).describe('Exclude tools with the specified tags'),
301
- client: ClientType.optional().describe('Specify the MCP client being used'),
302
- capability: coerceArray(z.string()).describe('Specify client capabilities'),
303
- no_capability: coerceArray(z.enum(CAPABILITY_CHOICES)).describe('Unset client capabilities'),
304
137
  });
305
138
 
306
139
  export function parseQueryOptions(defaultOptions: McpOptions, query: unknown): McpOptions {
307
140
  const queryObject = typeof query === 'string' ? qs.parse(query) : query;
308
141
  const queryOptions = QueryOptions.parse(queryObject);
309
142
 
310
- const filters: Filter[] = [...(defaultOptions.filters ?? [])];
311
-
312
- for (const resource of queryOptions.resource || []) {
313
- filters.push({ type: 'resource', op: 'include', value: resource });
314
- }
315
- for (const operation of queryOptions.operation || []) {
316
- filters.push({ type: 'operation', op: 'include', value: operation });
317
- }
318
- for (const tag of queryOptions.tag || []) {
319
- filters.push({ type: 'tag', op: 'include', value: tag });
320
- }
321
- for (const tool of queryOptions.tool || []) {
322
- filters.push({ type: 'tool', op: 'include', value: tool });
323
- }
324
- for (const resource of queryOptions.no_resource || []) {
325
- filters.push({ type: 'resource', op: 'exclude', value: resource });
326
- }
327
- for (const operation of queryOptions.no_operation || []) {
328
- filters.push({ type: 'operation', op: 'exclude', value: operation });
329
- }
330
- for (const tag of queryOptions.no_tag || []) {
331
- filters.push({ type: 'tag', op: 'exclude', value: tag });
332
- }
333
- for (const tool of queryOptions.no_tool || []) {
334
- filters.push({ type: 'tool', op: 'exclude', value: tool });
335
- }
336
-
337
- // Parse client capabilities
338
- const clientCapabilities: Partial<ClientCapabilities> = { ...defaultOptions.capabilities };
339
-
340
- for (const cap of queryOptions.capability || []) {
341
- const parsed = parseCapabilityValue(cap);
342
- if (parsed.name === 'top-level-unions') {
343
- clientCapabilities.topLevelUnions = true;
344
- } else if (parsed.name === 'valid-json') {
345
- clientCapabilities.validJson = true;
346
- } else if (parsed.name === 'refs') {
347
- clientCapabilities.refs = true;
348
- } else if (parsed.name === 'unions') {
349
- clientCapabilities.unions = true;
350
- } else if (parsed.name === 'formats') {
351
- clientCapabilities.formats = true;
352
- } else if (parsed.name === 'tool-name-length') {
353
- clientCapabilities.toolNameLength = parsed.value;
354
- }
355
- }
356
-
357
- for (const cap of queryOptions.no_capability || []) {
358
- if (cap === 'top-level-unions') {
359
- clientCapabilities.topLevelUnions = false;
360
- } else if (cap === 'valid-json') {
361
- clientCapabilities.validJson = false;
362
- } else if (cap === 'refs') {
363
- clientCapabilities.refs = false;
364
- } else if (cap === 'unions') {
365
- clientCapabilities.unions = false;
366
- } else if (cap === 'formats') {
367
- clientCapabilities.formats = false;
368
- } else if (cap === 'tool-name-length') {
369
- clientCapabilities.toolNameLength = undefined;
370
- }
371
- }
372
-
373
- let dynamicTools: boolean | undefined =
374
- queryOptions.no_tools && queryOptions.no_tools?.includes('dynamic') ? false
375
- : queryOptions.tools?.includes('dynamic') ? true
376
- : defaultOptions.includeDynamicTools;
377
-
378
- let allTools: boolean | undefined =
379
- queryOptions.no_tools && queryOptions.no_tools?.includes('all') ? false
380
- : queryOptions.tools?.includes('all') ? true
381
- : defaultOptions.includeAllTools;
382
-
383
- let docsTools: boolean | undefined =
384
- queryOptions.no_tools && queryOptions.no_tools?.includes('docs') ? false
385
- : queryOptions.tools?.includes('docs') ? true
386
- : defaultOptions.includeDocsTools;
143
+ let codeTool: boolean | undefined =
144
+ queryOptions.no_tools && queryOptions.no_tools?.includes('code') ? false
145
+ : queryOptions.tools?.includes('code') ? true
146
+ : defaultOptions.includeCodeTool;
387
147
 
388
148
  return {
389
- client: queryOptions.client ?? defaultOptions.client,
390
- includeDynamicTools: dynamicTools,
391
- includeAllTools: allTools,
392
- includeCodeTools: undefined,
393
- includeDocsTools: docsTools,
394
- filters,
395
- capabilities: clientCapabilities,
149
+ ...(codeTool !== undefined && { includeCodeTool: codeTool }),
150
+ codeExecutionMode: defaultOptions.codeExecutionMode,
396
151
  };
397
152
  }
398
-
399
- function getCapabilitiesExplanation(): string {
400
- return `
401
- Client Capabilities Explanation:
402
-
403
- Different Language Models (LLMs) and the MCP clients that use them have varying limitations in how they handle tool schemas. Capability flags allow you to inform the MCP server about these limitations.
404
-
405
- When a capability flag is set to false, the MCP server will automatically adjust the tool schemas to work around that limitation, ensuring broader compatibility.
406
-
407
- Available Capabilities:
408
-
409
- # top-level-unions
410
- Some clients/LLMs do not support JSON schemas with a union type (anyOf) at the root level. If a client lacks this capability, the MCP server splits tools with top-level unions into multiple separate tools, one for each variant in the union.
411
-
412
- # refs
413
- Some clients/LLMs do not support $ref pointers for schema reuse. If a client lacks this capability, the MCP server automatically inlines all references ($defs) directly into the schema. Properties that would cause circular references are removed during this process.
414
-
415
- # valid-json
416
- Some clients/LLMs may incorrectly send arguments as a JSON-encoded string instead of a proper JSON object. If a client *has* this capability, the MCP server will attempt to parse string values as JSON if the initial validation against the schema fails.
417
-
418
- # unions
419
- Some clients/LLMs do not support union types (anyOf) in JSON schemas. If a client lacks this capability, the MCP server removes all anyOf fields and uses only the first variant as the schema.
420
-
421
- # formats
422
- Some clients/LLMs do not support the 'format' keyword in JSON Schema specifications. If a client lacks this capability, the MCP server removes all format fields and appends the format information to the field's description in parentheses.
423
-
424
- # tool-name-length=N
425
- Some clients/LLMs impose a maximum length on tool names. If this capability is set, the MCP server will automatically truncate tool names exceeding the specified length (N), ensuring uniqueness by appending numbers if necessary.
426
-
427
- Client Presets (--client):
428
- Presets like '--client=openai-agents' or '--client=cursor' automatically configure these capabilities based on current known limitations of those clients, simplifying setup.
429
-
430
- Current presets:
431
- ${JSON.stringify(knownClients, null, 2)}
432
- `;
433
- }
434
-
435
- function examples(): [string, string][] {
436
- const firstEndpoint = endpoints[0]!;
437
- const secondEndpoint =
438
- endpoints.find((e) => e.metadata.resource !== firstEndpoint.metadata.resource) || endpoints[1];
439
- const tag = endpoints.find((e) => e.metadata.tags.length > 0)?.metadata.tags[0];
440
- const otherEndpoint = secondEndpoint || firstEndpoint;
441
-
442
- return [
443
- [
444
- `--tool="${firstEndpoint.tool.name}" ${secondEndpoint ? `--tool="${secondEndpoint.tool.name}"` : ''}`,
445
- 'Include tools by name',
446
- ],
447
- [
448
- `--resource="${firstEndpoint.metadata.resource}" --operation="read"`,
449
- 'Filter by resource and operation',
450
- ],
451
- [
452
- `--resource="${otherEndpoint.metadata.resource}*" --no-tool="${otherEndpoint.tool.name}"`,
453
- 'Use resource wildcards and exclusions',
454
- ],
455
- [`--client="cursor"`, 'Adjust schemas to be more compatible with Cursor'],
456
- [
457
- `--capability="top-level-unions" --capability="tool-name-length=40"`,
458
- 'Specify individual client capabilities',
459
- ],
460
- [
461
- `--client="cursor" --no-capability="tool-name-length"`,
462
- 'Use cursor client preset but remove tool name length limit',
463
- ],
464
- ...(tag ? [[`--tag="${tag}"`, 'Filter based on tags'] as [string, string]] : []),
465
- ];
466
- }