@agiflowai/one-mcp 0.3.11 → 0.3.13

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_http = require('./http-pwzeCOpM.cjs');
2
+ const require_http = require('./http-SFQFxDCq.cjs');
3
3
  let node_fs_promises = require("node:fs/promises");
4
4
  let node_path = require("node:path");
5
5
  let liquidjs = require("liquidjs");
@@ -125,6 +125,9 @@ const TRANSPORT_MODE = {
125
125
  function isValidTransportType(type) {
126
126
  return type === "stdio" || type === "http" || type === "sse";
127
127
  }
128
+ function isValidProxyMode(mode) {
129
+ return mode === "meta" || mode === "flat" || mode === "search";
130
+ }
128
131
  /**
129
132
  * Start MCP server with given transport handler
130
133
  * @param handler - The transport handler to start
@@ -147,17 +150,24 @@ async function startServer(handler) {
147
150
  /**
148
151
  * MCP Serve command
149
152
  */
150
- const mcpServeCommand = new commander.Command("mcp-serve").description("Start MCP server with specified transport").option("-t, --type <type>", "Transport type: stdio, http, or sse", "stdio").option("-p, --port <port>", "Port to listen on (http/sse only)", (val) => parseInt(val, 10), 3e3).option("--host <host>", "Host to bind to (http/sse only)", "localhost").option("-c, --config <path>", "Path to MCP server configuration file").option("--no-cache", "Disable configuration caching, always reload from config file").option("--id <id>", "Unique server identifier (overrides config file id, auto-generated if not provided)").action(async (options) => {
153
+ const mcpServeCommand = new commander.Command("mcp-serve").description("Start MCP server with specified transport").option("-t, --type <type>", "Transport type: stdio, http, or sse", "stdio").option("-p, --port <port>", "Port to listen on (http/sse only)", (val) => parseInt(val, 10), 3e3).option("--host <host>", "Host to bind to (http/sse only)", "localhost").option("-c, --config <path>", "Path to MCP server configuration file").option("--no-cache", "Disable configuration caching, always reload from config file").option("--definitions-cache <path>", "Path to prefetched tool/prompt/skill definitions cache file").option("--clear-definitions-cache", "Delete definitions cache before startup", false).option("--proxy-mode <mode>", "How one-mcp exposes downstream tools: meta, flat, or search", "meta").option("--id <id>", "Unique server identifier (overrides config file id, auto-generated if not provided)").action(async (options) => {
151
154
  const transportType = options.type.toLowerCase();
152
155
  if (!isValidTransportType(transportType)) {
153
156
  console.error(`Unknown transport type: '${transportType}'. Valid options: stdio, http, sse`);
154
157
  process.exit(1);
155
158
  }
159
+ if (!isValidProxyMode(options.proxyMode)) {
160
+ console.error(`Unknown proxy mode: '${options.proxyMode}'. Valid options: meta, flat, search`);
161
+ process.exit(1);
162
+ }
156
163
  try {
157
164
  const serverOptions = {
158
165
  configFilePath: options.config || require_http.findConfigFile() || void 0,
159
166
  noCache: options.cache === false,
160
- serverId: options.id
167
+ serverId: options.id,
168
+ definitionsCachePath: options.definitionsCache,
169
+ clearDefinitionsCache: options.clearDefinitionsCache,
170
+ proxyMode: options.proxyMode
161
171
  };
162
172
  if (transportType === "stdio") await startServer(new require_http.StdioTransportHandler(await require_http.createServer(serverOptions)));
163
173
  else if (transportType === "http") await startServer(new require_http.HttpTransportHandler(await require_http.createServer(serverOptions), {
@@ -577,85 +587,62 @@ var PrefetchService = class {
577
587
  * - Hardcoded values (use options or environment variables)
578
588
  * - Not exiting with appropriate exit codes on errors
579
589
  */
580
- function toErrorMessage$2(error) {
590
+ function toErrorMessage$4(error) {
581
591
  return error instanceof Error ? error.message : String(error);
582
592
  }
583
- /**
584
- * List all available tools from connected MCP servers
585
- */
586
- const listToolsCommand = new commander.Command("list-tools").description("List all available tools from connected MCP servers").option("-c, --config <path>", "Path to MCP server configuration file").option("-s, --server <name>", "Filter by server name").option("-j, --json", "Output as JSON", false).action(async (options) => {
593
+ function printSearchResults(result) {
594
+ for (const server of result.servers) {
595
+ console.log(`\n${server.server}:`);
596
+ if (server.capabilities && server.capabilities.length > 0) console.log(` capabilities: ${server.capabilities.join(", ")}`);
597
+ if (server.summary) console.log(` summary: ${server.summary}`);
598
+ if (server.tools.length === 0) {
599
+ console.log(" no tools");
600
+ continue;
601
+ }
602
+ for (const tool of server.tools) {
603
+ const capabilitySummary = tool.capabilities && tool.capabilities.length > 0 ? ` [${tool.capabilities.join(", ")}]` : "";
604
+ console.log(` - ${tool.name}${capabilitySummary}`);
605
+ if (tool.description) console.log(` ${tool.description}`);
606
+ }
607
+ }
608
+ }
609
+ const searchToolsCommand = new commander.Command("search-tools").description("Search proxied MCP tools by capability or server").option("-c, --config <path>", "Path to MCP server configuration file").option("-s, --server <name>", "Filter by server name").option("--capability <name>", "Filter by capability tag, summary, tool name, or description").option("--definitions-cache <path>", "Path to definitions cache file").option("-j, --json", "Output as JSON", false).action(async (options) => {
587
610
  try {
588
611
  const configFilePath = options.config || require_http.findConfigFile();
589
612
  if (!configFilePath) throw new Error("No config file found. Use --config or create mcp-config.yaml");
590
613
  const config = await new require_http.ConfigFetcherService({ configFilePath }).fetchConfiguration();
591
614
  const clientManager = new require_http.McpClientManagerService();
615
+ clientManager.registerServerConfigs(config.mcpServers);
592
616
  const connectionPromises = Object.entries(config.mcpServers).map(async ([serverName, serverConfig]) => {
593
617
  try {
594
618
  await clientManager.connectToServer(serverName, serverConfig);
595
619
  if (!options.json) console.error(`✓ Connected to ${serverName}`);
596
620
  } catch (error) {
597
- if (!options.json) console.error(`✗ Failed to connect to ${serverName}: ${toErrorMessage$2(error)}`);
621
+ if (!options.json) console.error(`✗ Failed to connect to ${serverName}: ${toErrorMessage$4(error)}`);
598
622
  }
599
623
  });
600
624
  await Promise.all(connectionPromises);
601
- const clients = options.server ? [clientManager.getClient(options.server)].filter((c) => c !== void 0) : clientManager.getAllClients();
602
- if (clients.length === 0) throw new Error("No MCP servers connected");
603
- const toolsByServer = {};
604
- const toolResults = await Promise.all(clients.map(async (client) => {
605
- try {
606
- const tools = await client.listTools();
607
- const blacklist = new Set(client.toolBlacklist || []);
608
- const filteredTools = tools.filter((t) => !blacklist.has(t.name));
609
- return {
610
- serverName: client.serverName,
611
- tools: filteredTools,
612
- error: null
613
- };
614
- } catch (error) {
615
- return {
616
- serverName: client.serverName,
617
- tools: [],
618
- error
619
- };
620
- }
621
- }));
622
- for (const { serverName, tools, error } of toolResults) {
623
- if (error && !options.json) console.error(`Failed to list tools from ${serverName}: ${toErrorMessage$2(error)}`);
624
- toolsByServer[serverName] = tools;
625
+ if (clientManager.getAllClients().length === 0) throw new Error("No MCP servers connected");
626
+ const cachePath = options.definitionsCache || require_http.DefinitionsCacheService.getDefaultCachePath(configFilePath);
627
+ let cacheData;
628
+ try {
629
+ cacheData = await require_http.DefinitionsCacheService.readFromFile(cachePath);
630
+ } catch {
631
+ cacheData = void 0;
625
632
  }
626
- const cwd = process.env.PROJECT_PATH || process.cwd();
627
- const skillPaths = config.skills?.paths || [];
628
- let skills = [];
629
- if (skillPaths.length > 0) try {
630
- skills = await new require_http.SkillService(cwd, skillPaths).getSkills();
631
- } catch (error) {
632
- if (!options.json) console.error(`Failed to load skills: ${toErrorMessage$2(error)}`);
633
- }
634
- if (options.json) {
635
- const output = { ...toolsByServer };
636
- if (skills.length > 0) output.__skills__ = skills.map((s) => ({
637
- name: s.name,
638
- description: s.description
639
- }));
640
- console.log(JSON.stringify(output, null, 2));
641
- } else {
642
- for (const [serverName, tools] of Object.entries(toolsByServer)) {
643
- const omitDescription = clients.find((c) => c.serverName === serverName)?.omitToolDescription || false;
644
- console.log(`\n${serverName}:`);
645
- if (tools.length === 0) console.log(" No tools available");
646
- else if (omitDescription) {
647
- const toolNames = tools.map((t) => t.name).join(", ");
648
- console.log(` ${toolNames}`);
649
- } else for (const tool of tools) console.log(` - ${tool.name}: ${tool.description || "No description"}`);
650
- }
651
- if (skills.length > 0) {
652
- console.log("\nskills:");
653
- for (const skill of skills) console.log(` - ${skill.name}: ${skill.description}`);
654
- }
633
+ const textBlock = (await new require_http.SearchListToolsTool(clientManager, new require_http.DefinitionsCacheService(clientManager, void 0, { cacheData })).execute({
634
+ capability: options.capability,
635
+ serverName: options.server
636
+ })).content.find((content) => content.type === "text");
637
+ const parsed = textBlock?.type === "text" ? JSON.parse(textBlock.text) : { servers: [] };
638
+ if (options.json) console.log(JSON.stringify(parsed, null, 2));
639
+ else {
640
+ if (!parsed.servers || parsed.servers.length === 0) throw new Error("No tools matched the requested filters");
641
+ printSearchResults(parsed);
655
642
  }
656
643
  await clientManager.disconnectAll();
657
644
  } catch (error) {
658
- console.error(`Error executing list-tools: ${toErrorMessage$2(error)}`);
645
+ console.error(`Error executing search-tools: ${toErrorMessage$4(error)}`);
659
646
  process.exit(1);
660
647
  }
661
648
  });
@@ -1014,7 +1001,7 @@ const useToolCommand = new commander.Command("use-tool").description("Execute an
1014
1001
  * - Hardcoded values (use options or environment variables)
1015
1002
  * - Not exiting with appropriate exit codes on errors
1016
1003
  */
1017
- function toErrorMessage$1(error) {
1004
+ function toErrorMessage$3(error) {
1018
1005
  return error instanceof Error ? error.message : String(error);
1019
1006
  }
1020
1007
  /**
@@ -1031,7 +1018,7 @@ const listResourcesCommand = new commander.Command("list-resources").description
1031
1018
  await clientManager.connectToServer(serverName, serverConfig);
1032
1019
  if (!options.json) console.error(`✓ Connected to ${serverName}`);
1033
1020
  } catch (error) {
1034
- if (!options.json) console.error(`✗ Failed to connect to ${serverName}: ${toErrorMessage$1(error)}`);
1021
+ if (!options.json) console.error(`✗ Failed to connect to ${serverName}: ${toErrorMessage$3(error)}`);
1035
1022
  }
1036
1023
  }));
1037
1024
  const clients = options.server ? [clientManager.getClient(options.server)].filter((c) => c !== void 0) : clientManager.getAllClients();
@@ -1054,7 +1041,7 @@ const listResourcesCommand = new commander.Command("list-resources").description
1054
1041
  }
1055
1042
  }));
1056
1043
  for (const { serverName, resources, error } of resourceResults) {
1057
- if (error && !options.json) console.error(`Failed to list resources from ${serverName}: ${toErrorMessage$1(error)}`);
1044
+ if (error && !options.json) console.error(`Failed to list resources from ${serverName}: ${toErrorMessage$3(error)}`);
1058
1045
  resourcesByServer[serverName] = resources;
1059
1046
  }
1060
1047
  if (options.json) console.log(JSON.stringify(resourcesByServer, null, 2));
@@ -1068,7 +1055,7 @@ const listResourcesCommand = new commander.Command("list-resources").description
1068
1055
  }
1069
1056
  await clientManager.disconnectAll();
1070
1057
  } catch (error) {
1071
- console.error(`Error executing list-resources: ${toErrorMessage$1(error)}`);
1058
+ console.error(`Error executing list-resources: ${toErrorMessage$3(error)}`);
1072
1059
  process.exit(1);
1073
1060
  }
1074
1061
  });
@@ -1096,7 +1083,7 @@ const listResourcesCommand = new commander.Command("list-resources").description
1096
1083
  * - Hardcoded values (use options or environment variables)
1097
1084
  * - Not exiting with appropriate exit codes on errors
1098
1085
  */
1099
- function toErrorMessage(error) {
1086
+ function toErrorMessage$2(error) {
1100
1087
  return error instanceof Error ? error.message : String(error);
1101
1088
  }
1102
1089
  /**
@@ -1113,7 +1100,7 @@ const readResourceCommand = new commander.Command("read-resource").description("
1113
1100
  await clientManager.connectToServer(serverName, serverConfig);
1114
1101
  if (!options.json) console.error(`✓ Connected to ${serverName}`);
1115
1102
  } catch (error) {
1116
- console.error(`✗ Failed to connect to ${serverName}: ${toErrorMessage(error)}`);
1103
+ console.error(`✗ Failed to connect to ${serverName}: ${toErrorMessage$2(error)}`);
1117
1104
  }
1118
1105
  }));
1119
1106
  const clients = clientManager.getAllClients();
@@ -1148,7 +1135,7 @@ const readResourceCommand = new commander.Command("read-resource").description("
1148
1135
  const matchingServers = [];
1149
1136
  for (const { serverName, hasResource, error } of searchResults) {
1150
1137
  if (error) {
1151
- console.error(`Failed to list resources from ${serverName}: ${toErrorMessage(error)}`);
1138
+ console.error(`Failed to list resources from ${serverName}: ${toErrorMessage$2(error)}`);
1152
1139
  continue;
1153
1140
  }
1154
1141
  if (hasResource) matchingServers.push(serverName);
@@ -1165,7 +1152,125 @@ const readResourceCommand = new commander.Command("read-resource").description("
1165
1152
  else console.log(JSON.stringify(content, null, 2));
1166
1153
  await clientManager.disconnectAll();
1167
1154
  } catch (error) {
1168
- console.error(`Error executing read-resource: ${toErrorMessage(error)}`);
1155
+ console.error(`Error executing read-resource: ${toErrorMessage$2(error)}`);
1156
+ process.exit(1);
1157
+ }
1158
+ });
1159
+
1160
+ //#endregion
1161
+ //#region src/commands/list-prompts.ts
1162
+ function toErrorMessage$1(error) {
1163
+ return error instanceof Error ? error.message : String(error);
1164
+ }
1165
+ const listPromptsCommand = new commander.Command("list-prompts").description("List all available prompts from connected MCP servers").option("-c, --config <path>", "Path to MCP server configuration file").option("-s, --server <name>", "Filter by server name").option("-j, --json", "Output as JSON", false).action(async (options) => {
1166
+ try {
1167
+ const configFilePath = options.config || require_http.findConfigFile();
1168
+ if (!configFilePath) throw new Error("No config file found. Use --config or create mcp-config.yaml");
1169
+ const config = await new require_http.ConfigFetcherService({ configFilePath }).fetchConfiguration();
1170
+ const clientManager = new require_http.McpClientManagerService();
1171
+ await Promise.all(Object.entries(config.mcpServers).map(async ([serverName, serverConfig]) => {
1172
+ try {
1173
+ await clientManager.connectToServer(serverName, serverConfig);
1174
+ if (!options.json) console.error(`✓ Connected to ${serverName}`);
1175
+ } catch (error) {
1176
+ if (!options.json) console.error(`✗ Failed to connect to ${serverName}: ${toErrorMessage$1(error)}`);
1177
+ }
1178
+ }));
1179
+ const clients = options.server ? [clientManager.getClient(options.server)].filter((client) => client !== void 0) : clientManager.getAllClients();
1180
+ if (clients.length === 0) throw new Error("No MCP servers connected");
1181
+ const promptsByServer = {};
1182
+ await Promise.all(clients.map(async (client) => {
1183
+ try {
1184
+ promptsByServer[client.serverName] = await client.listPrompts();
1185
+ } catch (error) {
1186
+ promptsByServer[client.serverName] = [];
1187
+ if (!options.json) console.error(`Failed to list prompts from ${client.serverName}: ${toErrorMessage$1(error)}`);
1188
+ }
1189
+ }));
1190
+ if (options.json) console.log(JSON.stringify(promptsByServer, null, 2));
1191
+ else for (const [serverName, prompts] of Object.entries(promptsByServer)) {
1192
+ console.log(`\n${serverName}:`);
1193
+ if (prompts.length === 0) {
1194
+ console.log(" No prompts available");
1195
+ continue;
1196
+ }
1197
+ for (const prompt of prompts) {
1198
+ console.log(` - ${prompt.name}: ${prompt.description || "No description"}`);
1199
+ if (prompt.arguments && prompt.arguments.length > 0) {
1200
+ const args = prompt.arguments.map((arg) => `${arg.name}${arg.required ? " (required)" : ""}`).join(", ");
1201
+ console.log(` args: ${args}`);
1202
+ }
1203
+ }
1204
+ }
1205
+ await clientManager.disconnectAll();
1206
+ } catch (error) {
1207
+ console.error(`Error executing list-prompts: ${toErrorMessage$1(error)}`);
1208
+ process.exit(1);
1209
+ }
1210
+ });
1211
+
1212
+ //#endregion
1213
+ //#region src/commands/get-prompt.ts
1214
+ function toErrorMessage(error) {
1215
+ return error instanceof Error ? error.message : String(error);
1216
+ }
1217
+ const getPromptCommand = new commander.Command("get-prompt").description("Get a prompt by name from a connected MCP server").argument("<promptName>", "Prompt name to fetch").option("-c, --config <path>", "Path to MCP server configuration file").option("-s, --server <name>", "Server name (required if prompt exists on multiple servers)").option("-a, --args <json>", "Prompt arguments as JSON string", "{}").option("-j, --json", "Output as JSON", false).action(async (promptName, options) => {
1218
+ try {
1219
+ const configFilePath = options.config || require_http.findConfigFile();
1220
+ if (!configFilePath) throw new Error("No config file found. Use --config or create mcp-config.yaml");
1221
+ let promptArgs = {};
1222
+ try {
1223
+ promptArgs = JSON.parse(options.args);
1224
+ } catch {
1225
+ throw new Error("Invalid JSON in --args");
1226
+ }
1227
+ const config = await new require_http.ConfigFetcherService({ configFilePath }).fetchConfiguration();
1228
+ const clientManager = new require_http.McpClientManagerService();
1229
+ await Promise.all(Object.entries(config.mcpServers).map(async ([serverName, serverConfig]) => {
1230
+ try {
1231
+ await clientManager.connectToServer(serverName, serverConfig);
1232
+ if (!options.json) console.error(`✓ Connected to ${serverName}`);
1233
+ } catch (error) {
1234
+ if (!options.json) console.error(`✗ Failed to connect to ${serverName}: ${toErrorMessage(error)}`);
1235
+ }
1236
+ }));
1237
+ const clients = clientManager.getAllClients();
1238
+ if (clients.length === 0) throw new Error("No MCP servers connected");
1239
+ if (options.server) {
1240
+ const client$1 = clientManager.getClient(options.server);
1241
+ if (!client$1) throw new Error(`Server "${options.server}" not found`);
1242
+ const prompt$1 = await client$1.getPrompt(promptName, promptArgs);
1243
+ if (options.json) console.log(JSON.stringify(prompt$1, null, 2));
1244
+ else for (const message of prompt$1.messages) {
1245
+ const content = message.content;
1246
+ if (typeof content === "object" && content && "text" in content) console.log(content.text);
1247
+ else console.log(JSON.stringify(message, null, 2));
1248
+ }
1249
+ await clientManager.disconnectAll();
1250
+ return;
1251
+ }
1252
+ const matchingServers = [];
1253
+ await Promise.all(clients.map(async (client$1) => {
1254
+ try {
1255
+ if ((await client$1.listPrompts()).some((prompt$1) => prompt$1.name === promptName)) matchingServers.push(client$1.serverName);
1256
+ } catch (error) {
1257
+ if (!options.json) console.error(`Failed to list prompts from ${client$1.serverName}: ${toErrorMessage(error)}`);
1258
+ }
1259
+ }));
1260
+ if (matchingServers.length === 0) throw new Error(`Prompt "${promptName}" not found on any connected server`);
1261
+ if (matchingServers.length > 1) throw new Error(`Prompt "${promptName}" found on multiple servers: ${matchingServers.join(", ")}. Use --server to disambiguate`);
1262
+ const client = clientManager.getClient(matchingServers[0]);
1263
+ if (!client) throw new Error(`Internal error: Server "${matchingServers[0]}" not connected`);
1264
+ const prompt = await client.getPrompt(promptName, promptArgs);
1265
+ if (options.json) console.log(JSON.stringify(prompt, null, 2));
1266
+ else for (const message of prompt.messages) {
1267
+ const content = message.content;
1268
+ if (typeof content === "object" && content && "text" in content) console.log(content.text);
1269
+ else console.log(JSON.stringify(message, null, 2));
1270
+ }
1271
+ await clientManager.disconnectAll();
1272
+ } catch (error) {
1273
+ console.error(`Error executing get-prompt: ${toErrorMessage(error)}`);
1169
1274
  process.exit(1);
1170
1275
  }
1171
1276
  });
@@ -1196,7 +1301,7 @@ const readResourceCommand = new commander.Command("read-resource").description("
1196
1301
  /**
1197
1302
  * Pre-download packages used by MCP servers (npx, pnpx, uvx, uv)
1198
1303
  */
1199
- const prefetchCommand = new commander.Command("prefetch").description("Pre-download packages used by MCP servers (npx, pnpx, uvx, uv)").option("-c, --config <path>", "Path to MCP server configuration file").option("-p, --parallel", "Run prefetch commands in parallel", false).option("-d, --dry-run", "Show what would be prefetched without executing", false).option("-f, --filter <type>", "Filter by package manager type: npx, pnpx, uvx, or uv").action(async (options) => {
1304
+ const prefetchCommand = new commander.Command("prefetch").description("Pre-download packages used by MCP servers (npx, pnpx, uvx, uv)").option("-c, --config <path>", "Path to MCP server configuration file").option("-p, --parallel", "Run prefetch commands in parallel", false).option("-d, --dry-run", "Show what would be prefetched without executing", false).option("-f, --filter <type>", "Filter by package manager type: npx, pnpx, uvx, or uv").option("--definitions-out <path>", "Write discovered definitions to a JSON or YAML cache file").option("--skip-packages", "Skip package prefetch and only build definitions cache", false).option("--clear-definitions-cache", "Delete the definitions cache file before continuing", false).action(async (options) => {
1200
1305
  try {
1201
1306
  const configFilePath = options.config || require_http.findConfigFile();
1202
1307
  if (!configFilePath) {
@@ -1205,50 +1310,96 @@ const prefetchCommand = new commander.Command("prefetch").description("Pre-downl
1205
1310
  process.exit(1);
1206
1311
  }
1207
1312
  __agiflowai_aicode_utils.print.info(`Loading configuration from: ${configFilePath}`);
1313
+ const mcpConfig = await new require_http.ConfigFetcherService({
1314
+ configFilePath,
1315
+ useCache: false
1316
+ }).fetchConfiguration(true);
1317
+ const serverId = mcpConfig.id || require_http.generateServerId();
1318
+ const configHash = require_http.DefinitionsCacheService.generateConfigHash(mcpConfig);
1319
+ const effectiveDefinitionsPath = options.definitionsOut || require_http.DefinitionsCacheService.getDefaultCachePath(configFilePath);
1208
1320
  const prefetchService = new PrefetchService({
1209
- mcpConfig: await new require_http.ConfigFetcherService({
1210
- configFilePath,
1211
- useCache: false
1212
- }).fetchConfiguration(true),
1321
+ mcpConfig,
1213
1322
  filter: options.filter,
1214
1323
  parallel: options.parallel
1215
1324
  });
1216
1325
  const packages = prefetchService.extractPackages();
1217
- if (packages.length === 0) {
1326
+ const shouldPrefetchPackages = !options.skipPackages;
1327
+ const shouldWriteDefinitions = Boolean(options.definitionsOut);
1328
+ if (options.clearDefinitionsCache) if (options.dryRun) __agiflowai_aicode_utils.print.info(`Would clear definitions cache: ${effectiveDefinitionsPath}`);
1329
+ else {
1330
+ await require_http.DefinitionsCacheService.clearFile(effectiveDefinitionsPath);
1331
+ __agiflowai_aicode_utils.print.success(`Cleared definitions cache: ${effectiveDefinitionsPath}`);
1332
+ }
1333
+ if (shouldPrefetchPackages) if (packages.length === 0) {
1218
1334
  __agiflowai_aicode_utils.print.warning("No packages found to prefetch.");
1219
1335
  __agiflowai_aicode_utils.print.info("Prefetch supports: npx, pnpx, uvx, and uv run commands");
1336
+ } else {
1337
+ __agiflowai_aicode_utils.print.info(`Found ${packages.length} package(s) to prefetch:`);
1338
+ for (const pkg of packages) __agiflowai_aicode_utils.print.item(`${pkg.serverName}: ${pkg.packageManager} ${pkg.packageName}`);
1339
+ }
1340
+ if (!shouldPrefetchPackages && !shouldWriteDefinitions) {
1341
+ __agiflowai_aicode_utils.print.warning("Nothing to do. Use package prefetch or provide --definitions-out.");
1220
1342
  return;
1221
1343
  }
1222
- __agiflowai_aicode_utils.print.info(`Found ${packages.length} package(s) to prefetch:`);
1223
- for (const pkg of packages) __agiflowai_aicode_utils.print.item(`${pkg.serverName}: ${pkg.packageManager} ${pkg.packageName}`);
1224
1344
  if (options.dryRun) {
1225
- __agiflowai_aicode_utils.print.newline();
1226
- __agiflowai_aicode_utils.print.header("Dry run mode - commands that would be executed:");
1227
- for (const pkg of packages) __agiflowai_aicode_utils.print.indent(pkg.fullCommand.join(" "));
1345
+ if (shouldPrefetchPackages && packages.length > 0) {
1346
+ __agiflowai_aicode_utils.print.newline();
1347
+ __agiflowai_aicode_utils.print.header("Dry run mode - commands that would be executed:");
1348
+ for (const pkg of packages) __agiflowai_aicode_utils.print.indent(pkg.fullCommand.join(" "));
1349
+ }
1350
+ if (shouldWriteDefinitions) {
1351
+ __agiflowai_aicode_utils.print.newline();
1352
+ __agiflowai_aicode_utils.print.info(`Would write definitions cache to: ${effectiveDefinitionsPath}`);
1353
+ }
1228
1354
  return;
1229
1355
  }
1230
- __agiflowai_aicode_utils.print.newline();
1231
- __agiflowai_aicode_utils.print.info("Prefetching packages...");
1232
- const summary = await prefetchService.prefetch();
1233
- __agiflowai_aicode_utils.print.newline();
1234
- if (summary.failed === 0) __agiflowai_aicode_utils.print.success(`Prefetch complete: ${summary.successful} succeeded, ${summary.failed} failed`);
1235
- else __agiflowai_aicode_utils.print.warning(`Prefetch complete: ${summary.successful} succeeded, ${summary.failed} failed`);
1236
- if (summary.failed > 0) {
1356
+ let packagePrefetchFailed = false;
1357
+ if (shouldPrefetchPackages && packages.length > 0) {
1237
1358
  __agiflowai_aicode_utils.print.newline();
1238
- __agiflowai_aicode_utils.print.error("Failed packages:");
1239
- for (const result of summary.results.filter((r) => !r.success)) __agiflowai_aicode_utils.print.item(`${result.package.serverName} (${result.package.packageName}): ${result.output.trim()}`);
1240
- process.exit(1);
1359
+ __agiflowai_aicode_utils.print.info("Prefetching packages...");
1360
+ const summary = await prefetchService.prefetch();
1361
+ __agiflowai_aicode_utils.print.newline();
1362
+ if (summary.failed === 0) __agiflowai_aicode_utils.print.success(`Package prefetch complete: ${summary.successful} succeeded, ${summary.failed} failed`);
1363
+ else __agiflowai_aicode_utils.print.warning(`Package prefetch complete: ${summary.successful} succeeded, ${summary.failed} failed`);
1364
+ if (summary.failed > 0) {
1365
+ packagePrefetchFailed = true;
1366
+ __agiflowai_aicode_utils.print.newline();
1367
+ __agiflowai_aicode_utils.print.error("Failed packages:");
1368
+ for (const result of summary.results.filter((r) => !r.success)) __agiflowai_aicode_utils.print.item(`${result.package.serverName} (${result.package.packageName}): ${result.output.trim()}`);
1369
+ }
1241
1370
  }
1371
+ if (shouldWriteDefinitions) {
1372
+ __agiflowai_aicode_utils.print.newline();
1373
+ __agiflowai_aicode_utils.print.info("Collecting definitions cache...");
1374
+ const clientManager = new require_http.McpClientManagerService();
1375
+ const skillPaths = mcpConfig.skills?.paths || [];
1376
+ const definitionsCacheService = new require_http.DefinitionsCacheService(clientManager, skillPaths.length > 0 ? new require_http.SkillService(process.cwd(), skillPaths) : void 0);
1377
+ await Promise.all(Object.entries(mcpConfig.mcpServers).map(async ([serverName, serverConfig]) => {
1378
+ try {
1379
+ await clientManager.connectToServer(serverName, serverConfig);
1380
+ __agiflowai_aicode_utils.print.item(`Connected for definitions: ${serverName}`);
1381
+ } catch (error) {
1382
+ __agiflowai_aicode_utils.print.warning(`Failed to connect for definitions: ${serverName} (${error instanceof Error ? error.message : String(error)})`);
1383
+ }
1384
+ }));
1385
+ const definitionsCache = await definitionsCacheService.collectForCache({
1386
+ configPath: configFilePath,
1387
+ configHash,
1388
+ oneMcpVersion: require_http.version,
1389
+ serverId
1390
+ });
1391
+ await require_http.DefinitionsCacheService.writeToFile(effectiveDefinitionsPath, definitionsCache);
1392
+ __agiflowai_aicode_utils.print.success(`Definitions cache written: ${effectiveDefinitionsPath} (${Object.keys(definitionsCache.servers).length} servers, ${definitionsCache.skills.length} skills)`);
1393
+ if (definitionsCache.failures.length > 0) __agiflowai_aicode_utils.print.warning(`Definitions cache completed with ${definitionsCache.failures.length} server failure(s)`);
1394
+ await clientManager.disconnectAll();
1395
+ }
1396
+ if (packagePrefetchFailed) process.exit(1);
1242
1397
  } catch (error) {
1243
1398
  __agiflowai_aicode_utils.print.error("Error executing prefetch:", error instanceof Error ? error.message : String(error));
1244
1399
  process.exit(1);
1245
1400
  }
1246
1401
  });
1247
1402
 
1248
- //#endregion
1249
- //#region package.json
1250
- var version = "0.3.10";
1251
-
1252
1403
  //#endregion
1253
1404
  //#region src/cli.ts
1254
1405
  /**
@@ -1275,14 +1426,16 @@ var version = "0.3.10";
1275
1426
  async function main() {
1276
1427
  try {
1277
1428
  const program = new commander.Command();
1278
- program.name("one-mcp").description("One MCP server package").version(version);
1429
+ program.name("one-mcp").description("One MCP server package").version(require_http.version);
1279
1430
  program.addCommand(initCommand);
1280
1431
  program.addCommand(mcpServeCommand);
1281
- program.addCommand(listToolsCommand);
1432
+ program.addCommand(searchToolsCommand);
1282
1433
  program.addCommand(describeToolsCommand);
1283
1434
  program.addCommand(useToolCommand);
1284
1435
  program.addCommand(listResourcesCommand);
1285
1436
  program.addCommand(readResourceCommand);
1437
+ program.addCommand(listPromptsCommand);
1438
+ program.addCommand(getPromptCommand);
1286
1439
  program.addCommand(prefetchCommand);
1287
1440
  await program.parseAsync(process.argv);
1288
1441
  } catch (error) {