@agiflowai/one-mcp 0.3.18 → 0.4.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.
package/dist/cli.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- const require_src = require('./src-hm1dRqUF.cjs');
2
+ const require_src = require("./src-Cc3lEKJ5.cjs");
3
3
  let node_fs_promises = require("node:fs/promises");
4
4
  let node_fs = require("node:fs");
5
5
  let node_crypto = require("node:crypto");
@@ -7,54 +7,15 @@ let node_path = require("node:path");
7
7
  let liquidjs = require("liquidjs");
8
8
  let node_child_process = require("node:child_process");
9
9
  let commander = require("commander");
10
- let __agiflowai_aicode_utils = require("@agiflowai/aicode-utils");
11
-
12
- //#region src/services/PrefetchService/constants.ts
13
- /**
14
- * PrefetchService Constants
15
- *
16
- * Constants for package manager commands and process configuration.
17
- */
18
- /** Transport type for stdio-based MCP servers */
19
- const TRANSPORT_STDIO = "stdio";
20
- /** npx command name */
21
- const COMMAND_NPX = "npx";
22
- /** npm command name */
23
- const COMMAND_NPM = "npm";
10
+ let _agiflowai_aicode_utils = require("@agiflowai/aicode-utils");
24
11
  /** pnpx command name (pnpm's npx equivalent) */
25
12
  const COMMAND_PNPX = "pnpx";
26
13
  /** pnpm command name */
27
14
  const COMMAND_PNPM = "pnpm";
28
- /** uvx command name */
29
- const COMMAND_UVX = "uvx";
30
- /** uv command name */
31
- const COMMAND_UV = "uv";
32
- /** Path suffix for npx command */
33
- const COMMAND_NPX_SUFFIX = "/npx";
34
- /** Path suffix for pnpx command */
35
- const COMMAND_PNPX_SUFFIX = "/pnpx";
36
- /** Path suffix for uvx command */
37
- const COMMAND_UVX_SUFFIX = "/uvx";
38
- /** Path suffix for uv command */
39
- const COMMAND_UV_SUFFIX = "/uv";
40
- /** Run subcommand for uv */
41
- const ARG_RUN = "run";
42
15
  /** Tool subcommand for uv */
43
16
  const ARG_TOOL = "tool";
44
17
  /** Install subcommand for uv tool and npm/pnpm */
45
18
  const ARG_INSTALL = "install";
46
- /** Add subcommand for pnpm */
47
- const ARG_ADD = "add";
48
- /** Global flag for npm/pnpm install */
49
- const ARG_GLOBAL = "-g";
50
- /** Flag prefix for command arguments */
51
- const FLAG_PREFIX = "-";
52
- /** npx --package flag (long form) */
53
- const FLAG_PACKAGE_LONG = "--package";
54
- /** npx -p flag (short form) */
55
- const FLAG_PACKAGE_SHORT = "-p";
56
- /** Equals delimiter used in flag=value patterns */
57
- const EQUALS_DELIMITER = "=";
58
19
  /**
59
20
  * Regex pattern for valid package names (npm, pnpm, uvx, uv)
60
21
  * Allows: @scope/package-name@version, package-name, package_name
@@ -66,13 +27,10 @@ const EQUALS_DELIMITER = "=";
66
27
  const VALID_PACKAGE_NAME_PATTERN = /^(@[a-zA-Z0-9_-]+\/)?[a-zA-Z0-9._-]+(@[a-zA-Z0-9._-]+)?$/;
67
28
  /** Windows platform identifier */
68
29
  const PLATFORM_WIN32 = "win32";
69
- /** Success exit code */
70
- const EXIT_CODE_SUCCESS = 0;
71
30
  /** Stdio option to ignore stream */
72
31
  const STDIO_IGNORE = "ignore";
73
32
  /** Stdio option to pipe stream */
74
33
  const STDIO_PIPE = "pipe";
75
-
76
34
  //#endregion
77
35
  //#region src/services/PrefetchService/PrefetchService.ts
