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