@introspection-ai/recipes 0.13.0 → 0.14.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 (222) hide show
  1. package/README.md +45 -58
  2. package/dist/{agent-tool.d.ts → agents.d.ts} +4 -1
  3. package/dist/agents.d.ts.map +1 -0
  4. package/dist/{agent-tool.js → agents.js} +1 -1
  5. package/dist/agents.js.map +1 -0
  6. package/dist/api/extensions.d.ts +3 -0
  7. package/dist/api/extensions.d.ts.map +1 -0
  8. package/dist/api/extensions.js +2 -0
  9. package/dist/api/extensions.js.map +1 -0
  10. package/dist/api/mcp.d.ts +4 -0
  11. package/dist/api/mcp.d.ts.map +1 -0
  12. package/dist/api/mcp.js +2 -0
  13. package/dist/api/mcp.js.map +1 -0
  14. package/dist/api/session.d.ts +3 -0
  15. package/dist/api/session.d.ts.map +1 -0
  16. package/dist/api/session.js +2 -0
  17. package/dist/api/session.js.map +1 -0
  18. package/dist/child-agent.d.ts +5 -4
  19. package/dist/child-agent.d.ts.map +1 -1
  20. package/dist/child-agent.js +26 -117
  21. package/dist/child-agent.js.map +1 -1
  22. package/dist/child-session.d.ts +23 -0
  23. package/dist/child-session.d.ts.map +1 -0
  24. package/dist/child-session.js +48 -0
  25. package/dist/child-session.js.map +1 -0
  26. package/dist/extensions.d.ts +29 -0
  27. package/dist/extensions.d.ts.map +1 -0
  28. package/dist/extensions.js +119 -0
  29. package/dist/extensions.js.map +1 -0
  30. package/dist/index.d.ts +4 -13
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +2 -13
  33. package/dist/index.js.map +1 -1
  34. package/dist/inspect.d.ts +38 -5
  35. package/dist/inspect.d.ts.map +1 -1
  36. package/dist/inspect.js +92 -41
  37. package/dist/inspect.js.map +1 -1
  38. package/dist/interactions.d.ts +18 -2
  39. package/dist/interactions.d.ts.map +1 -1
  40. package/dist/interactions.js +41 -10
  41. package/dist/interactions.js.map +1 -1
  42. package/dist/mcp-catalog.d.ts +1 -0
  43. package/dist/mcp-catalog.d.ts.map +1 -1
  44. package/dist/mcp-catalog.js +14 -6
  45. package/dist/mcp-catalog.js.map +1 -1
  46. package/dist/mcp-chunks/auth-command-ZLGYIEUY.js +273 -0
  47. package/dist/mcp-chunks/call-arguments-LU3W6D3K.js +13 -0
  48. package/dist/mcp-chunks/call-command-LKTKSYTH.js +612 -0
  49. package/dist/mcp-chunks/chunk-2U4BSDC4.js +3951 -0
  50. package/dist/mcp-chunks/chunk-2XL7MG7R.js +272 -0
  51. package/dist/mcp-chunks/chunk-3BJA27PY.js +2321 -0
  52. package/dist/mcp-chunks/chunk-4SQKWYFF.js +15 -0
  53. package/dist/mcp-chunks/chunk-5QOSCSQB.js +290 -0
  54. package/dist/mcp-chunks/chunk-6W5QFASN.js +77 -0
  55. package/dist/mcp-chunks/chunk-6XCZGU3G.js +1004 -0
  56. package/dist/mcp-chunks/chunk-7FHEBT5G.js +149 -0
  57. package/dist/mcp-chunks/chunk-7KA2VJVZ.js +114 -0
  58. package/dist/mcp-chunks/chunk-7UDVSOOF.js +138 -0
  59. package/dist/mcp-chunks/chunk-BNV3TPE4.js +66 -0
  60. package/dist/mcp-chunks/chunk-BTLAWHTA.js +129 -0
  61. package/dist/mcp-chunks/chunk-BV56DXPW.js +13 -0
  62. package/dist/mcp-chunks/chunk-BWHIA4PC.js +90 -0
  63. package/dist/mcp-chunks/chunk-BZIQOWE6.js +267 -0
  64. package/dist/mcp-chunks/chunk-D3MRAZ6H.js +16140 -0
  65. package/dist/mcp-chunks/chunk-DHBE7UBH.js +750 -0
  66. package/dist/mcp-chunks/chunk-E22DYOW5.js +251 -0
  67. package/dist/mcp-chunks/chunk-ECIVB7P4.js +139 -0
  68. package/dist/mcp-chunks/chunk-HKRJ6O36.js +1076 -0
  69. package/dist/mcp-chunks/chunk-IABRYROW.js +44 -0
  70. package/dist/mcp-chunks/chunk-J6LYIZXN.js +45 -0
  71. package/dist/mcp-chunks/chunk-L7NTQVYN.js +161 -0
  72. package/dist/mcp-chunks/chunk-LEZSACDE.js +141 -0
  73. package/dist/mcp-chunks/chunk-LKIBAYKU.js +208 -0
  74. package/dist/mcp-chunks/chunk-LNH5LAJD.js +152 -0
  75. package/dist/mcp-chunks/chunk-LQQEYD76.js +124 -0
  76. package/dist/mcp-chunks/chunk-LRKZP7DJ.js +47 -0
  77. package/dist/mcp-chunks/chunk-LS7PMWSR.js +109 -0
  78. package/dist/mcp-chunks/chunk-M3TPODXI.js +95 -0
  79. package/dist/mcp-chunks/chunk-MZ2NARG7.js +400 -0
  80. package/dist/mcp-chunks/chunk-N46NEFAF.js +45 -0
  81. package/dist/mcp-chunks/chunk-NNOEGEUZ.js +17273 -0
  82. package/dist/mcp-chunks/chunk-NRAJX5E4.js +69 -0
  83. package/dist/mcp-chunks/chunk-P3PSC54P.js +869 -0
  84. package/dist/mcp-chunks/chunk-PIIYJR44.js +6341 -0
  85. package/dist/mcp-chunks/chunk-PWYFKGKG.js +385 -0
  86. package/dist/mcp-chunks/chunk-SJCCBNZ4.js +45 -0
  87. package/dist/mcp-chunks/chunk-TATVT5IT.js +194 -0
  88. package/dist/mcp-chunks/chunk-TEUKFFQL.js +29 -0
  89. package/dist/mcp-chunks/chunk-UKYNQGNE.js +150 -0
  90. package/dist/mcp-chunks/chunk-UNKB4SBV.js +37 -0
  91. package/dist/mcp-chunks/chunk-WD6BOD24.js +138 -0
  92. package/dist/mcp-chunks/chunk-WQJZMCJN.js +73 -0
  93. package/dist/mcp-chunks/chunk-XANPGTLI.js +364 -0
  94. package/dist/mcp-chunks/chunk-XQK2JSW4.js +35 -0
  95. package/dist/mcp-chunks/chunk-YHQUTU6L.js +571 -0
  96. package/dist/mcp-chunks/chunk-YVZKMV5H.js +57 -0
  97. package/dist/mcp-chunks/cli-UV4QJZZM.js +929 -0
  98. package/dist/mcp-chunks/client-S7RQUG5U.js +13 -0
  99. package/dist/mcp-chunks/config-command-NLAGKID5.js +1101 -0
  100. package/dist/mcp-chunks/daemon-command-U242Z6VY.js +26 -0
  101. package/dist/mcp-chunks/dist-LK3SHAMX.js +6478 -0
  102. package/dist/mcp-chunks/emit-ts-command-VBXVXO6V.js +386 -0
  103. package/dist/mcp-chunks/generate-cli-runner-6CAZZA3P.js +1426 -0
  104. package/dist/mcp-chunks/inspect-cli-command-3ZORTOR7.js +111 -0
  105. package/dist/mcp-chunks/launch-YKRXHXJI.js +10 -0
  106. package/dist/mcp-chunks/lifecycle-XVKRHPH3.js +16 -0
  107. package/dist/mcp-chunks/list-command-2MEGGNFQ.js +4190 -0
  108. package/dist/mcp-chunks/output-utils-NKESLAJ6.js +12 -0
  109. package/dist/mcp-chunks/prompt-B1Yc1NPt-VGOTWJMN.js +918 -0
  110. package/dist/mcp-chunks/record-command-YXHTTTT5.js +17 -0
  111. package/dist/mcp-chunks/replay-command-25HJ6AQU.js +85 -0
  112. package/dist/mcp-chunks/resource-command-OO4NYF5C.js +97 -0
  113. package/dist/mcp-chunks/result-utils-MOHHLNM7.js +15 -0
  114. package/dist/mcp-chunks/runtime-5WJ3G25Y.js +33 -0
  115. package/dist/mcp-chunks/runtime-wrapper-RPWDIDBF.js +10 -0
  116. package/dist/mcp-chunks/serve-command-DHXJZMMN.js +3302 -0
  117. package/dist/mcp-chunks/timeouts-W2XWCCXR.js +18 -0
  118. package/dist/mcp-chunks/vault-command-PIYIUEZL.js +154 -0
  119. package/dist/mcp-daemon-client.d.ts +6 -1
  120. package/dist/mcp-daemon-client.d.ts.map +1 -1
  121. package/dist/mcp-daemon-client.js +119 -2
  122. package/dist/mcp-daemon-client.js.map +1 -1
  123. package/dist/mcp-daemon-protocol.d.ts +18 -1
  124. package/dist/mcp-daemon-protocol.d.ts.map +1 -1
  125. package/dist/mcp-daemon-protocol.js +31 -0
  126. package/dist/mcp-daemon-protocol.js.map +1 -1
  127. package/dist/mcp-daemon.js +169 -76602
  128. package/dist/mcp-daemon.js.map +1 -1
  129. package/dist/mcp-policy.d.ts +11 -0
  130. package/dist/mcp-policy.d.ts.map +1 -0
  131. package/dist/mcp-policy.js +27 -0
  132. package/dist/mcp-policy.js.map +1 -0
  133. package/dist/mcp-run-worker.js +38 -76540
  134. package/dist/mcp-tools.d.ts +39 -0
  135. package/dist/mcp-tools.d.ts.map +1 -0
  136. package/dist/mcp-tools.js +493 -0
  137. package/dist/mcp-tools.js.map +1 -0
  138. package/dist/mcp.d.ts +21 -9
  139. package/dist/mcp.d.ts.map +1 -1
  140. package/dist/mcp.js +101 -31
  141. package/dist/mcp.js.map +1 -1
  142. package/dist/model-binding.d.ts +39 -0
  143. package/dist/model-binding.d.ts.map +1 -0
  144. package/dist/model-binding.js +103 -0
  145. package/dist/model-binding.js.map +1 -0
  146. package/dist/pi-extension.d.ts +2 -22
  147. package/dist/pi-extension.d.ts.map +1 -1
  148. package/dist/pi-extension.js +296 -71
  149. package/dist/pi-extension.js.map +1 -1
  150. package/dist/recipe/resolve.d.ts +43 -20
  151. package/dist/recipe/resolve.d.ts.map +1 -1
  152. package/dist/recipe/resolve.js +215 -70
  153. package/dist/recipe/resolve.js.map +1 -1
  154. package/dist/recipe-agent.d.ts +24 -27
  155. package/dist/recipe-agent.d.ts.map +1 -1
  156. package/dist/recipe-agent.js +278 -230
  157. package/dist/recipe-agent.js.map +1 -1
  158. package/dist/recipe-check.d.ts +17 -0
  159. package/dist/recipe-check.d.ts.map +1 -0
  160. package/dist/recipe-check.js +258 -0
  161. package/dist/recipe-check.js.map +1 -0
  162. package/dist/recipe-extensions.d.ts.map +1 -1
  163. package/dist/recipe-extensions.js +0 -3
  164. package/dist/recipe-extensions.js.map +1 -1
  165. package/dist/recipe-model.d.ts +3 -1
  166. package/dist/recipe-model.d.ts.map +1 -1
  167. package/dist/recipe-model.js +15 -12
  168. package/dist/recipe-model.js.map +1 -1
  169. package/dist/recipe-package.d.ts +6 -28
  170. package/dist/recipe-package.d.ts.map +1 -1
  171. package/dist/recipe-package.js +248 -191
  172. package/dist/recipe-package.js.map +1 -1
  173. package/dist/recipe-skills.d.ts.map +1 -1
  174. package/dist/recipe-skills.js +42 -29
  175. package/dist/recipe-skills.js.map +1 -1
  176. package/dist/run-controller.d.ts +10 -9
  177. package/dist/run-controller.d.ts.map +1 -1
  178. package/dist/run-controller.js +28 -21
  179. package/dist/run-controller.js.map +1 -1
  180. package/dist/session.d.ts +40 -53
  181. package/dist/session.d.ts.map +1 -1
  182. package/dist/session.js +312 -173
  183. package/dist/session.js.map +1 -1
  184. package/dist/test-utils.d.ts +7 -7
  185. package/dist/test-utils.d.ts.map +1 -1
  186. package/dist/test-utils.js +32 -15
  187. package/dist/test-utils.js.map +1 -1
  188. package/docs/agent-composition.md +41 -35
  189. package/docs/host-api.md +201 -0
  190. package/docs/index.md +8 -14
  191. package/docs/interactions.md +12 -11
  192. package/docs/mcp-auth.md +6 -6
  193. package/docs/mcp-configuration.md +72 -24
  194. package/docs/pi-extension.md +39 -11
  195. package/docs/recipe-flow.md +9 -9
  196. package/docs/recipe-format.md +90 -41
  197. package/package.json +23 -17
  198. package/vendor/mcp-client/darwin-arm64/mcp-client +0 -0
  199. package/vendor/mcp-client/darwin-x64/mcp-client +0 -0
  200. package/vendor/mcp-client/linux-arm64/mcp-client +0 -0
  201. package/vendor/recipe-check/darwin-arm64/recipe-check +0 -0
  202. package/vendor/recipe-check/darwin-x64/recipe-check +0 -0
  203. package/vendor/recipe-check/linux-arm64/recipe-check +0 -0
  204. package/vendor/recipe-check/linux-x64/recipe-check +0 -0
  205. package/vendor/recipe-check/linux-x64-musl/recipe-check +0 -0
  206. package/vendor/recipe-check/win32-x64/recipe-check.exe +0 -0
  207. package/dist/agent-tool.d.ts.map +0 -1
  208. package/dist/agent-tool.js.map +0 -1
  209. package/dist/run.d.ts +0 -28
  210. package/dist/run.d.ts.map +0 -1
  211. package/dist/run.js +0 -84
  212. package/dist/run.js.map +0 -1
  213. package/dist/testing.d.ts +0 -25
  214. package/dist/testing.d.ts.map +0 -1
  215. package/dist/testing.js +0 -96
  216. package/dist/testing.js.map +0 -1
  217. package/docs/deployment-configuration.md +0 -65
  218. package/docs/migration.md +0 -70
  219. package/docs/python-bindings-release.md +0 -47
  220. package/docs/recipe-evals.md +0 -70
  221. package/docs/recipe-judges.md +0 -152
  222. package/docs/runtime-library.md +0 -171