78
36
  /**
@@ -132,7 +90,7 @@ var PrefetchService = class {
132
90
  const { mcpConfig, filter } = this.config;
133
91
  for (const [serverName, serverConfig] of Object.entries(mcpConfig.mcpServers)) {
134
92
  if (serverConfig.disabled) continue;
135
- if (serverConfig.transport !== TRANSPORT_STDIO) continue;
93
+ if (serverConfig.transport !== "stdio") continue;
136
94
  if (!isMcpStdioConfig(serverConfig.config)) continue;
137
95
  const packageInfo = this.extractPackageInfo(serverName, serverConfig.config);
138
96
  if (packageInfo) {
@@ -221,21 +179,21 @@ var PrefetchService = class {
221
179
  extractPackageInfo(serverName, config) {
222
180
  const command = config.command.toLowerCase();
223
181
  const args = config.args || [];
224
- if (command === COMMAND_NPX || command.endsWith(COMMAND_NPX_SUFFIX)) {
182
+ if (command === "npx" || command.endsWith("/npx")) {
225
183
  const packageName = this.extractNpxPackage(args);
226
184
  if (packageName && this.isValidPackageName(packageName)) return {
227
185
  serverName,
228
- packageManager: COMMAND_NPX,
186
+ packageManager: "npx",
229
187
  packageName,
230
188
  fullCommand: [
231
- COMMAND_NPM,
189
+ "npm",
232
190
  ARG_INSTALL,
233
- ARG_GLOBAL,
191
+ "-g",
234
192
  packageName
235
193
  ]
236
194
  };
237
195
  }
238
- if (command === COMMAND_PNPX || command.endsWith(COMMAND_PNPX_SUFFIX)) {
196
+ if (command === "pnpx" || command.endsWith("/pnpx")) {
239
197
  const packageName = this.extractNpxPackage(args);
240
198
  if (packageName && this.isValidPackageName(packageName)) return {
241
199
  serverName,
@@ -243,29 +201,29 @@ var PrefetchService = class {
243
201
  packageName,
244
202
  fullCommand: [
245
203
  COMMAND_PNPM,
246
- ARG_ADD,
247
- ARG_GLOBAL,
204
+ "add",
205
+ "-g",
248
206
  packageName
249
207
  ]
250
208
  };
251
209
  }
252
- if (command === COMMAND_UVX || command.endsWith(COMMAND_UVX_SUFFIX)) {
210
+ if (command === "uvx" || command.endsWith("/uvx")) {
253
211
  const packageName = this.extractUvxPackage(args);
254
212
  if (packageName && this.isValidPackageName(packageName)) return {
255
213
  serverName,
256
- packageManager: COMMAND_UVX,
214
+ packageManager: "uvx",
257
215
  packageName,
258
- fullCommand: [COMMAND_UVX, packageName]
216
+ fullCommand: ["uvx", packageName]
259
217
  };
260
218
  }
261
- if ((command === COMMAND_UV || command.endsWith(COMMAND_UV_SUFFIX)) && args.includes(ARG_RUN)) {
219
+ if ((command === "uv" || command.endsWith("/uv")) && args.includes("run")) {
262
220
  const packageName = this.extractUvRunPackage(args);
263
221
  if (packageName && this.isValidPackageName(packageName)) return {
264
222
  serverName,
265
- packageManager: COMMAND_UV,
223
+ packageManager: "uv",
266
224
  packageName,
267
225
  fullCommand: [
268
- COMMAND_UV,
226
+ "uv",
269
227
  ARG_TOOL,
270
228
  ARG_INSTALL,
271
229
  packageName
@@ -292,18 +250,18 @@ var PrefetchService = class {
292
250
  extractNpxPackage(args) {
293
251
  for (let i = 0; i < args.length; i++) {
294
252
  const arg = args[i];
295
- if (arg.startsWith(FLAG_PACKAGE_LONG + EQUALS_DELIMITER)) return arg.slice(FLAG_PACKAGE_LONG.length + EQUALS_DELIMITER.length) || null;
296
- if (arg === FLAG_PACKAGE_LONG && i + 1 < args.length) {
253
+ if (arg.startsWith("--package=")) return arg.slice(10) || null;
254
+ if (arg === "--package" && i + 1 < args.length) {
297
255
  const nextArg = args[i + 1];
298
- if (!nextArg.startsWith(FLAG_PREFIX)) return nextArg;
256
+ if (!nextArg.startsWith("-")) return nextArg;
299
257
  }
300
- if (arg === FLAG_PACKAGE_SHORT && i + 1 < args.length) {
258
+ if (arg === "-p" && i + 1 < args.length) {
301
259
  const nextArg = args[i + 1];
302
- if (!nextArg.startsWith(FLAG_PREFIX)) return nextArg;
260
+ if (!nextArg.startsWith("-")) return nextArg;
303
261
  }
304
262
  }
305
263
  for (const arg of args) {
306
- if (arg.startsWith(FLAG_PREFIX)) continue;
264
+ if (arg.startsWith("-")) continue;
307
265
  return arg;
308
266
  }
309
267
  return null;
@@ -320,7 +278,7 @@ var PrefetchService = class {
320
278
  */