@@ -0,0 +1,929 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
3
+ import {
4
+ extractFlags
5
+ } from "./chunk-XQK2JSW4.js";
6
+ import {
7
+ isRecordReplayModeActive,
8
+ isReplayModeActive
9
+ } from "./chunk-J6LYIZXN.js";
10
+ import {
11
+ extractListFlags
12
+ } from "./chunk-LEZSACDE.js";
13
+ import {
14
+ DEBUG_HANG,
15
+ dumpActiveHandles,
16
+ terminateChildProcesses
17
+ } from "./chunk-BTLAWHTA.js";
18
+ import {
19
+ parseCallArguments
20
+ } from "./chunk-PIIYJR44.js";
21
+ import {
22
+ CliUsageError
23
+ } from "./chunk-BV56DXPW.js";
24
+ import {
25
+ getActiveLogLevel,
26
+ getActiveLogger,
27
+ logError,
28
+ logInfo,
29
+ setLogLevel
30
+ } from "./chunk-UNKB4SBV.js";
31
+ import {
32
+ chooseClosestIdentifier,
33
+ renderIdentifierResolutionMessages
34
+ } from "./chunk-BWHIA4PC.js";
35
+ import {
36
+ boldText,
37
+ dimText,
38
+ extraDimText,
39
+ supportsAnsiColor,
40
+ yellowText
41
+ } from "./chunk-N46NEFAF.js";
42
+ import {
43
+ parsePositiveInteger,
44
+ resolveCallTimeout
45
+ } from "./chunk-BNV3TPE4.js";
46
+ import "./chunk-LQQEYD76.js";
47
+ import {
48
+ looksLikeHttpUrl,
49
+ splitHttpToolSelector
50
+ } from "./chunk-M3TPODXI.js";
51
+ import "./chunk-YVZKMV5H.js";
52
+ import {
53
+ MCPORTER_VERSION
54
+ } from "./chunk-4SQKWYFF.js";
55
+ import {
56
+ parseLogLevel
57
+ } from "./chunk-6W5QFASN.js";
58
+ import {
59
+ resolveConfigPath
60
+ } from "./chunk-WQJZMCJN.js";
61
+ import "./chunk-ECIVB7P4.js";
62
+ import "./chunk-LRKZP7DJ.js";
63
+
64
+ // node_modules/.pnpm/mcporter@0.12.3/node_modules/mcporter/dist/cli/cli-factory.js
65
+ function buildGlobalContext(argv) {
66
+ const globalFlags = extractFlags(argv, ["--config", "--root", "--log-level", "--oauth-timeout"]);
67
+ if (globalFlags["--log-level"]) {
68
+ try {
69
+ const parsedLevel = parseLogLevel(globalFlags["--log-level"], getActiveLogLevel());
70
+ setLogLevel(parsedLevel);
71
+ } catch (error) {
72
+ const message = error instanceof Error ? error.message : String(error);
73
+ logError(message, error instanceof Error ? error : void 0);
74
+ return { exit: true, code: 1 };
75
+ }
76
+ }
77
+ let oauthTimeoutOverride;
78
+ if (globalFlags["--oauth-timeout"]) {
79
+ const parsed = parsePositiveInteger(globalFlags["--oauth-timeout"]);
80
+ if (parsed === void 0) {
81
+ logError("Flag '--oauth-timeout' must be a positive integer (milliseconds).");
82
+ return { exit: true, code: 1 };
83
+ }
84
+ oauthTimeoutOverride = parsed;
85
+ }
86
+ const rootOverride = globalFlags["--root"];
87
+ const configResolution = resolveConfigPath(globalFlags["--config"], rootOverride ?? process.cwd());
88
+ const runtimeOptions = {
89
+ configPath: configResolution.explicit ? configResolution.path : void 0,
90
+ rootDir: rootOverride,
91
+ logger: getActiveLogger(),
92
+ oauthTimeoutMs: oauthTimeoutOverride
93
+ };
94
+ return { globalFlags, oauthTimeoutOverride, runtimeOptions };
95
+ }
96
+
97
+ // node_modules/.pnpm/mcporter@0.12.3/node_modules/mcporter/dist/cli/command-inference.js
98
+ var CALL_TOKEN_PATTERN = /[.(]/;
99
+ function inferCommandRouting(token, args, definitions) {
100
+ if (!token) {
101
+ return { kind: "command", command: token, args };
102
+ }
103
+ if (token === "describe") {
104
+ return { kind: "command", command: "list", args };
105
+ }
106
+ if (token === "list-tools") {
107
+ return { kind: "command", command: "list", args };
108
+ }
109
+ if (isExplicitCommand(token)) {
110
+ return { kind: "command", command: token, args };
111
+ }
112
+ if (isHttpToolToken(token)) {
113
+ return { kind: "command", command: "call", args: [token, ...args] };
114
+ }
115
+ if (isUrlToken(token)) {
116
+ return { kind: "command", command: "list", args: [token, ...args] };
117
+ }
118
+ if (isCallLikeToken(token)) {
119
+ return { kind: "command", command: "call", args: [token, ...args] };
120
+ }
121
+ if (definitions.length === 0) {
122
+ return { kind: "command", command: token, args };
123
+ }
124
+ const serverNames = definitions.map((entry) => entry.name);
125
+ if (serverNames.includes(token)) {
126
+ return { kind: "command", command: "list", args: [token, ...args] };
127
+ }
128
+ const resolution = chooseClosestIdentifier(token, serverNames);
129
+ if (!resolution) {
130
+ return { kind: "command", command: token, args };
131
+ }
132
+ const messages = renderIdentifierResolutionMessages({
133
+ entity: "server",
134
+ attempted: token,
135
+ resolution
136
+ });
137
+ if (resolution.kind === "auto" && messages.auto) {
138
+ console.log(dimText(messages.auto));
139
+ return { kind: "command", command: "list", args: [resolution.value, ...args] };
140
+ }
141
+ if (messages.suggest) {
142
+ console.error(yellowText(messages.suggest));
143
+ }
144
+ console.error(`Unknown MCP server '${token}'.`);
145
+ return { kind: "abort", exitCode: 1 };
146
+ }
147
+ function isCallLikeToken(token) {
148
+ if (!token) {
149
+ return false;
150
+ }
151
+ if (looksLikeHttpUrl(token)) {
152
+ return false;
153
+ }
154
+ return CALL_TOKEN_PATTERN.test(token);
155
+ }
156
+ function isExplicitCommand(token) {
157
+ return token === "list" || token === "call" || token === "auth" || token === "vault" || token === "resource" || token === "resources";
158
+ }
159
+ function isUrlToken(token) {
160
+ return looksLikeHttpUrl(token);
161
+ }
162
+ function isHttpToolToken(token) {
163
+ if (!token) {
164
+ return false;
165
+ }
166
+ return splitHttpToolSelector(token) !== null;
167
+ }
168
+
169
+ // node_modules/.pnpm/mcporter@0.12.3/node_modules/mcporter/dist/cli/help-output.js
170
+ import fsPromises from "node:fs/promises";
171
+ function printHelp(message) {
172
+ if (message) {
173
+ console.error(message);
174
+ console.error("");
175
+ }
176
+ const colorize = supportsAnsiColor;
177
+ const sections = buildCommandSections(colorize);
178
+ const globalFlags = formatGlobalFlags(colorize);
179
+ const quickStart = formatQuickStart(colorize);
180
+ const footer = formatHelpFooter(colorize);
181
+ const title = colorize ? `${boldText("mcporter")} ${dimText("\u2014 Model Context Protocol CLI & generator")}` : "mcporter \u2014 Model Context Protocol CLI & generator";
182
+ const lines = [
183
+ title,
184
+ "",
185
+ "Usage: mcporter <command> [options]",
186
+ "",
187
+ ...sections,
188
+ "",
189
+ globalFlags,
190
+ "",
191
+ quickStart,
192
+ "",
193
+ footer
194
+ ];
195
+ console.error(lines.join("\n"));
196
+ }
197
+ function buildCommandSections(colorize) {
198
+ const sections = [
199
+ {
200
+ title: "Core commands",
201
+ entries: [
202
+ {
203
+ name: "list",
204
+ summary: "List configured servers (add --schema for tool docs)",
205
+ usage: "mcporter list [name] [--schema] [--json]"
206
+ },
207
+ {
208
+ name: "call",
209
+ summary: "Call a tool by selector (server.tool) or HTTP URL; key=value flags supported",
210
+ usage: "mcporter call <selector> [key=value ...]"
211
+ },
212
+ {
213
+ name: "resource",
214
+ summary: "List or read MCP resources exposed by a server",
215
+ usage: "mcporter resource <server> [uri]"
216
+ },
217
+ {
218
+ name: "auth",
219
+ summary: "Complete OAuth for a server without listing tools",
220
+ usage: "mcporter auth <server | url> [--reset]"
221
+ },
222
+ {
223
+ name: "vault",
224
+ summary: "Seed or clear OAuth credentials non-interactively",
225
+ usage: "mcporter vault set <server> --tokens-file <path>"
226
+ },
227
+ {
228
+ name: "record",
229
+ summary: "Capture MCP JSON-RPC traffic to NDJSON",
230
+ usage: "mcporter record <session-name> [--server <name>] [-- <command>]"
231
+ },
232
+ {
233
+ name: "replay",
234
+ summary: "Replay recorded MCP JSON-RPC traffic deterministically",
235
+ usage: "mcporter replay <session-name> [--server <name>] [-- <command>]"
236
+ }
237
+ ]
238
+ },
239
+ {
240
+ title: "Generator & tooling",
241
+ entries: [
242
+ {
243
+ name: "generate-cli",
244
+ summary: "Emit a standalone CLI (supports HTTP, stdio, and inline commands)",
245
+ usage: "mcporter generate-cli --server <name> | --command <ref> [options]"
246
+ },
247
+ {
248
+ name: "inspect-cli",
249
+ summary: "Show metadata and regen instructions for a generated CLI",
250
+ usage: "mcporter inspect-cli <path> [--json]"
251
+ },
252
+ {
253
+ name: "emit-ts",
254
+ summary: "Generate TypeScript client/types for a server",
255
+ usage: "mcporter emit-ts <server> --mode client|types [options]"
256
+ }
257
+ ]
258
+ },
259
+ {
260
+ title: "Configuration",
261
+ entries: [
262
+ {
263
+ name: "config",
264
+ summary: "Inspect or edit config files (list, get, add, remove, import, login, logout)",
265
+ usage: "mcporter config <command> [options]"
266
+ }
267
+ ]
268
+ },
269
+ {
270
+ title: "Daemon",
271
+ entries: [
272
+ {
273
+ name: "daemon",
274
+ summary: "Manage the keep-alive daemon (start | status | stop | restart)",
275
+ usage: "mcporter daemon <subcommand>"
276
+ },
277
+ {
278
+ name: "serve",
279
+ summary: "Expose daemon-managed keep-alive servers as one MCP server",
280
+ usage: "mcporter serve [--servers a,b,c] [--stdio | --http <port>]"
281
+ }
282
+ ]
283
+ }
284
+ ];
285
+ return sections.flatMap((section) => formatCommandSection(section, colorize));
286
+ }
287
+ function formatCommandSection(section, colorize) {
288
+ const maxNameLength = Math.max(...section.entries.map((entry) => entry.name.length));
289
+ const header = colorize ? boldText(section.title) : section.title;
290
+ const lines = [header];
291
+ section.entries.forEach((entry) => {
292
+ const paddedName = entry.name.padEnd(maxNameLength);
293
+ const renderedName = colorize ? boldText(paddedName) : paddedName;
294
+ const summary = colorize ? dimText(entry.summary) : entry.summary;
295
+ lines.push(` ${renderedName} ${summary}`);
296
+ lines.push(` ${extraDimText("usage:")} ${entry.usage}`);
297
+ });
298
+ return [...lines, ""];
299
+ }
300
+ function formatGlobalFlags(colorize) {
301
+ const title = colorize ? boldText("Global flags") : "Global flags";
302
+ const entries = [
303
+ {
304
+ flag: "--config <path>",
305
+ summary: "Path to mcporter.json (defaults to ./config/mcporter.json)"
306
+ },
307
+ {
308
+ flag: "--root <path>",
309
+ summary: "Working directory for stdio servers"
310
+ },
311
+ {
312
+ flag: "--log-level <debug|info|warn|error>",
313
+ summary: "Adjust CLI logging (defaults to warn)"
314
+ },
315
+ {
316
+ flag: "--oauth-timeout <ms>",
317
+ summary: "Time to wait for browser-based OAuth before giving up (default 300000)"
318
+ }
319
+ ];
320
+ const formatted = entries.map((entry) => ` ${entry.flag.padEnd(34)}${entry.summary}`);
321
+ return [title, ...formatted].join("\n");
322
+ }
323
+ function formatQuickStart(colorize) {
324
+ const title = colorize ? boldText("Quick start") : "Quick start";
325
+ const entries = [
326
+ ["mcporter list", "show configured servers"],
327
+ ["mcporter list linear --schema", "view Linear tool docs"],
328
+ ["mcporter call linear.list_issues limit:5", "invoke a tool with key=value arguments"],
329
+ ["mcporter generate-cli --command https://host/mcp --compile ./my-cli", "build a standalone CLI/binary"]
330
+ ];
331
+ const formatted = entries.map(([cmd, note]) => {
332
+ const comment = colorize ? dimText(`# ${note}`) : `# ${note}`;
333
+ return ` ${cmd}
334
+ ${comment}`;
335
+ });
336
+ return [title, ...formatted].join("\n");
337
+ }
338
+ function formatHelpFooter(colorize) {
339
+ const pointer = "Run `mcporter <command> --help` for detailed flags.";
340
+ const autoLoad = "mcporter auto-loads servers from ./config/mcporter.json and editor imports (Cursor, Claude, Codex, etc.).";
341
+ if (!colorize) {
342
+ return `${pointer}
343
+ ${autoLoad}`;
344
+ }
345
+ return `${dimText(pointer)}
346
+ ${extraDimText(autoLoad)}`;
347
+ }
348
+ function isHelpToken(token) {
349
+ return token === "--help" || token === "-h" || token === "help";
350
+ }
351
+ function consumeHelpTokens(args) {
352
+ let found = false;
353
+ for (let index = args.length - 1; index >= 0; index -= 1) {
354
+ const token = args[index];
355
+ if (token && isHelpToken(token)) {
356
+ args.splice(index, 1);
357
+ found = true;
358
+ }
359
+ }
360
+ return found;
361
+ }
362
+ function isVersionToken(token) {
363
+ return token === "--version" || token === "-v" || token === "-V";
364
+ }
365
+ async function printVersion() {
366
+ console.log(await resolveCliVersion());
367
+ }
368
+ async function resolveCliVersion() {
369
+ try {
370
+ const packageJsonPath = new URL("../../package.json", import.meta.url);
371
+ const buffer = await fsPromises.readFile(packageJsonPath, "utf8");
372
+ const pkg = JSON.parse(buffer);
373
+ return pkg.version ?? MCPORTER_VERSION;
374
+ } catch {
375
+ return MCPORTER_VERSION;
376
+ }
377
+ }
378
+
379
+ // node_modules/.pnpm/mcporter@0.12.3/node_modules/mcporter/dist/cli.js
380
+ var FORCE_EXIT_GRACE_MS = 50;
381
+ var STDOUT_FLUSH_TIMEOUT_MS = 2e3;
382
+ var DAEMON_FAST_PATH_SERVERS = /* @__PURE__ */ new Set(["chrome-devtools", "mobile-mcp", "playwright"]);
383
+ function handleStdioError(error) {
384
+ if (error.code === "EPIPE") {
385
+ return;
386
+ }
387
+ throw error;
388
+ }
389
+ function installStdioErrorHandlers() {
390
+ process.stdout.on("error", handleStdioError);
391
+ process.stderr.on("error", handleStdioError);
392
+ }
393
+ function flushWriteStreamForExit(stream) {
394
+ return new Promise((resolve) => {
395
+ if (!stream.writable || stream.destroyed || stream.writableEnded) {
396
+ resolve();
397
+ return;
398
+ }
399
+ stream.write("", () => {
400
+ resolve();
401
+ });
402
+ });
403
+ }
404
+ function flushStdioThenForceExit() {
405
+ let exited = false;
406
+ const exit = () => {
407
+ if (exited) {
408
+ return;
409
+ }
410
+ exited = true;
411
+ process.exit(process.exitCode ?? 0);
412
+ };
413
+ const fallback = setTimeout(exit, STDOUT_FLUSH_TIMEOUT_MS);
414
+ fallback.unref?.();
415
+ void Promise.allSettled([flushWriteStreamForExit(process.stdout), flushWriteStreamForExit(process.stderr)]).then(() => {
416
+ clearTimeout(fallback);
417
+ exit();
418
+ });
419
+ }
420
+ async function handleAuth(...args) {
421
+ const { handleAuth: imported } = await import("./auth-command-ZLGYIEUY.js");
422
+ return imported(...args);
423
+ }
424
+ async function printAuthHelp() {
425
+ const { printAuthHelp: imported } = await import("./auth-command-ZLGYIEUY.js");
426
+ imported();
427
+ }
428
+ async function handleCall(...args) {
429
+ const { handleCall: imported } = await import("./call-command-LKTKSYTH.js");
430
+ return imported(...args);
431
+ }
432
+ async function handleGenerateCli(...args) {
433
+ const { handleGenerateCli: imported } = await import("./generate-cli-runner-6CAZZA3P.js");
434
+ return imported(...args);
435
+ }
436
+ async function handleInspectCli(...args) {
437
+ const { handleInspectCli: imported } = await import("./inspect-cli-command-3ZORTOR7.js");
438
+ return imported(...args);
439
+ }
440
+ async function handleList(...args) {
441
+ const { handleList: imported } = await import("./list-command-2MEGGNFQ.js");
442
+ return imported(...args);
443
+ }
444
+ async function handleResource(...args) {
445
+ const { handleResource: imported } = await import("./resource-command-OO4NYF5C.js");
446
+ return imported(...args);
447
+ }
448
+ async function runCli(argv) {
449
+ const args = [...argv];
450
+ if (args.length === 0) {
451
+ printHelp();
452
+ process.exit(1);
453
+ return;
454
+ }
455
+ const context = buildGlobalContext(args);
456
+ if ("exit" in context) {
457
+ process.exit(context.code);
458
+ return;
459
+ }
460
+ const { globalFlags, runtimeOptions } = context;
461
+ const command = args.shift();
462
+ if (!command) {
463
+ printHelp();
464
+ process.exit(1);
465
+ return;
466
+ }
467
+ if (isHelpToken(command)) {
468
+ printHelp();
469
+ process.exitCode = 0;
470
+ return;
471
+ }
472
+ if (isVersionToken(command)) {
473
+ await printVersion();
474
+ return;
475
+ }
476
+ if (command === "generate-cli") {
477
+ if (consumeHelpTokens(args)) {
478
+ const { printGenerateCliHelp } = await import("./generate-cli-runner-6CAZZA3P.js");
479
+ printGenerateCliHelp();
480
+ process.exitCode = 0;
481
+ return;
482
+ }
483
+ const { handleGenerateCli: importedHandleGenerateCli } = await import("./generate-cli-runner-6CAZZA3P.js");
484
+ await importedHandleGenerateCli(args, globalFlags);
485
+ return;
486
+ }
487
+ if (command === "inspect-cli") {
488
+ if (consumeHelpTokens(args)) {
489
+ const { printInspectCliHelp } = await import("./inspect-cli-command-3ZORTOR7.js");
490
+ printInspectCliHelp();
491
+ process.exitCode = 0;
492
+ return;
493
+ }
494
+ const { handleInspectCli: importedHandleInspectCli } = await import("./inspect-cli-command-3ZORTOR7.js");
495
+ await importedHandleInspectCli(args);
496
+ return;
497
+ }
498
+ const rootOverride = globalFlags["--root"];
499
+ const configPath = runtimeOptions.configPath ?? globalFlags["--config"];
500
+ const configResolution = resolveConfigPath(globalFlags["--config"], rootOverride ?? process.cwd());
501
+ const configPathResolved = configPath ?? configResolution.path;
502
+ const runtimeOptionsWithPath = {
503
+ ...runtimeOptions,
504
+ configPath: configResolution.explicit ? configPathResolved : runtimeOptions.configPath
505
+ };
506
+ if (command === "daemon") {
507
+ const { handleDaemonCli } = await import("./daemon-command-U242Z6VY.js");
508
+ await handleDaemonCli(args, {
509
+ configPath: configPathResolved,
510
+ configExplicit: configResolution.explicit,
511
+ rootDir: rootOverride
512
+ });
513
+ return;
514
+ }
515
+ if (command === "serve") {
516
+ const { handleServeCli, printServeHelp } = await import("./serve-command-DHXJZMMN.js");
517
+ if (consumeHelpTokens(args)) {
518
+ printServeHelp();
519
+ process.exitCode = 0;
520
+ return;
521
+ }
522
+ await handleServeCli(args, {
523
+ configPath: configPathResolved,
524
+ configExplicit: configResolution.explicit,
525
+ rootDir: rootOverride
526
+ });
527
+ return;
528
+ }
529
+ if (command === "record") {
530
+ const { handleRecordCli, printRecordHelp } = await import("./record-command-YXHTTTT5.js");
531
+ if (consumeHelpTokens(wrapperArgsBeforeSeparator(args))) {
532
+ printRecordHelp();
533
+ process.exitCode = 0;
534
+ return;
535
+ }
536
+ await handleRecordCli(args);
537
+ return;
538
+ }
539
+ if (command === "replay") {
540
+ const { handleReplayCli, printReplayHelp } = await import("./replay-command-25HJ6AQU.js");
541
+ if (consumeHelpTokens(wrapperArgsBeforeSeparator(args))) {
542
+ printReplayHelp();
543
+ process.exitCode = 0;
544
+ return;
545
+ }
546
+ await handleReplayCli(args);
547
+ return;
548
+ }
549
+ if (command === "config") {
550
+ const { handleConfigCli } = await import("./config-command-NLAGKID5.js");
551
+ await handleConfigCli({
552
+ loadOptions: { configPath, rootDir: rootOverride },
553
+ invokeAuth: (authArgs) => invokeAuthCommand(runtimeOptionsWithPath, authArgs)
554
+ }, args);
555
+ return;
556
+ }
557
+ if (command === "emit-ts") {
558
+ if (consumeHelpTokens(args)) {
559
+ const { printEmitTsHelp } = await import("./emit-ts-command-VBXVXO6V.js");
560
+ printEmitTsHelp();
561
+ process.exitCode = 0;
562
+ return;
563
+ }
564
+ const [{ createRuntime: createRuntime2 }, { handleEmitTs }] = await Promise.all([
565
+ import("./runtime-5WJ3G25Y.js"),
566
+ import("./emit-ts-command-VBXVXO6V.js")
567
+ ]);
568
+ const runtime2 = await createRuntime2(runtimeOptionsWithPath);
569
+ try {
570
+ await handleEmitTs(runtime2, args);
571
+ } finally {
572
+ await runtime2.close().catch(() => {
573
+ });
574
+ }
575
+ return;
576
+ }
577
+ if (await maybeHandleDaemonFastCall(command, args, configResolution, rootOverride)) {
578
+ return;
579
+ }
580
+ const [{ createRuntime }, { DaemonClient }, { createKeepAliveRuntime }, { isKeepAliveServer }] = await Promise.all([
581
+ import("./runtime-5WJ3G25Y.js"),
582
+ import("./client-S7RQUG5U.js"),
583
+ import("./runtime-wrapper-RPWDIDBF.js"),
584
+ import("./lifecycle-XVKRHPH3.js")
585
+ ]);
586
+ const baseRuntime = await createRuntime(runtimeOptionsWithPath);
587
+ const recordReplayModeActive = isRecordReplayModeActive();
588
+ const keepAliveServers = recordReplayModeActive ? /* @__PURE__ */ new Set() : new Set(baseRuntime.getDefinitions().filter(isKeepAliveServer).map((entry) => entry.name));
589
+ const daemonClient = !recordReplayModeActive && keepAliveServers.size > 0 ? new DaemonClient({
590
+ configPath: configResolution.path,
591
+ configExplicit: configResolution.explicit,
592
+ rootDir: rootOverride
593
+ }) : null;
594
+ const runtime = createKeepAliveRuntime(baseRuntime, { daemonClient, keepAliveServers });
595
+ let primaryError;
596
+ try {
597
+ const inference = inferCommandRouting(command, args, runtime.getDefinitions());
598
+ if (inference.kind === "abort") {
599
+ process.exitCode = inference.exitCode;
600
+ return;
601
+ }
602
+ const resolvedCommand = inference.command;
603
+ const resolvedArgs = inference.args;
604
+ if (resolvedCommand === "list") {
605
+ if (consumeHelpTokens(resolvedArgs)) {
606
+ const { printListHelp } = await import("./list-command-2MEGGNFQ.js");
607
+ printListHelp();
608
+ process.exitCode = 0;
609
+ return;
610
+ }
611
+ const { handleList: importedHandleList } = await import("./list-command-2MEGGNFQ.js");
612
+ await importedHandleList(runtime, resolvedArgs);
613
+ return;
614
+ }
615
+ if (resolvedCommand === "call") {
616
+ if (consumeHelpTokens(resolvedArgs)) {
617
+ const { printCallHelp } = await import("./call-command-LKTKSYTH.js");
618
+ printCallHelp();
619
+ process.exitCode = 0;
620
+ return;
621
+ }
622
+ const { handleCall: runHandleCall } = await import("./call-command-LKTKSYTH.js");
623
+ await runHandleCall(runtime, resolvedArgs);
624
+ return;
625
+ }
626
+ if (resolvedCommand === "auth") {
627
+ if (consumeHelpTokens(resolvedArgs)) {
628
+ const { printAuthHelp: importedPrintAuthHelp } = await import("./auth-command-ZLGYIEUY.js");
629
+ importedPrintAuthHelp();
630
+ process.exitCode = 0;
631
+ return;
632
+ }
633
+ const { handleAuth: importedHandleAuth } = await import("./auth-command-ZLGYIEUY.js");
634
+ await importedHandleAuth(runtime, resolvedArgs);
635
+ return;
636
+ }
637
+ if (resolvedCommand === "vault") {
638
+ if (consumeHelpTokens(resolvedArgs)) {
639
+ const { printVaultHelp } = await import("./vault-command-PIYIUEZL.js");
640
+ printVaultHelp();
641
+ process.exitCode = 0;
642
+ return;
643
+ }
644
+ const { handleVault } = await import("./vault-command-PIYIUEZL.js");
645
+ await handleVault(runtime, resolvedArgs);
646
+ return;
647
+ }
648
+ if (resolvedCommand === "resource" || resolvedCommand === "resources") {
649
+ if (consumeHelpTokens(resolvedArgs)) {
650
+ const { printResourceHelp } = await import("./resource-command-OO4NYF5C.js");
651
+ printResourceHelp();
652
+ process.exitCode = 0;
653
+ return;
654
+ }
655
+ const { handleResource: importedHandleResource } = await import("./resource-command-OO4NYF5C.js");
656
+ await importedHandleResource(runtime, resolvedArgs);
657
+ return;
658
+ }
659
+ printHelp(`Unknown command '${resolvedCommand}'.`);
660
+ process.exit(1);
661
+ } catch (error) {
662
+ primaryError = error;
663
+ throw error;
664
+ } finally {
665
+ await closeRuntimeAfterCommand(runtime, { suppressReplayCloseError: primaryError !== void 0 });
666
+ }
667
+ }
668
+ async function closeRuntimeAfterCommand(runtime, options = {}) {
669
+ const closeStart = Date.now();
670
+ let closeError;
671
+ if (DEBUG_HANG) {
672
+ logInfo("[debug] beginning runtime.close()");
673
+ dumpActiveHandles("before runtime.close");
674
+ }
675
+ try {
676
+ await runtime.close();
677
+ if (DEBUG_HANG) {
678
+ const duration = Date.now() - closeStart;
679
+ logInfo(`[debug] runtime.close() completed in ${duration}ms`);
680
+ dumpActiveHandles("after runtime.close");
681
+ }
682
+ } catch (error) {
683
+ if (DEBUG_HANG) {
684
+ logError("[debug] runtime.close() failed", error);
685
+ }
686
+ if (isReplayModeActive() && !options.suppressReplayCloseError) {
687
+ closeError = error;
688
+ }
689
+ } finally {
690
+ terminateChildProcesses("runtime.finally");
691
+ const disableForceExit = process.env.MCPORTER_NO_FORCE_EXIT === "1";
692
+ const shouldForceExit = !disableForceExit || process.env.MCPORTER_FORCE_EXIT === "1";
693
+ const scheduleForcedExit = () => {
694
+ if (shouldForceExit) {
695
+ setTimeout(flushStdioThenForceExit, FORCE_EXIT_GRACE_MS);
696
+ }
697
+ };
698
+ if (DEBUG_HANG) {
699
+ dumpActiveHandles("after terminateChildProcesses");
700
+ scheduleForcedExit();
701
+ } else {
702
+ setImmediate(scheduleForcedExit);
703
+ }
704
+ }
705
+ if (closeError) {
706
+ throw closeError;
707
+ }
708
+ }
709
+ function wrapperArgsBeforeSeparator(args) {
710
+ const separatorIndex = args.indexOf("--");
711
+ return separatorIndex === -1 ? [...args] : args.slice(0, separatorIndex);
712
+ }
713
+ async function main() {
714
+ await runCli(process.argv.slice(2));
715
+ }
716
+ if (process.env.MCPORTER_DISABLE_AUTORUN !== "1") {
717
+ installStdioErrorHandlers();
718
+ main().catch((error) => {
719
+ if (error instanceof CliUsageError) {
720
+ logError(error.message);
721
+ process.exit(1);
722
+ return;
723
+ }
724
+ const message = error instanceof Error ? error.message : String(error);
725
+ logError(message, error instanceof Error ? error : void 0);
726
+ process.exit(1);
727
+ });
728
+ }
729
+ async function invokeAuthCommand(runtimeOptions, args) {
730
+ const [{ createRuntime }, { handleAuth: importedHandleAuth }] = await Promise.all([
731
+ import("./runtime-5WJ3G25Y.js"),
732
+ import("./auth-command-ZLGYIEUY.js")
733
+ ]);
734
+ const runtime = await createRuntime(runtimeOptions);
735
+ try {
736
+ await importedHandleAuth(runtime, args);
737
+ } finally {
738
+ await runtime.close().catch(() => {
739
+ });
740
+ }
741
+ }
742
+ async function maybeHandleDaemonFastCall(command, args, configResolution, rootDir) {
743
+ if (isRecordReplayModeActive()) {
744
+ return false;
745
+ }
746
+ const callArgs = resolveDaemonFastCallArgs(command, args);
747
+ if (!callArgs) {
748
+ return false;
749
+ }
750
+ const server = resolveExplicitCallServer(callArgs);
751
+ if (!server || !DAEMON_FAST_PATH_SERVERS.has(server) || isFastPathKeepAliveDisabled(server)) {
752
+ return false;
753
+ }
754
+ if (await maybeHandleSimpleDaemonFastCall(callArgs, configResolution, rootDir)) {
755
+ return true;
756
+ }
757
+ const [{ DaemonClient }, { handleCall: importedHandleCall }] = await Promise.all([
758
+ import("./client-S7RQUG5U.js"),
759
+ import("./call-command-LKTKSYTH.js")
760
+ ]);
761
+ const daemonClient = new DaemonClient({
762
+ configPath: configResolution.path,
763
+ configExplicit: configResolution.explicit,
764
+ rootDir
765
+ });
766
+ await importedHandleCall(createDaemonOnlyRuntime(daemonClient), callArgs);
767
+ return true;
768
+ }
769
+ async function maybeHandleSimpleDaemonFastCall(callArgs, configResolution, rootDir) {
770
+ const [{ parseCallArguments: parseCallArguments2 }, { resolveCallTimeout: resolveCallTimeout2 }] = await Promise.all([
771
+ import("./call-arguments-LU3W6D3K.js"),
772
+ import("./timeouts-W2XWCCXR.js")
773
+ ]);
774
+ let parsed;
775
+ try {
776
+ parsed = parseCallArguments2([...callArgs]);
777
+ } catch {
778
+ return false;
779
+ }
780
+ if (!parsed.server || !parsed.tool || parsed.ephemeral || parsed.tailLog || parsed.saveImagesDir || (parsed.positionalArgs?.length ?? 0) > 0 || parsed.schemaStringCoercionCandidates || parsed.schemaArrayCoercionCandidates) {
781
+ return false;
782
+ }
783
+ const [{ DaemonClient }, { wrapCallResult }, { printCallOutput }] = await Promise.all([
784
+ import("./client-S7RQUG5U.js"),
785
+ import("./result-utils-MOHHLNM7.js"),
786
+ import("./output-utils-NKESLAJ6.js")
787
+ ]);
788
+ const daemonClient = new DaemonClient({
789
+ configPath: configResolution.path,
790
+ configExplicit: configResolution.explicit,
791
+ rootDir
792
+ });
793
+ const result = await daemonClient.callTool({
794
+ server: parsed.server,
795
+ tool: parsed.tool,
796
+ args: Object.keys(parsed.args).length > 0 ? parsed.args : void 0,
797
+ timeoutMs: resolveCallTimeout2(parsed.timeoutMs),
798
+ disableOAuth: parsed.disableOAuth
799
+ });
800
+ const { callResult } = wrapCallResult(result);
801
+ printCallOutput(callResult, result, parsed.output);
802
+ return true;
803
+ }
804
+ function resolveDaemonFastCallArgs(command, args) {
805
+ if (command === "call") {
806
+ return args;
807
+ }
808
+ if (isExplicitNonCallCommand(command) || command.includes("://")) {
809
+ return void 0;
810
+ }
811
+ if (!/[.(]/.test(command)) {
812
+ return void 0;
813
+ }
814
+ return [command, ...args];
815
+ }
816
+ function isExplicitNonCallCommand(command) {
817
+ return command === "list" || command === "auth" || command === "resource" || command === "resources" || command === "daemon" || command === "serve" || command === "record" || command === "replay" || command === "config" || command === "emit-ts" || command === "generate-cli" || command === "inspect-cli" || command === "describe";
818
+ }
819
+ function resolveExplicitCallServer(args) {
820
+ let serverFlag;
821
+ for (let index = 0; index < args.length; index += 1) {
822
+ const token = args[index];
823
+ if (!token) {
824
+ continue;
825
+ }
826
+ if (isHelpToken(token)) {
827
+ return void 0;
828
+ }
829
+ if (token === "--http-url" || token === "--stdio") {
830
+ return void 0;
831
+ }
832
+ if (token === "--server") {
833
+ serverFlag = args[index + 1];
834
+ index += 1;
835
+ continue;
836
+ }
837
+ if (token.startsWith("--server=")) {
838
+ serverFlag = token.slice("--server=".length);
839
+ continue;
840
+ }
841
+ if (token.startsWith("-")) {
842
+ continue;
843
+ }
844
+ if (token.includes("://")) {
845
+ return void 0;
846
+ }
847
+ const separator = token.indexOf(".");
848
+ if (separator > 0) {
849
+ return token.slice(0, separator);
850
+ }
851
+ return serverFlag;
852
+ }
853
+ return serverFlag;
854
+ }
855
+ function isFastPathKeepAliveDisabled(server) {
856
+ const raw = process.env.MCPORTER_DISABLE_KEEPALIVE ?? process.env.MCPORTER_NO_KEEPALIVE;
857
+ if (!raw) {
858
+ return false;
859
+ }
860
+ const disabled = new Set(raw.split(",").map((entry) => entry.trim().toLowerCase()).filter(Boolean));
861
+ return disabled.has("*") || disabled.has(server.toLowerCase());
862
+ }
863
+ function createDaemonOnlyRuntime(daemonClient) {
864
+ return {
865
+ listServers: () => [],
866
+ getDefinitions: () => [],
867
+ getDefinition: (server) => {
868
+ throw new Error(`Server '${server}' is only available through the keep-alive daemon fast path.`);
869
+ },
870
+ registerDefinition: () => {
871
+ throw new Error("Ad-hoc servers are not supported by the keep-alive daemon fast path.");
872
+ },
873
+ getInstructions: async () => void 0,
874
+ listTools: async (server, options) => await daemonClient.listTools({
875
+ server,
876
+ includeSchema: options?.includeSchema,
877
+ autoAuthorize: options?.autoAuthorize,
878
+ allowCachedAuth: options?.allowCachedAuth,
879
+ disableOAuth: options?.disableOAuth
880
+ }),
881
+ callTool: (server, toolName, options) => daemonClient.callTool({
882
+ server,
883
+ tool: toolName,
884
+ args: options?.args,
885
+ timeoutMs: options?.timeoutMs,
886
+ disableOAuth: options?.disableOAuth
887
+ }),
888
+ listResources: (server, options) => {
889
+ const params = { ...options };
890
+ delete params.allowCachedAuth;
891
+ delete params.disableOAuth;
892
+ delete params.oauthSessionOptions;
893
+ return daemonClient.listResources({
894
+ server,
895
+ params,
896
+ allowCachedAuth: options?.allowCachedAuth,
897
+ disableOAuth: options?.disableOAuth
898
+ });
899
+ },
900
+ readResource: (server, uri, options) => daemonClient.readResource({
901
+ server,
902
+ uri,
903
+ allowCachedAuth: options?.allowCachedAuth,
904
+ disableOAuth: options?.disableOAuth
905
+ }),
906
+ connect: async (server) => {
907
+ throw new Error(`Server '${server}' is only available through daemon request methods.`);
908
+ },
909
+ close: async (server) => {
910
+ if (server) {
911
+ await daemonClient.closeServer({ server }).catch(() => {
912
+ });
913
+ }
914
+ }
915
+ };
916
+ }
917
+ export {
918
+ extractListFlags,
919
+ handleAuth,
920
+ handleCall,
921
+ handleGenerateCli,
922
+ handleInspectCli,
923
+ handleList,
924
+ handleResource,
925
+ parseCallArguments,
926
+ printAuthHelp,
927
+ resolveCallTimeout,
928
+ runCli
929
+ };