321
279
  extractUvxPackage(args) {
322
280
  for (const arg of args) {
323
- if (arg.startsWith(FLAG_PREFIX)) continue;
281
+ if (arg.startsWith("-")) continue;
324
282
  return arg;
325
283
  }
326
284
  return null;
@@ -337,11 +295,11 @@ var PrefetchService = class {
337
295
  * extractUvRunPackage(['install', 'pkg']) // returns null (no 'run')
338
296
  */
339
297
  extractUvRunPackage(args) {
340
- const runIndex = args.indexOf(ARG_RUN);
298
+ const runIndex = args.indexOf("run");
341
299
  if (runIndex === -1) return null;
342
300
  for (let i = runIndex + 1; i < args.length; i++) {
343
301
  const arg = args[i];
344
- if (arg.startsWith(FLAG_PREFIX)) continue;
302
+ if (arg.startsWith("-")) continue;
345
303
  return arg;
346
304
  }
347
305
  return null;
@@ -353,7 +311,7 @@ var PrefetchService = class {
353
311
  * @returns Promise with success status and output
354
312
  */
355
313
  runCommand(command, args) {
356
- return new Promise((resolve$2) => {
314
+ return new Promise((resolve) => {
357
315
  const proc = (0, node_child_process.spawn)(command, args, {
358
316
  stdio: [
359
317
  STDIO_IGNORE,
@@ -371,13 +329,13 @@ var PrefetchService = class {
371
329
  stderr += data.toString();
372
330
  });
373
331
  proc.on("close", (code) => {
374
- resolve$2({
375
- success: code === EXIT_CODE_SUCCESS,
332
+ resolve({
333
+ success: code === 0,
376
334
  output: stdout || stderr
377
335
  });
378
336
  });
379
337
  proc.on("error", (error) => {
380
- resolve$2({
338
+ resolve({
381
339
  success: false,
382
340
  output: error.message
383
341
  });
@@ -385,15 +343,12 @@ var PrefetchService = class {
385
343
  });
386
344
  }
387
345
  };
388
-
389
346
  //#endregion
390
347
  //#region src/templates/mcp-config.yaml.liquid?raw
391
348
  var mcp_config_yaml_default = "# MCP Server Configuration\n# This file configures the MCP servers that one-mcp will connect to\n#\n# Environment Variable Interpolation:\n# Use ${VAR_NAME} syntax to reference environment variables\n# Example: ${HOME}, ${API_KEY}, ${DATABASE_URL}\n#\n# Instructions:\n# - config.instruction: Server's default instruction (from server documentation)\n# - instruction: User override (optional, takes precedence over config.instruction)\n# - config.toolBlacklist: Array of tool names to hide/block from this server\n# - config.omitToolDescription: Boolean to show only tool names without descriptions (saves tokens)\n\n# Remote Configuration Sources (OPTIONAL)\n# Fetch and merge configurations from remote URLs\n# Remote configs are merged with local configs based on merge strategy\n#\n# SECURITY: SSRF Protection is ENABLED by default\n# - Only HTTPS URLs are allowed (set security.enforceHttps: false to allow HTTP)\n# - Private IPs and localhost are blocked (set security.allowPrivateIPs: true for internal networks)\n# - Blocked ranges: 127.0.0.0/8, 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 169.254.0.0/16\nremoteConfigs:\n # Example 1: Basic remote config with default security\n # - url: ${AGIFLOW_URL}/api/v1/mcp-configs\n # headers:\n # Authorization: Bearer ${AGIFLOW_API_KEY}\n # mergeStrategy: local-priority # Options: local-priority (default), remote-priority, merge-deep\n #\n # Example 2: Remote config with custom security settings (for internal networks)\n # - url: ${INTERNAL_URL}/mcp-configs\n # headers:\n # Authorization: Bearer ${INTERNAL_TOKEN}\n # security:\n # allowPrivateIPs: true # Allow internal IPs (default: false)\n # enforceHttps: false # Allow HTTP (default: true, HTTPS only)\n # mergeStrategy: local-priority\n #\n # Example 3: Remote config with additional validation (OPTIONAL)\n # - url: ${AGIFLOW_URL}/api/v1/mcp-configs\n # headers:\n # Authorization: Bearer ${AGIFLOW_API_KEY}\n # X-API-Key: ${AGIFLOW_API_KEY}\n # security:\n # enforceHttps: true # Require HTTPS (default: true)\n # allowPrivateIPs: false # Block private IPs (default: false)\n # validation: # OPTIONAL: Additional regex validation on top of security checks\n # url: ^https://.*\\.agiflow\\.io/.* # OPTIONAL: Regex pattern to validate URL format\n # headers: # OPTIONAL: Regex patterns to validate header values\n # Authorization: ^Bearer [A-Za-z0-9_-]+$\n # X-API-Key: ^[A-Za-z0-9_-]{32,}$\n # mergeStrategy: local-priority\n\nmcpServers:\n{%- if mcpServers %}{% for server in mcpServers %}\n {{ server.name }}:\n command: {{ server.command }}\n args:{% for arg in server.args %}\n - '{{ arg }}'{% endfor %}\n # env:\n # LOG_LEVEL: info\n # # API_KEY: ${MY_API_KEY}\n # config:\n # instruction: Use this server for...\n # # toolBlacklist:\n # # - tool_to_block\n # # omitToolDescription: true\n{% endfor %}\n # Example MCP server using SSE transport\n # remote-server:\n # url: https://example.com/mcp\n # type: sse\n # headers:\n # Authorization: Bearer ${API_KEY}\n # config:\n # instruction: This server provides tools for...\n{% else %}\n # Example MCP server using stdio transport\n example-server:\n command: node\n args:\n - /path/to/mcp-server/build/index.js\n env:\n # Environment variables for the MCP server\n LOG_LEVEL: info\n # You can use environment variable interpolation:\n # DATABASE_URL: ${DATABASE_URL}\n # API_KEY: ${MY_API_KEY}\n config:\n # Server's default instruction (from server documentation)\n instruction: Use this server for...\n # Optional: Block specific tools from being listed or executed\n # toolBlacklist:\n # - dangerous_tool_name\n # - another_blocked_tool\n # Optional: Omit tool descriptions to save tokens (default: false)\n # omitToolDescription: true\n # instruction: Optional user override - takes precedence over config.instruction\n\n # Example MCP server using SSE transport with environment variables\n # remote-server:\n # url: https://example.com/mcp\n # type: sse\n # headers:\n # # Use ${VAR_NAME} to interpolate environment variables\n # Authorization: Bearer ${API_KEY}\n # config:\n # instruction: This server provides tools for...\n # # Optional: Block specific tools from being listed or executed\n # # toolBlacklist:\n # # - tool_to_block\n # # Optional: Omit tool descriptions to save tokens (default: false)\n # # omitToolDescription: true\n # # instruction: Optional user override\n{% endif %}\n";
392
-
393
349
  //#endregion
394
350
  //#region src/templates/mcp-config.json?raw
395
351
  var mcp_config_default = "{\n \"_comment\": \"MCP Server Configuration - Use ${VAR_NAME} syntax for environment variable interpolation\",\n \"_instructions\": \"config.instruction: Server's default instruction | instruction: User override (takes precedence)\",\n \"mcpServers\": {\n \"example-server\": {\n \"command\": \"node\",\n \"args\": [\"/path/to/mcp-server/build/index.js\"],\n \"env\": {\n \"LOG_LEVEL\": \"info\",\n \"_comment\": \"You can use environment variable interpolation:\",\n \"_example_DATABASE_URL\": \"${DATABASE_URL}\",\n \"_example_API_KEY\": \"${MY_API_KEY}\"\n },\n \"config\": {\n \"instruction\": \"Use this server for...\"\n },\n \"_instruction_override\": \"Optional user override - takes precedence over config.instruction\"\n }\n }\n}\n";
396
-
397
352
  //#endregion
398
353
  //#region src/commands/init.ts
399
354
  /**
@@ -436,7 +391,7 @@ const initCommand = new commander.Command("init").description("Initialize MCP co
436
391
  args: config.args
437
392
  }));
438
393
  } catch (parseError) {
439
- __agiflowai_aicode_utils.log.error("Failed to parse --mcp-servers JSON:", parseError instanceof Error ? parseError.message : String(parseError));
394
+ _agiflowai_aicode_utils.log.error("Failed to parse --mcp-servers JSON:", parseError instanceof Error ? parseError.message : String(parseError));
440
395
  process.exit(1);
441
396
  }
442
397
  content = await liquid.parseAndRender(mcp_config_yaml_default, { mcpServers: mcpServersData });
@@ -448,22 +403,21 @@ const initCommand = new commander.Command("init").description("Initialize MCP co
448
403
  });
449
404
  } catch (error) {
450
405
  if (error && typeof error === "object" && "code" in error && error.code === "EEXIST") {
451
- __agiflowai_aicode_utils.log.error(`Config file already exists: ${outputPath}`);
452
- __agiflowai_aicode_utils.log.info("Use --force to overwrite");
406
+ _agiflowai_aicode_utils.log.error(`Config file already exists: ${outputPath}`);
407
+ _agiflowai_aicode_utils.log.info("Use --force to overwrite");
453
408
  process.exit(1);
454
409
  }
455
410
  throw error;
456
411
  }
457
- __agiflowai_aicode_utils.log.info(`MCP configuration file created: ${outputPath}`);
458
- __agiflowai_aicode_utils.log.info("Next steps:");
459
- __agiflowai_aicode_utils.log.info("1. Edit the configuration file to add your MCP servers");
460
- __agiflowai_aicode_utils.log.info(`2. Run: one-mcp mcp-serve --config ${outputPath}`);
412
+ _agiflowai_aicode_utils.log.info(`MCP configuration file created: ${outputPath}`);
413
+ _agiflowai_aicode_utils.log.info("Next steps:");
414
+ _agiflowai_aicode_utils.log.info("1. Edit the configuration file to add your MCP servers");
415
+ _agiflowai_aicode_utils.log.info(`2. Run: one-mcp mcp-serve --config ${outputPath}`);
461
416
  } catch (error) {
462
- __agiflowai_aicode_utils.log.error("Error executing init:", error instanceof Error ? error.message : String(error));
417
+ _agiflowai_aicode_utils.log.error("Error executing init:", error instanceof Error ? error.message : String(error));
463
418
  process.exit(1);
464
419
  }
465
420
  });
466
-
467
421
  //#endregion
468
422
  //#region src/commands/mcp-serve.ts
469
423
  /**
@@ -864,7 +818,6 @@ const mcpServeCommand = new commander.Command("mcp-serve").description("Start MC
864
818
  process.exit(1);
865
819
  }
866
820
  });
867
-
868
821
  //#endregion
869
822
  //#region src/commands/list-tools.ts
870
823
  /**
@@ -947,7 +900,6 @@ const searchToolsCommand = new commander.Command("search-tools").description("Se
947
900
  process.exit(1);
948
901
  }
949
902
  });
950
-
951
903
  //#endregion
952
904
  //#region src/commands/describe-tools.ts
953
905
  /**
@@ -1105,7 +1057,6 @@ const describeToolsCommand = new commander.Command("describe-tools").description
1105
1057
  process.exit(1);
1106
1058
  }
1107
1059
  });
1108
-
1109
1060
  //#endregion
1110
1061
  //#region src/commands/use-tool.ts
1111
1062
  /**
@@ -1163,15 +1114,15 @@ const useToolCommand = new commander.Command("use-tool").description("Execute an
1163
1114
  process.exit(1);
1164
1115
  }
1165
1116
  if (options.server) {
1166
- const client$1 = clientManager.getClient(options.server);
1167
- if (!client$1) {
1117
+ const client = clientManager.getClient(options.server);
1118
+ if (!client) {
1168
1119
  console.error(`Server "${options.server}" not found`);
1169
1120
  process.exit(1);
1170
1121
  }
1171
1122
  try {
1172
1123
  if (!options.json) console.error(`Executing ${toolName} on ${options.server}...`);
1173
1124
  const requestOptions = options.timeout ? { timeout: options.timeout } : void 0;
1174
- const result = await client$1.callTool(toolName, toolArgs, requestOptions);
1125
+ const result = await client.callTool(toolName, toolArgs, requestOptions);
1175
1126
  if (options.json) console.log(JSON.stringify(result, null, 2));
1176
1127
  else {
1177
1128
  console.log("\nResult:");
@@ -1190,17 +1141,17 @@ const useToolCommand = new commander.Command("use-tool").description("Execute an
1190
1141
  process.exit(1);
1191
1142
  }
1192
1143
  }
1193
- const searchResults = await Promise.all(clients.map(async (client$1) => {
1144
+ const searchResults = await Promise.all(clients.map(async (client) => {
1194
1145
  try {
1195
- const hasTool = (await client$1.listTools()).some((t) => t.name === toolName);
1146
+ const hasTool = (await client.listTools()).some((t) => t.name === toolName);
1196
1147
  return {
1197
- serverName: client$1.serverName,
1148
+ serverName: client.serverName,
1198
1149
  hasTool,
1199
1150
  error: null
1200
1151
  };
1201
1152
  } catch (error) {
1202
1153
  return {
1203
- serverName: client$1.serverName,
1154
+ serverName: client.serverName,
1204
1155
  hasTool: false,
1205
1156
  error
1206
1157
  };
@@ -1280,7 +1231,6 @@ const useToolCommand = new commander.Command("use-tool").description("Execute an
1280
1231
  process.exit(1);
1281
1232
  }
1282
1233
  });
1283
-
1284
1234
  //#endregion
1285
1235
  //#region src/commands/list-resources.ts
1286
1236
  /**
@@ -1362,7 +1312,6 @@ const listResourcesCommand = new commander.Command("list-resources").description
1362
1312
  process.exit(1);
1363
1313
  }
1364
1314
  });
1365
-
1366
1315
  //#endregion
1367
1316
  //#region src/commands/read-resource.ts
1368
1317
  /**
@@ -1409,27 +1358,27 @@ const readResourceCommand = new commander.Command("read-resource").description("
1409
1358
  const clients = clientManager.getAllClients();
1410
1359
  if (clients.length === 0) throw new Error("No MCP servers connected");
1411
1360
  if (options.server) {
1412
- const client$1 = clientManager.getClient(options.server);
1413
- if (!client$1) throw new Error(`Server "${options.server}" not found`);
1361
+ const client = clientManager.getClient(options.server);
1362
+ if (!client) throw new Error(`Server "${options.server}" not found`);
1414
1363
  if (!options.json) console.error(`Reading ${uri} from ${options.server}...`);
1415
- const result$1 = await client$1.readResource(uri);
1416
- if (options.json) console.log(JSON.stringify(result$1, null, 2));
1417
- else for (const content of result$1.contents) if ("text" in content) console.log(content.text);
1364
+ const result = await client.readResource(uri);
1365
+ if (options.json) console.log(JSON.stringify(result, null, 2));
1366
+ else for (const content of result.contents) if ("text" in content) console.log(content.text);
1418
1367
  else console.log(JSON.stringify(content, null, 2));
1419
1368
  await clientManager.disconnectAll();
1420
1369
  return;
1421
1370
  }
1422
- const searchResults = await Promise.all(clients.map(async (client$1) => {
1371
+ const searchResults = await Promise.all(clients.map(async (client) => {
1423
1372
  try {
1424
- const hasResource = (await client$1.listResources()).some((r) => r.uri === uri);
1373
+ const hasResource = (await client.listResources()).some((r) => r.uri === uri);
1425
1374
  return {
1426
- serverName: client$1.serverName,
1375
+ serverName: client.serverName,
1427
1376
  hasResource,
1428
1377
  error: null
1429
1378
  };
1430
1379
  } catch (error) {
1431
1380
  return {
1432
- serverName: client$1.serverName,
1381
+ serverName: client.serverName,
1433
1382
  hasResource: false,
1434
1383
  error
1435
1384
  };
@@ -1459,7 +1408,6 @@ const readResourceCommand = new commander.Command("read-resource").description("
1459
1408
  process.exit(1);
1460
1409
  }
1461
1410
  });
1462
-
1463
1411
  //#endregion
1464
1412
  //#region src/commands/list-prompts.ts
1465
1413
  function toErrorMessage$2(error) {
@@ -1511,7 +1459,6 @@ const listPromptsCommand = new commander.Command("list-prompts").description("Li
1511
1459
  process.exit(1);
1512
1460
  }
1513
1461
  });
1514
-
1515
1462
  //#endregion
1516
1463
  //#region src/commands/get-prompt.ts
1517
1464
  function toErrorMessage$1(error) {
@@ -1540,11 +1487,11 @@ const getPromptCommand = new commander.Command("get-prompt").description("Get a
1540
1487
  const clients = clientManager.getAllClients();
1541
1488
  if (clients.length === 0) throw new Error("No MCP servers connected");
1542
1489
  if (options.server) {
1543
- const client$1 = clientManager.getClient(options.server);
1544
- if (!client$1) throw new Error(`Server "${options.server}" not found`);
1545
- const prompt$1 = await client$1.getPrompt(promptName, promptArgs);
1546
- if (options.json) console.log(JSON.stringify(prompt$1, null, 2));
1547
- else for (const message of prompt$1.messages) {
1490
+ const client = clientManager.getClient(options.server);
1491
+ if (!client) throw new Error(`Server "${options.server}" not found`);
1492
+ const prompt = await client.getPrompt(promptName, promptArgs);
1493
+ if (options.json) console.log(JSON.stringify(prompt, null, 2));
1494
+ else for (const message of prompt.messages) {
1548
1495
  const content = message.content;
1549
1496
  if (typeof content === "object" && content && "text" in content) console.log(content.text);
1550
1497
  else console.log(JSON.stringify(message, null, 2));
@@ -1553,11 +1500,11 @@ const getPromptCommand = new commander.Command("get-prompt").description("Get a
1553
1500
  return;
1554
1501
  }
1555
1502
  const matchingServers = [];
1556
- await Promise.all(clients.map(async (client$1) => {
1503
+ await Promise.all(clients.map(async (client) => {
1557
1504
  try {
1558
- if ((await client$1.listPrompts()).some((prompt$1) => prompt$1.name === promptName)) matchingServers.push(client$1.serverName);
1505
+ if ((await client.listPrompts()).some((prompt) => prompt.name === promptName)) matchingServers.push(client.serverName);
1559
1506
  } catch (error) {
1560
- if (!options.json) console.error(`Failed to list prompts from ${client$1.serverName}: ${toErrorMessage$1(error)}`);
1507
+ if (!options.json) console.error(`Failed to list prompts from ${client.serverName}: ${toErrorMessage$1(error)}`);
1561
1508
  }
1562
1509
  }));
1563
1510
  if (matchingServers.length === 0) throw new Error(`Prompt "${promptName}" not found on any connected server`);
@@ -1577,7 +1524,6 @@ const getPromptCommand = new commander.Command("get-prompt").description("Get a
1577
1524
  process.exit(1);
1578
1525
  }
1579
1526
  });
1580
-
1581
1527
  //#endregion
1582
1528
  //#region src/commands/prefetch.ts
1583
1529
  /**
@@ -1608,11 +1554,11 @@ const prefetchCommand = new commander.Command("prefetch").description("Pre-downl
1608
1554
  try {
1609
1555
  const configFilePath = options.config || require_src.findConfigFile();
1610
1556
  if (!configFilePath) {
1611
- __agiflowai_aicode_utils.print.error("No MCP configuration file found.");
1612
- __agiflowai_aicode_utils.print.info("Use --config <path> to specify a config file, or run \"one-mcp init\" to create one.");
1557
+ _agiflowai_aicode_utils.print.error("No MCP configuration file found.");
1558
+ _agiflowai_aicode_utils.print.info("Use --config <path> to specify a config file, or run \"one-mcp init\" to create one.");
1613
1559
  process.exit(1);
1614
1560
  }
1615
- __agiflowai_aicode_utils.print.info(`Loading configuration from: ${configFilePath}`);
1561
+ _agiflowai_aicode_utils.print.info(`Loading configuration from: ${configFilePath}`);
1616
1562
  const mcpConfig = await new require_src.ConfigFetcherService({
1617
1563
  configFilePath,
1618
1564
  useCache: false
@@ -1628,61 +1574,61 @@ const prefetchCommand = new commander.Command("prefetch").description("Pre-downl
1628
1574
  const packages = prefetchService.extractPackages();
1629
1575
  const shouldPrefetchPackages = !options.skipPackages;
1630
1576
  const shouldWriteDefinitions = Boolean(options.definitionsOut);
1631
- if (options.clearDefinitionsCache) if (options.dryRun) __agiflowai_aicode_utils.print.info(`Would clear definitions cache: ${effectiveDefinitionsPath}`);
1577
+ if (options.clearDefinitionsCache) if (options.dryRun) _agiflowai_aicode_utils.print.info(`Would clear definitions cache: ${effectiveDefinitionsPath}`);
1632
1578
  else {
1633
1579
  await require_src.DefinitionsCacheService.clearFile(effectiveDefinitionsPath);
1634
- __agiflowai_aicode_utils.print.success(`Cleared definitions cache: ${effectiveDefinitionsPath}`);
1580
+ _agiflowai_aicode_utils.print.success(`Cleared definitions cache: ${effectiveDefinitionsPath}`);
1635
1581
  }
1636
1582
  if (shouldPrefetchPackages) if (packages.length === 0) {
1637
- __agiflowai_aicode_utils.print.warning("No packages found to prefetch.");
1638
- __agiflowai_aicode_utils.print.info("Prefetch supports: npx, pnpx, uvx, and uv run commands");
1583
+ _agiflowai_aicode_utils.print.warning("No packages found to prefetch.");
1584
+ _agiflowai_aicode_utils.print.info("Prefetch supports: npx, pnpx, uvx, and uv run commands");
1639
1585
  } else {
1640
- __agiflowai_aicode_utils.print.info(`Found ${packages.length} package(s) to prefetch:`);
1641
- for (const pkg of packages) __agiflowai_aicode_utils.print.item(`${pkg.serverName}: ${pkg.packageManager} ${pkg.packageName}`);
1586
+ _agiflowai_aicode_utils.print.info(`Found ${packages.length} package(s) to prefetch:`);
1587
+ for (const pkg of packages) _agiflowai_aicode_utils.print.item(`${pkg.serverName}: ${pkg.packageManager} ${pkg.packageName}`);
1642
1588
  }
1643
1589
  if (!shouldPrefetchPackages && !shouldWriteDefinitions) {
1644
- __agiflowai_aicode_utils.print.warning("Nothing to do. Use package prefetch or provide --definitions-out.");
1590
+ _agiflowai_aicode_utils.print.warning("Nothing to do. Use package prefetch or provide --definitions-out.");
1645
1591
  return;
1646
1592
  }
1647
1593
  if (options.dryRun) {
1648
1594
  if (shouldPrefetchPackages && packages.length > 0) {
1649
- __agiflowai_aicode_utils.print.newline();
1650
- __agiflowai_aicode_utils.print.header("Dry run mode - commands that would be executed:");
1651
- for (const pkg of packages) __agiflowai_aicode_utils.print.indent(pkg.fullCommand.join(" "));
1595
+ _agiflowai_aicode_utils.print.newline();
1596
+ _agiflowai_aicode_utils.print.header("Dry run mode - commands that would be executed:");
1597
+ for (const pkg of packages) _agiflowai_aicode_utils.print.indent(pkg.fullCommand.join(" "));
1652
1598
  }
1653
1599
  if (shouldWriteDefinitions) {
1654
- __agiflowai_aicode_utils.print.newline();
1655
- __agiflowai_aicode_utils.print.info(`Would write definitions cache to: ${effectiveDefinitionsPath}`);
1600
+ _agiflowai_aicode_utils.print.newline();
1601
+ _agiflowai_aicode_utils.print.info(`Would write definitions cache to: ${effectiveDefinitionsPath}`);
1656
1602
  }
1657
1603
  return;
1658
1604
  }
1659
1605
  let packagePrefetchFailed = false;
1660
1606
  if (shouldPrefetchPackages && packages.length > 0) {
1661
- __agiflowai_aicode_utils.print.newline();
1662
- __agiflowai_aicode_utils.print.info("Prefetching packages...");
1607
+ _agiflowai_aicode_utils.print.newline();
1608
+ _agiflowai_aicode_utils.print.info("Prefetching packages...");
1663
1609
  const summary = await prefetchService.prefetch();
1664
- __agiflowai_aicode_utils.print.newline();
1665
- if (summary.failed === 0) __agiflowai_aicode_utils.print.success(`Package prefetch complete: ${summary.successful} succeeded, ${summary.failed} failed`);
1666
- else __agiflowai_aicode_utils.print.warning(`Package prefetch complete: ${summary.successful} succeeded, ${summary.failed} failed`);
1610
+ _agiflowai_aicode_utils.print.newline();
1611
+ if (summary.failed === 0) _agiflowai_aicode_utils.print.success(`Package prefetch complete: ${summary.successful} succeeded, ${summary.failed} failed`);
1612
+ else _agiflowai_aicode_utils.print.warning(`Package prefetch complete: ${summary.successful} succeeded, ${summary.failed} failed`);
1667
1613
  if (summary.failed > 0) {
1668
1614
  packagePrefetchFailed = true;
1669
- __agiflowai_aicode_utils.print.newline();
1670
- __agiflowai_aicode_utils.print.error("Failed packages:");
1671
- for (const result of summary.results.filter((r) => !r.success)) __agiflowai_aicode_utils.print.item(`${result.package.serverName} (${result.package.packageName}): ${result.output.trim()}`);
1615
+ _agiflowai_aicode_utils.print.newline();
1616
+ _agiflowai_aicode_utils.print.error("Failed packages:");
1617
+ for (const result of summary.results.filter((r) => !r.success)) _agiflowai_aicode_utils.print.item(`${result.package.serverName} (${result.package.packageName}): ${result.output.trim()}`);
1672
1618
  }
1673
1619
  }
1674
1620
  if (shouldWriteDefinitions) {
1675
- __agiflowai_aicode_utils.print.newline();
1676
- __agiflowai_aicode_utils.print.info("Collecting definitions cache...");
1621
+ _agiflowai_aicode_utils.print.newline();
1622
+ _agiflowai_aicode_utils.print.info("Collecting definitions cache...");
1677
1623
  const clientManager = new require_src.McpClientManagerService();
1678
1624
  const skillPaths = mcpConfig.skills?.paths || [];
1679
1625
  const definitionsCacheService = new require_src.DefinitionsCacheService(clientManager, skillPaths.length > 0 ? new require_src.SkillService(process.cwd(), skillPaths) : void 0);
1680
1626
  await Promise.all(Object.entries(mcpConfig.mcpServers).map(async ([serverName, serverConfig]) => {
1681
1627
  try {
1682
1628
  await clientManager.connectToServer(serverName, serverConfig);
1683
- __agiflowai_aicode_utils.print.item(`Connected for definitions: ${serverName}`);
1629
+ _agiflowai_aicode_utils.print.item(`Connected for definitions: ${serverName}`);
1684
1630
  } catch (error) {
1685
- __agiflowai_aicode_utils.print.warning(`Failed to connect for definitions: ${serverName} (${error instanceof Error ? error.message : String(error)})`);
1631
+ _agiflowai_aicode_utils.print.warning(`Failed to connect for definitions: ${serverName} (${error instanceof Error ? error.message : String(error)})`);
1686
1632
  }
1687
1633
  }));
1688
1634
  const definitionsCache = await definitionsCacheService.collectForCache({
@@ -1692,24 +1638,23 @@ const prefetchCommand = new commander.Command("prefetch").description("Pre-downl
1692
1638
  serverId
1693
1639
  });
1694
1640
  await require_src.DefinitionsCacheService.writeToFile(effectiveDefinitionsPath, definitionsCache);
1695
- __agiflowai_aicode_utils.print.success(`Definitions cache written: ${effectiveDefinitionsPath} (${Object.keys(definitionsCache.servers).length} servers, ${definitionsCache.skills.length} skills)`);
1696
- if (definitionsCache.failures.length > 0) __agiflowai_aicode_utils.print.warning(`Definitions cache completed with ${definitionsCache.failures.length} server failure(s)`);
1641
+ _agiflowai_aicode_utils.print.success(`Definitions cache written: ${effectiveDefinitionsPath} (${Object.keys(definitionsCache.servers).length} servers, ${definitionsCache.skills.length} skills)`);
1642
+ if (definitionsCache.failures.length > 0) _agiflowai_aicode_utils.print.warning(`Definitions cache completed with ${definitionsCache.failures.length} server failure(s)`);
1697
1643
  await clientManager.disconnectAll();
1698
1644
  }
1699
1645
  if (packagePrefetchFailed) process.exit(1);
1700
1646
  } catch (error) {
1701
- __agiflowai_aicode_utils.print.error("Error executing prefetch:", error instanceof Error ? error.message : String(error));
1647
+ _agiflowai_aicode_utils.print.error("Error executing prefetch:", error instanceof Error ? error.message : String(error));
1702
1648
  process.exit(1);
1703
1649
  }
1704
1650
  });
1705
-
1706
1651
  //#endregion
1707
1652
  //#region src/commands/stop.ts
1708
1653
  /**
1709
1654
  * Stop Command
1710
1655
  *
1711
- * Stops a running HTTP one-mcp server using the authenticated admin endpoint
1712
- * and the persisted runtime registry.
1656
+ * Stops a running HTTP one-mcp server using the persisted runtime registry
1657
+ * and a local process signal.
1713
1658
  */
1714
1659
  function toErrorMessage(error) {
1715
1660
  return error instanceof Error ? error.message : String(error);
@@ -1722,14 +1667,13 @@ function printStopResult(result) {
1722
1667
  /**
1723
1668
  * Stop a running HTTP one-mcp server.
1724
1669
  */
1725
- const stopCommand = new commander.Command("stop").description("Stop a running HTTP one-mcp server").option("--id <id>", "Target server ID from the runtime registry").option("--host <host>", "Target runtime host").option("--port <port>", "Target runtime port", (value) => Number.parseInt(value, 10)).option("-c, --config <path>", "Reserved for future config-based targeting support").option("--token <token>", "Override the persisted shutdown token").option("--force", "Skip server ID verification against the /health response", false).option("-j, --json", "Output as JSON", false).option("--timeout <ms>", "Maximum time to wait for shutdown completion", (value) => Number.parseInt(value, 10), 5e3).action(async (options) => {
1670
+ const stopCommand = new commander.Command("stop").description("Stop a running HTTP one-mcp server").option("--id <id>", "Target server ID from the runtime registry").option("--host <host>", "Target runtime host").option("--port <port>", "Target runtime port", (value) => Number.parseInt(value, 10)).option("-c, --config <path>", "Reserved for future config-based targeting support").option("--force", "Skip server ID verification against the /health response", false).option("-j, --json", "Output as JSON", false).option("--timeout <ms>", "Maximum time to wait for shutdown completion", (value) => Number.parseInt(value, 10), 5e3).action(async (options) => {
1726
1671
  try {
1727
1672
  if (options.config) console.error("Warning: --config is not used yet; runtime resolution uses the persisted registry.");
1728
1673
  const result = await new require_src.StopServerService().stop({
1729
1674
  serverId: options.id,
1730
1675
  host: options.host,
1731
1676
  port: options.port,
1732
- token: options.token,
1733
1677
  force: options.force,
1734
1678
  timeoutMs: options.timeout
1735
1679
  });
@@ -1748,7 +1692,6 @@ const stopCommand = new commander.Command("stop").description("Stop a running HT
1748
1692
  process.exit(1);
1749
1693
  }
1750
1694
  });
1751
-
1752
1695
  //#endregion
1753
1696
  //#region src/cli.ts
1754
1697
  /**
@@ -1797,5 +1740,4 @@ main().catch((error) => {
1797
1740
  console.error(`Fatal error: ${error instanceof Error ? error.message : error}`);
1798
1741
  process.exit(1);
1799
1742
  });
1800
-
1801
- //#endregion
1743
+ //#endregion