@agiflowai/one-mcp 0.3.1 → 0.3.3

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-C4IfZSwW.cjs');
2
+ const require_http = require('./http-BzrxGEr-.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");
@@ -148,14 +148,27 @@ const listToolsCommand = new commander.Command("list-tools").description("List a
148
148
  process.exit(1);
149
149
  }
150
150
  const toolsByServer = {};
151
- for (const client of clients) try {
152
- const tools = await client.listTools();
153
- const blacklist = new Set(client.toolBlacklist || []);
154
- const filteredTools = tools.filter((t) => !blacklist.has(t.name));
155
- toolsByServer[client.serverName] = filteredTools;
156
- } catch (error) {
157
- if (!options.json) console.error(`Failed to list tools from ${client.serverName}:`, error);
158
- toolsByServer[client.serverName] = [];
151
+ const toolResults = await Promise.all(clients.map(async (client) => {
152
+ try {
153
+ const tools = await client.listTools();
154
+ const blacklist = new Set(client.toolBlacklist || []);
155
+ const filteredTools = tools.filter((t) => !blacklist.has(t.name));
156
+ return {
157
+ serverName: client.serverName,
158
+ tools: filteredTools,
159
+ error: null
160
+ };
161
+ } catch (error) {
162
+ return {
163
+ serverName: client.serverName,
164
+ tools: [],
165
+ error
166
+ };
167
+ }
168
+ }));
169
+ for (const { serverName, tools, error } of toolResults) {
170
+ if (error && !options.json) console.error(`Failed to list tools from ${serverName}:`, error);
171
+ toolsByServer[serverName] = tools;
159
172
  }
160
173
  if (options.json) console.log(JSON.stringify(toolsByServer, null, 2));
161
174
  else for (const [serverName, tools] of Object.entries(toolsByServer)) {
@@ -229,43 +242,60 @@ const describeToolsCommand = new commander.Command("describe-tools").description
229
242
  const foundTools = [];
230
243
  const foundSkills = [];
231
244
  const notFoundTools = [...toolNames];
232
- for (const client of clients) {
233
- if (options.server && client.serverName !== options.server) continue;
245
+ const filteredClients = clients.filter((client) => !options.server || client.serverName === options.server);
246
+ const toolResults = await Promise.all(filteredClients.map(async (client) => {
234
247
  try {
235
- const tools = await client.listTools();
236
- for (const toolName of toolNames) {
237
- const tool = tools.find((t) => t.name === toolName);
238
- if (tool) {
239
- foundTools.push({
240
- server: client.serverName,
241
- name: tool.name,
242
- description: tool.description,
243
- inputSchema: tool.inputSchema
244
- });
245
- const idx = notFoundTools.indexOf(toolName);
246
- if (idx > -1) notFoundTools.splice(idx, 1);
247
- }
248
- }
248
+ return {
249
+ client,
250
+ tools: await client.listTools(),
251
+ error: null
252
+ };
249
253
  } catch (error) {
254
+ return {
255
+ client,
256
+ tools: [],
257
+ error
258
+ };
259
+ }
260
+ }));
261
+ for (const { client, tools, error } of toolResults) {
262
+ if (error) {
250
263
  if (!options.json) console.error(`Failed to list tools from ${client.serverName}:`, error);
264
+ continue;
251
265
  }
252
- }
253
- if (skillService && notFoundTools.length > 0) {
254
- const skillsToCheck = [...notFoundTools];
255
- for (const toolName of skillsToCheck) {
256
- const skillName = toolName.startsWith("skill__") ? toolName.slice(7) : toolName;
257
- const skill = await skillService.getSkill(skillName);
258
- if (skill) {
259
- foundSkills.push({
260
- name: skill.name,
261
- location: skill.basePath,
262
- instructions: skill.content
266
+ for (const toolName of toolNames) {
267
+ const tool = tools.find((t) => t.name === toolName);
268
+ if (tool) {
269
+ foundTools.push({
270
+ server: client.serverName,
271
+ name: tool.name,
272
+ description: tool.description,
273
+ inputSchema: tool.inputSchema
263
274
  });
264
275
  const idx = notFoundTools.indexOf(toolName);
265
276
  if (idx > -1) notFoundTools.splice(idx, 1);
266
277
  }
267
278
  }
268
279
  }
280
+ if (skillService && notFoundTools.length > 0) {
281
+ const skillsToCheck = [...notFoundTools];
282
+ const skillResults = await Promise.all(skillsToCheck.map(async (toolName) => {
283
+ const skillName = toolName.startsWith("skill__") ? toolName.slice(7) : toolName;
284
+ return {
285
+ toolName,
286
+ skill: await skillService.getSkill(skillName)
287
+ };
288
+ }));
289
+ for (const { toolName, skill } of skillResults) if (skill) {
290
+ foundSkills.push({
291
+ name: skill.name,
292
+ location: skill.basePath,
293
+ instructions: skill.content
294
+ });
295
+ const idx = notFoundTools.indexOf(toolName);
296
+ if (idx > -1) notFoundTools.splice(idx, 1);
297
+ }
298
+ }
269
299
  const nextSteps = [];
270
300
  if (foundTools.length > 0) nextSteps.push("For MCP tools: Use the use_tool function with toolName and toolArgs based on the inputSchema above.");
271
301
  if (foundSkills.length > 0) nextSteps.push(`For skill, just follow skill's description to continue.`);
@@ -398,11 +428,29 @@ const useToolCommand = new commander.Command("use-tool").description("Execute an
398
428
  process.exit(1);
399
429
  }
400
430
  }
431
+ const searchResults = await Promise.all(clients.map(async (client$1) => {
432
+ try {
433
+ const hasTool = (await client$1.listTools()).some((t) => t.name === toolName);
434
+ return {
435
+ serverName: client$1.serverName,
436
+ hasTool,
437
+ error: null
438
+ };
439
+ } catch (error) {
440
+ return {
441
+ serverName: client$1.serverName,
442
+ hasTool: false,
443
+ error
444
+ };
445
+ }
446
+ }));
401
447
  const matchingServers = [];
402
- for (const client$1 of clients) try {
403
- if ((await client$1.listTools()).some((t) => t.name === toolName)) matchingServers.push(client$1.serverName);
404
- } catch (error) {
405
- if (!options.json) console.error(`Failed to list tools from ${client$1.serverName}:`, error);
448
+ for (const { serverName, hasTool, error } of searchResults) {
449
+ if (error) {
450
+ if (!options.json) console.error(`Failed to list tools from ${serverName}:`, error);
451
+ continue;
452
+ }
453
+ if (hasTool) matchingServers.push(serverName);
406
454
  }
407
455
  if (matchingServers.length === 0) {
408
456
  const cwd = process.env.PROJECT_PATH || process.cwd();
@@ -1003,7 +1051,7 @@ const prefetchCommand = new commander.Command("prefetch").description("Pre-downl
1003
1051
 
1004
1052
  //#endregion
1005
1053
  //#region package.json
1006
- var version = "0.3.0";
1054
+ var version = "0.3.2";
1007
1055
 
1008
1056
  //#endregion
1009
1057
  //#region src/cli.ts
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { a as SkillService, c as ConfigFetcherService, i as createServer, n as SseTransportHandler, o as findConfigFile, r as StdioTransportHandler, s as McpClientManagerService, t as HttpTransportHandler } from "./http-xi_ha63Y.mjs";
2
+ import { a as SkillService, c as ConfigFetcherService, i as createServer, n as SseTransportHandler, o as findConfigFile, r as StdioTransportHandler, s as McpClientManagerService, t as HttpTransportHandler } from "./http-DeUYygKb.mjs";
3
3
  import { writeFile } from "node:fs/promises";
4
4
  import { resolve } from "node:path";
5
5
  import { Liquid } from "liquidjs";
@@ -148,14 +148,27 @@ const listToolsCommand = new Command("list-tools").description("List all availab
148
148
  process.exit(1);
149
149
  }
150
150
  const toolsByServer = {};
151
- for (const client of clients) try {
152
- const tools = await client.listTools();
153
- const blacklist = new Set(client.toolBlacklist || []);
154
- const filteredTools = tools.filter((t) => !blacklist.has(t.name));
155
- toolsByServer[client.serverName] = filteredTools;
156
- } catch (error) {
157
- if (!options.json) console.error(`Failed to list tools from ${client.serverName}:`, error);
158
- toolsByServer[client.serverName] = [];
151
+ const toolResults = await Promise.all(clients.map(async (client) => {
152
+ try {
153
+ const tools = await client.listTools();
154
+ const blacklist = new Set(client.toolBlacklist || []);
155
+ const filteredTools = tools.filter((t) => !blacklist.has(t.name));
156
+ return {
157
+ serverName: client.serverName,
158
+ tools: filteredTools,
159
+ error: null
160
+ };
161
+ } catch (error) {
162
+ return {
163
+ serverName: client.serverName,
164
+ tools: [],
165
+ error
166
+ };
167
+ }
168
+ }));
169
+ for (const { serverName, tools, error } of toolResults) {
170
+ if (error && !options.json) console.error(`Failed to list tools from ${serverName}:`, error);
171
+ toolsByServer[serverName] = tools;
159
172
  }
160
173
  if (options.json) console.log(JSON.stringify(toolsByServer, null, 2));
161
174
  else for (const [serverName, tools] of Object.entries(toolsByServer)) {
@@ -229,43 +242,60 @@ const describeToolsCommand = new Command("describe-tools").description("Describe
229
242
  const foundTools = [];
230
243
  const foundSkills = [];
231
244
  const notFoundTools = [...toolNames];
232
- for (const client of clients) {
233
- if (options.server && client.serverName !== options.server) continue;
245
+ const filteredClients = clients.filter((client) => !options.server || client.serverName === options.server);
246
+ const toolResults = await Promise.all(filteredClients.map(async (client) => {
234
247
  try {
235
- const tools = await client.listTools();
236
- for (const toolName of toolNames) {
237
- const tool = tools.find((t) => t.name === toolName);
238
- if (tool) {
239
- foundTools.push({
240
- server: client.serverName,
241
- name: tool.name,
242
- description: tool.description,
243
- inputSchema: tool.inputSchema
244
- });
245
- const idx = notFoundTools.indexOf(toolName);
246
- if (idx > -1) notFoundTools.splice(idx, 1);
247
- }
248
- }
248
+ return {
249
+ client,
250
+ tools: await client.listTools(),
251
+ error: null
252
+ };
249
253
  } catch (error) {
254
+ return {
255
+ client,
256
+ tools: [],
257
+ error
258
+ };
259
+ }
260
+ }));
261
+ for (const { client, tools, error } of toolResults) {
262
+ if (error) {
250
263
  if (!options.json) console.error(`Failed to list tools from ${client.serverName}:`, error);
264
+ continue;
251
265
  }
252
- }
253
- if (skillService && notFoundTools.length > 0) {
254
- const skillsToCheck = [...notFoundTools];
255
- for (const toolName of skillsToCheck) {
256
- const skillName = toolName.startsWith("skill__") ? toolName.slice(7) : toolName;
257
- const skill = await skillService.getSkill(skillName);
258
- if (skill) {
259
- foundSkills.push({
260
- name: skill.name,
261
- location: skill.basePath,
262
- instructions: skill.content
266
+ for (const toolName of toolNames) {
267
+ const tool = tools.find((t) => t.name === toolName);
268
+ if (tool) {
269
+ foundTools.push({
270
+ server: client.serverName,
271
+ name: tool.name,
272
+ description: tool.description,
273
+ inputSchema: tool.inputSchema
263
274
  });
264
275
  const idx = notFoundTools.indexOf(toolName);
265
276
  if (idx > -1) notFoundTools.splice(idx, 1);
266
277
  }
267
278
  }
268
279
  }
280
+ if (skillService && notFoundTools.length > 0) {
281
+ const skillsToCheck = [...notFoundTools];
282
+ const skillResults = await Promise.all(skillsToCheck.map(async (toolName) => {
283
+ const skillName = toolName.startsWith("skill__") ? toolName.slice(7) : toolName;
284
+ return {
285
+ toolName,
286
+ skill: await skillService.getSkill(skillName)
287
+ };
288
+ }));
289
+ for (const { toolName, skill } of skillResults) if (skill) {
290
+ foundSkills.push({
291
+ name: skill.name,
292
+ location: skill.basePath,
293
+ instructions: skill.content
294
+ });
295
+ const idx = notFoundTools.indexOf(toolName);
296
+ if (idx > -1) notFoundTools.splice(idx, 1);
297
+ }
298
+ }
269
299
  const nextSteps = [];
270
300
  if (foundTools.length > 0) nextSteps.push("For MCP tools: Use the use_tool function with toolName and toolArgs based on the inputSchema above.");
271
301
  if (foundSkills.length > 0) nextSteps.push(`For skill, just follow skill's description to continue.`);
@@ -398,11 +428,29 @@ const useToolCommand = new Command("use-tool").description("Execute an MCP tool
398
428
  process.exit(1);
399
429
  }
400
430
  }
431
+ const searchResults = await Promise.all(clients.map(async (client$1) => {
432
+ try {
433
+ const hasTool = (await client$1.listTools()).some((t) => t.name === toolName);
434
+ return {
435
+ serverName: client$1.serverName,
436
+ hasTool,
437
+ error: null
438
+ };
439
+ } catch (error) {
440
+ return {
441
+ serverName: client$1.serverName,
442
+ hasTool: false,
443
+ error
444
+ };
445
+ }
446
+ }));
401
447
  const matchingServers = [];
402
- for (const client$1 of clients) try {
403
- if ((await client$1.listTools()).some((t) => t.name === toolName)) matchingServers.push(client$1.serverName);
404
- } catch (error) {
405
- if (!options.json) console.error(`Failed to list tools from ${client$1.serverName}:`, error);
448
+ for (const { serverName, hasTool, error } of searchResults) {
449
+ if (error) {
450
+ if (!options.json) console.error(`Failed to list tools from ${serverName}:`, error);
451
+ continue;
452
+ }
453
+ if (hasTool) matchingServers.push(serverName);
406
454
  }
407
455
  if (matchingServers.length === 0) {
408
456
  const cwd = process.env.PROJECT_PATH || process.cwd();
@@ -1003,7 +1051,7 @@ const prefetchCommand = new Command("prefetch").description("Pre-download packag
1003
1051
 
1004
1052
  //#endregion
1005
1053
  //#region package.json
1006
- var version = "0.3.0";
1054
+ var version = "0.3.2";
1007
1055
 
1008
1056
  //#endregion
1009
1057
  //#region src/cli.ts
@@ -557,22 +557,21 @@ var RemoteConfigCacheService = class {
557
557
  try {
558
558
  if (!(0, node_fs.existsSync)(this.cacheDir)) return;
559
559
  const now = Date.now();
560
- const files = await (0, node_fs_promises.readdir)(this.cacheDir);
561
- let expiredCount = 0;
562
- for (const file of files) {
563
- if (!file.endsWith(".json")) continue;
560
+ const jsonFiles = (await (0, node_fs_promises.readdir)(this.cacheDir)).filter((file) => file.endsWith(".json"));
561
+ const expiredCount = (await Promise.all(jsonFiles.map(async (file) => {
564
562
  const filePath = (0, node_path.join)(this.cacheDir, file);
565
563
  try {
566
564
  const content = await (0, node_fs_promises.readFile)(filePath, "utf-8");
567
565
  if (now > JSON.parse(content).expiresAt) {
568
566
  await (0, node_fs_promises.unlink)(filePath);
569
- expiredCount++;
567
+ return true;
570
568
  }
569
+ return false;
571
570
  } catch (error) {
572
571
  await (0, node_fs_promises.unlink)(filePath).catch(() => {});
573
- expiredCount++;
572
+ return true;
574
573
  }
575
- }
574
+ }))).filter(Boolean).length;
576
575
  if (expiredCount > 0) console.error(`Cleaned up ${expiredCount} expired remote config cache entries`);
577
576
  } catch (error) {
578
577
  console.error("Failed to clean expired remote config cache:", error);
@@ -588,14 +587,15 @@ var RemoteConfigCacheService = class {
588
587
  totalSize: 0
589
588
  };
590
589
  const jsonFiles = (await (0, node_fs_promises.readdir)(this.cacheDir)).filter((file) => file.endsWith(".json"));
591
- let totalSize = 0;
592
- for (const file of jsonFiles) {
590
+ const totalSize = (await Promise.all(jsonFiles.map(async (file) => {
593
591
  const filePath = (0, node_path.join)(this.cacheDir, file);
594
592
  try {
595
593
  const content = await (0, node_fs_promises.readFile)(filePath, "utf-8");
596
- totalSize += Buffer.byteLength(content, "utf-8");
597
- } catch {}
598
- }
594
+ return Buffer.byteLength(content, "utf-8");
595
+ } catch {
596
+ return 0;
597
+ }
598
+ }))).reduce((sum, size) => sum + size, 0);
599
599
  return {
600
600
  totalEntries: jsonFiles.length,
601
601
  totalSize
@@ -1416,13 +1416,13 @@ var SkillService = class {
1416
1416
  if (this.cachedSkills !== null) return this.cachedSkills;
1417
1417
  const skills = [];
1418
1418
  const loadedSkillNames = /* @__PURE__ */ new Set();
1419
- for (const skillPath of this.skillPaths) {
1419
+ const allDirSkills = await Promise.all(this.skillPaths.map(async (skillPath) => {
1420
1420
  const skillsDir = (0, node_path.isAbsolute)(skillPath) ? skillPath : (0, node_path.join)(this.cwd, skillPath);
1421
- const dirSkills = await this.loadSkillsFromDirectory(skillsDir, "project");
1422
- for (const skill of dirSkills) if (!loadedSkillNames.has(skill.name)) {
1423
- skills.push(skill);
1424
- loadedSkillNames.add(skill.name);
1425
- }
1421
+ return this.loadSkillsFromDirectory(skillsDir, "project");
1422
+ }));
1423
+ for (const dirSkills of allDirSkills) for (const skill of dirSkills) if (!loadedSkillNames.has(skill.name)) {
1424
+ skills.push(skill);
1425
+ loadedSkillNames.add(skill.name);
1426
1426
  }
1427
1427
  this.cachedSkills = skills;
1428
1428
  this.skillsByName = new Map(skills.map((skill) => [skill.name, skill]));
@@ -1460,9 +1460,15 @@ var SkillService = class {
1460
1460
  */
1461
1461
  async startWatching() {
1462
1462
  this.stopWatching();
1463
- for (const skillPath of this.skillPaths) {
1463
+ const existenceChecks = await Promise.all(this.skillPaths.map(async (skillPath) => {
1464
1464
  const skillsDir = (0, node_path.isAbsolute)(skillPath) ? skillPath : (0, node_path.join)(this.cwd, skillPath);
1465
- if (!await pathExists(skillsDir)) continue;
1465
+ return {
1466
+ skillsDir,
1467
+ exists: await pathExists(skillsDir)
1468
+ };
1469
+ }));
1470
+ for (const { skillsDir, exists } of existenceChecks) {
1471
+ if (!exists) continue;
1466
1472
  const abortController = new AbortController();
1467
1473
  this.watchers.push(abortController);
1468
1474
  this.watchDirectory(skillsDir, abortController.signal).catch((error) => {
@@ -1520,34 +1526,49 @@ var SkillService = class {
1520
1526
  } catch (error) {
1521
1527
  throw new SkillLoadError(`Failed to read skills directory: ${error instanceof Error ? error.message : "Unknown error"}`, dirPath, error instanceof Error ? error : void 0);
1522
1528
  }
1523
- for (const entry of entries) {
1529
+ const entryStats = await Promise.all(entries.map(async (entry) => {
1524
1530
  const entryPath = (0, node_path.join)(dirPath, entry);
1525
- let entryStat;
1526
1531
  try {
1527
- entryStat = await (0, node_fs_promises.stat)(entryPath);
1532
+ return {
1533
+ entry,
1534
+ entryPath,
1535
+ stat: await (0, node_fs_promises.stat)(entryPath),
1536
+ error: null
1537
+ };
1528
1538
  } catch (error) {
1529
1539
  console.warn(`Skipping entry ${entryPath}: ${error instanceof Error ? error.message : "Unknown error"}`);
1530
- continue;
1540
+ return {
1541
+ entry,
1542
+ entryPath,
1543
+ stat: null,
1544
+ error
1545
+ };
1531
1546
  }
1547
+ }));
1548
+ const skillFilesToLoad = [];
1549
+ for (const { entry, entryPath, stat: entryStat } of entryStats) {
1550
+ if (!entryStat) continue;
1532
1551
  if (entryStat.isDirectory()) {
1533
1552
  const skillFilePath = (0, node_path.join)(entryPath, "SKILL.md");
1534
- try {
1535
- if (await pathExists(skillFilePath)) {
1536
- const skill = await this.loadSkillFile(skillFilePath, location);
1537
- if (skill) skills.push(skill);
1538
- }
1539
- } catch (error) {
1540
- console.warn(`Skipping skill at ${skillFilePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
1541
- continue;
1542
- }
1543
- } else if (entry === "SKILL.md") try {
1544
- const skill = await this.loadSkillFile(entryPath, location);
1545
- if (skill) skills.push(skill);
1553
+ skillFilesToLoad.push({
1554
+ filePath: skillFilePath,
1555
+ isRootLevel: false
1556
+ });
1557
+ } else if (entry === "SKILL.md") skillFilesToLoad.push({
1558
+ filePath: entryPath,
1559
+ isRootLevel: true
1560
+ });
1561
+ }
1562
+ const loadResults = await Promise.all(skillFilesToLoad.map(async ({ filePath, isRootLevel }) => {
1563
+ try {
1564
+ if (!isRootLevel && !await pathExists(filePath)) return null;
1565
+ return await this.loadSkillFile(filePath, location);
1546
1566
  } catch (error) {
1547
- console.warn(`Skipping skill at ${entryPath}: ${error instanceof Error ? error.message : "Unknown error"}`);
1548
- continue;
1567
+ console.warn(`Skipping skill at ${filePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
1568
+ return null;
1549
1569
  }
1550
- }
1570
+ }));
1571
+ for (const skill of loadResults) if (skill) skills.push(skill);
1551
1572
  return skills;
1552
1573
  }
1553
1574
  /**
@@ -1689,44 +1710,42 @@ var DescribeToolsTool = class DescribeToolsTool {
1689
1710
  async detectSkillsFromPromptFrontMatter() {
1690
1711
  if (this.autoDetectedSkillsCache !== null) return this.autoDetectedSkillsCache;
1691
1712
  const clients = this.clientManager.getAllClients();
1692
- const autoDetectedSkills = [];
1693
1713
  let listPromptsFailures = 0;
1694
1714
  let fetchPromptFailures = 0;
1695
- const fetchPromises = [];
1696
- for (const client of clients) {
1715
+ const autoDetectedSkills = (await Promise.all(clients.map(async (client) => {
1716
+ const detectedSkills = [];
1697
1717
  const configuredPromptNames = new Set(client.prompts ? Object.keys(client.prompts) : []);
1698
- const listPromptsPromise = (async () => {
1699
- try {
1700
- const prompts = await client.listPrompts();
1701
- if (!prompts || prompts.length === 0) return;
1702
- const promptFetchPromises = prompts.map(async (promptInfo) => {
1703
- if (configuredPromptNames.has(promptInfo.name)) return;
1704
- try {
1705
- const skillExtraction = extractSkillFrontMatter(((await client.getPrompt(promptInfo.name)).messages || []).map((m) => {
1706
- const content = m.content;
1707
- if (typeof content === "string") return content;
1708
- if (content && typeof content === "object" && "text" in content) return String(content.text);
1709
- return "";
1710
- }).join("\n"));
1711
- if (skillExtraction) autoDetectedSkills.push({
1712
- serverName: client.serverName,
1713
- promptName: promptInfo.name,
1714
- skill: skillExtraction.skill
1715
- });
1716
- } catch (error) {
1717
- fetchPromptFailures++;
1718
- console.error(`${LOG_PREFIX_SKILL_DETECTION} Failed to fetch prompt '${promptInfo.name}' from ${client.serverName}: ${error instanceof Error ? error.message : "Unknown error"}`);
1719
- }
1720
- });
1721
- await Promise.all(promptFetchPromises);
1722
- } catch (error) {
1723
- listPromptsFailures++;
1724
- console.error(`${LOG_PREFIX_SKILL_DETECTION} Failed to list prompts from ${client.serverName}: ${error instanceof Error ? error.message : "Unknown error"}`);
1725
- }
1726
- })();
1727
- fetchPromises.push(listPromptsPromise);
1728
- }
1729
- await Promise.all(fetchPromises);
1718
+ try {
1719
+ const prompts = await client.listPrompts();
1720
+ if (!prompts || prompts.length === 0) return detectedSkills;
1721
+ const promptResults = await Promise.all(prompts.map(async (promptInfo) => {
1722
+ if (configuredPromptNames.has(promptInfo.name)) return null;
1723
+ try {
1724
+ const skillExtraction = extractSkillFrontMatter(((await client.getPrompt(promptInfo.name)).messages || []).map((m) => {
1725
+ const content = m.content;
1726
+ if (typeof content === "string") return content;
1727
+ if (content && typeof content === "object" && "text" in content) return String(content.text);
1728
+ return "";
1729
+ }).join("\n"));
1730
+ if (skillExtraction) return {
1731
+ serverName: client.serverName,
1732
+ promptName: promptInfo.name,
1733
+ skill: skillExtraction.skill
1734
+ };
1735
+ return null;
1736
+ } catch (error) {
1737
+ fetchPromptFailures++;
1738
+ console.error(`${LOG_PREFIX_SKILL_DETECTION} Failed to fetch prompt '${promptInfo.name}' from ${client.serverName}: ${error instanceof Error ? error.message : "Unknown error"}`);
1739
+ return null;
1740
+ }
1741
+ }));
1742
+ for (const result of promptResults) if (result) detectedSkills.push(result);
1743
+ } catch (error) {
1744
+ listPromptsFailures++;
1745
+ console.error(`${LOG_PREFIX_SKILL_DETECTION} Failed to list prompts from ${client.serverName}: ${error instanceof Error ? error.message : "Unknown error"}`);
1746
+ }
1747
+ return detectedSkills;
1748
+ }))).flat();
1730
1749
  if (listPromptsFailures > 0 || fetchPromptFailures > 0) console.error(`${LOG_PREFIX_SKILL_DETECTION} Completed with ${listPromptsFailures} server failure(s) and ${fetchPromptFailures} prompt failure(s). Detected ${autoDetectedSkills.length} skill(s).`);
1731
1750
  this.autoDetectedSkillsCache = autoDetectedSkills;
1732
1751
  return autoDetectedSkills;
@@ -1977,40 +1996,42 @@ var DescribeToolsTool = class DescribeToolsTool {
1977
1996
  serverToolsMap.set(client.serverName, []);
1978
1997
  }
1979
1998
  }));
1980
- const foundTools = [];
1981
- const foundSkills = [];
1982
- const notFoundItems = [];
1983
- for (const requestedName of toolNames) {
1999
+ const lookupResults = await Promise.all(toolNames.map(async (requestedName) => {
2000
+ const result$1 = {
2001
+ tools: [],
2002
+ skills: [],
2003
+ notFound: null
2004
+ };
1984
2005
  if (requestedName.startsWith(SKILL_PREFIX)) {
1985
2006
  const skillName = requestedName.slice(SKILL_PREFIX.length);
1986
2007
  if (this.skillService) {
1987
2008
  const skill = await this.skillService.getSkill(skillName);
1988
2009
  if (skill) {
1989
- foundSkills.push({
2010
+ result$1.skills.push({
1990
2011
  name: skill.name,
1991
2012
  location: skill.basePath,
1992
2013
  instructions: formatSkillInstructions(skill.name, skill.content)
1993
2014
  });
1994
- continue;
2015
+ return result$1;
1995
2016
  }
1996
2017
  }
1997
2018
  const promptSkillContent = await this.getPromptSkillContent(skillName);
1998
2019
  if (promptSkillContent) {
1999
- foundSkills.push(promptSkillContent);
2000
- continue;
2020
+ result$1.skills.push(promptSkillContent);
2021
+ return result$1;
2001
2022
  }
2002
- notFoundItems.push(requestedName);
2003
- continue;
2023
+ result$1.notFound = requestedName;
2024
+ return result$1;
2004
2025
  }
2005
2026
  const { serverName, actualToolName } = parseToolName(requestedName);
2006
2027
  if (serverName) {
2007
2028
  const serverTools = serverToolsMap.get(serverName);
2008
2029
  if (!serverTools) {
2009
- notFoundItems.push(requestedName);
2010
- continue;
2030
+ result$1.notFound = requestedName;
2031
+ return result$1;
2011
2032
  }
2012
2033
  const tool = serverTools.find((t) => t.name === actualToolName);
2013
- if (tool) foundTools.push({
2034
+ if (tool) result$1.tools.push({
2014
2035
  server: serverName,
2015
2036
  tool: {
2016
2037
  name: tool.name,
@@ -2018,52 +2039,61 @@ var DescribeToolsTool = class DescribeToolsTool {
2018
2039
  inputSchema: tool.inputSchema
2019
2040
  }
2020
2041
  });
2021
- else notFoundItems.push(requestedName);
2022
- } else {
2023
- const servers = toolToServers.get(actualToolName);
2024
- if (!servers || servers.length === 0) {
2025
- if (this.skillService) {
2026
- const skill = await this.skillService.getSkill(actualToolName);
2027
- if (skill) {
2028
- foundSkills.push({
2029
- name: skill.name,
2030
- location: skill.basePath,
2031
- instructions: formatSkillInstructions(skill.name, skill.content)
2032
- });
2033
- continue;
2034
- }
2035
- }
2036
- const promptSkillContent = await this.getPromptSkillContent(actualToolName);
2037
- if (promptSkillContent) {
2038
- foundSkills.push(promptSkillContent);
2039
- continue;
2042
+ else result$1.notFound = requestedName;
2043
+ return result$1;
2044
+ }
2045
+ const servers = toolToServers.get(actualToolName);
2046
+ if (!servers || servers.length === 0) {
2047
+ if (this.skillService) {
2048
+ const skill = await this.skillService.getSkill(actualToolName);
2049
+ if (skill) {
2050
+ result$1.skills.push({
2051
+ name: skill.name,
2052
+ location: skill.basePath,
2053
+ instructions: formatSkillInstructions(skill.name, skill.content)
2054
+ });
2055
+ return result$1;
2040
2056
  }
2041
- notFoundItems.push(requestedName);
2042
- continue;
2043
2057
  }
2044
- if (servers.length === 1) {
2045
- const server = servers[0];
2046
- const tool = serverToolsMap.get(server).find((t) => t.name === actualToolName);
2047
- foundTools.push({
2048
- server,
2049
- tool: {
2050
- name: tool.name,
2051
- description: tool.description,
2052
- inputSchema: tool.inputSchema
2053
- }
2054
- });
2055
- } else for (const server of servers) {
2056
- const tool = serverToolsMap.get(server).find((t) => t.name === actualToolName);
2057
- foundTools.push({
2058
- server,
2059
- tool: {
2060
- name: tool.name,
2061
- description: tool.description,
2062
- inputSchema: tool.inputSchema
2063
- }
2064
- });
2058
+ const promptSkillContent = await this.getPromptSkillContent(actualToolName);
2059
+ if (promptSkillContent) {
2060
+ result$1.skills.push(promptSkillContent);
2061
+ return result$1;
2065
2062
  }
2063
+ result$1.notFound = requestedName;
2064
+ return result$1;
2066
2065
  }
2066
+ if (servers.length === 1) {
2067
+ const server = servers[0];
2068
+ const tool = serverToolsMap.get(server).find((t) => t.name === actualToolName);
2069
+ result$1.tools.push({
2070
+ server,
2071
+ tool: {
2072
+ name: tool.name,
2073
+ description: tool.description,
2074
+ inputSchema: tool.inputSchema
2075
+ }
2076
+ });
2077
+ } else for (const server of servers) {
2078
+ const tool = serverToolsMap.get(server).find((t) => t.name === actualToolName);
2079
+ result$1.tools.push({
2080
+ server,
2081
+ tool: {
2082
+ name: tool.name,
2083
+ description: tool.description,
2084
+ inputSchema: tool.inputSchema
2085
+ }
2086
+ });
2087
+ }
2088
+ return result$1;
2089
+ }));
2090
+ const foundTools = [];
2091
+ const foundSkills = [];
2092
+ const notFoundItems = [];
2093
+ for (const result$1 of lookupResults) {
2094
+ foundTools.push(...result$1.tools);
2095
+ foundSkills.push(...result$1.skills);
2096
+ if (result$1.notFound) notFoundItems.push(result$1.notFound);
2067
2097
  }
2068
2098
  if (foundTools.length === 0 && foundSkills.length === 0) return {
2069
2099
  content: [{
@@ -528,22 +528,21 @@ var RemoteConfigCacheService = class {
528
528
  try {
529
529
  if (!existsSync(this.cacheDir)) return;
530
530
  const now = Date.now();
531
- const files = await readdir(this.cacheDir);
532
- let expiredCount = 0;
533
- for (const file of files) {
534
- if (!file.endsWith(".json")) continue;
531
+ const jsonFiles = (await readdir(this.cacheDir)).filter((file) => file.endsWith(".json"));
532
+ const expiredCount = (await Promise.all(jsonFiles.map(async (file) => {
535
533
  const filePath = join(this.cacheDir, file);
536
534
  try {
537
535
  const content = await readFile(filePath, "utf-8");
538
536
  if (now > JSON.parse(content).expiresAt) {
539
537
  await unlink(filePath);
540
- expiredCount++;
538
+ return true;
541
539
  }
540
+ return false;
542
541
  } catch (error) {
543
542
  await unlink(filePath).catch(() => {});
544
- expiredCount++;
543
+ return true;
545
544
  }
546
- }
545
+ }))).filter(Boolean).length;
547
546
  if (expiredCount > 0) console.error(`Cleaned up ${expiredCount} expired remote config cache entries`);
548
547
  } catch (error) {
549
548
  console.error("Failed to clean expired remote config cache:", error);
@@ -559,14 +558,15 @@ var RemoteConfigCacheService = class {
559
558
  totalSize: 0
560
559
  };
561
560
  const jsonFiles = (await readdir(this.cacheDir)).filter((file) => file.endsWith(".json"));
562
- let totalSize = 0;
563
- for (const file of jsonFiles) {
561
+ const totalSize = (await Promise.all(jsonFiles.map(async (file) => {
564
562
  const filePath = join(this.cacheDir, file);
565
563
  try {
566
564
  const content = await readFile(filePath, "utf-8");
567
- totalSize += Buffer.byteLength(content, "utf-8");
568
- } catch {}
569
- }
565
+ return Buffer.byteLength(content, "utf-8");
566
+ } catch {
567
+ return 0;
568
+ }
569
+ }))).reduce((sum, size) => sum + size, 0);
570
570
  return {
571
571
  totalEntries: jsonFiles.length,
572
572
  totalSize
@@ -1387,13 +1387,13 @@ var SkillService = class {
1387
1387
  if (this.cachedSkills !== null) return this.cachedSkills;
1388
1388
  const skills = [];
1389
1389
  const loadedSkillNames = /* @__PURE__ */ new Set();
1390
- for (const skillPath of this.skillPaths) {
1390
+ const allDirSkills = await Promise.all(this.skillPaths.map(async (skillPath) => {
1391
1391
  const skillsDir = isAbsolute(skillPath) ? skillPath : join(this.cwd, skillPath);
1392
- const dirSkills = await this.loadSkillsFromDirectory(skillsDir, "project");
1393
- for (const skill of dirSkills) if (!loadedSkillNames.has(skill.name)) {
1394
- skills.push(skill);
1395
- loadedSkillNames.add(skill.name);
1396
- }
1392
+ return this.loadSkillsFromDirectory(skillsDir, "project");
1393
+ }));
1394
+ for (const dirSkills of allDirSkills) for (const skill of dirSkills) if (!loadedSkillNames.has(skill.name)) {
1395
+ skills.push(skill);
1396
+ loadedSkillNames.add(skill.name);
1397
1397
  }
1398
1398
  this.cachedSkills = skills;
1399
1399
  this.skillsByName = new Map(skills.map((skill) => [skill.name, skill]));
@@ -1431,9 +1431,15 @@ var SkillService = class {
1431
1431
  */
1432
1432
  async startWatching() {
1433
1433
  this.stopWatching();
1434
- for (const skillPath of this.skillPaths) {
1434
+ const existenceChecks = await Promise.all(this.skillPaths.map(async (skillPath) => {
1435
1435
  const skillsDir = isAbsolute(skillPath) ? skillPath : join(this.cwd, skillPath);
1436
- if (!await pathExists(skillsDir)) continue;
1436
+ return {
1437
+ skillsDir,
1438
+ exists: await pathExists(skillsDir)
1439
+ };
1440
+ }));
1441
+ for (const { skillsDir, exists } of existenceChecks) {
1442
+ if (!exists) continue;
1437
1443
  const abortController = new AbortController();
1438
1444
  this.watchers.push(abortController);
1439
1445
  this.watchDirectory(skillsDir, abortController.signal).catch((error) => {
@@ -1491,34 +1497,49 @@ var SkillService = class {
1491
1497
  } catch (error) {
1492
1498
  throw new SkillLoadError(`Failed to read skills directory: ${error instanceof Error ? error.message : "Unknown error"}`, dirPath, error instanceof Error ? error : void 0);
1493
1499
  }
1494
- for (const entry of entries) {
1500
+ const entryStats = await Promise.all(entries.map(async (entry) => {
1495
1501
  const entryPath = join(dirPath, entry);
1496
- let entryStat;
1497
1502
  try {
1498
- entryStat = await stat(entryPath);
1503
+ return {
1504
+ entry,
1505
+ entryPath,
1506
+ stat: await stat(entryPath),
1507
+ error: null
1508
+ };
1499
1509
  } catch (error) {
1500
1510
  console.warn(`Skipping entry ${entryPath}: ${error instanceof Error ? error.message : "Unknown error"}`);
1501
- continue;
1511
+ return {
1512
+ entry,
1513
+ entryPath,
1514
+ stat: null,
1515
+ error
1516
+ };
1502
1517
  }
1518
+ }));
1519
+ const skillFilesToLoad = [];
1520
+ for (const { entry, entryPath, stat: entryStat } of entryStats) {
1521
+ if (!entryStat) continue;
1503
1522
  if (entryStat.isDirectory()) {
1504
1523
  const skillFilePath = join(entryPath, "SKILL.md");
1505
- try {
1506
- if (await pathExists(skillFilePath)) {
1507
- const skill = await this.loadSkillFile(skillFilePath, location);
1508
- if (skill) skills.push(skill);
1509
- }
1510
- } catch (error) {
1511
- console.warn(`Skipping skill at ${skillFilePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
1512
- continue;
1513
- }
1514
- } else if (entry === "SKILL.md") try {
1515
- const skill = await this.loadSkillFile(entryPath, location);
1516
- if (skill) skills.push(skill);
1524
+ skillFilesToLoad.push({
1525
+ filePath: skillFilePath,
1526
+ isRootLevel: false
1527
+ });
1528
+ } else if (entry === "SKILL.md") skillFilesToLoad.push({
1529
+ filePath: entryPath,
1530
+ isRootLevel: true
1531
+ });
1532
+ }
1533
+ const loadResults = await Promise.all(skillFilesToLoad.map(async ({ filePath, isRootLevel }) => {
1534
+ try {
1535
+ if (!isRootLevel && !await pathExists(filePath)) return null;
1536
+ return await this.loadSkillFile(filePath, location);
1517
1537
  } catch (error) {
1518
- console.warn(`Skipping skill at ${entryPath}: ${error instanceof Error ? error.message : "Unknown error"}`);
1519
- continue;
1538
+ console.warn(`Skipping skill at ${filePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
1539
+ return null;
1520
1540
  }
1521
- }
1541
+ }));
1542
+ for (const skill of loadResults) if (skill) skills.push(skill);
1522
1543
  return skills;
1523
1544
  }
1524
1545
  /**
@@ -1660,44 +1681,42 @@ var DescribeToolsTool = class DescribeToolsTool {
1660
1681
  async detectSkillsFromPromptFrontMatter() {
1661
1682
  if (this.autoDetectedSkillsCache !== null) return this.autoDetectedSkillsCache;
1662
1683
  const clients = this.clientManager.getAllClients();
1663
- const autoDetectedSkills = [];
1664
1684
  let listPromptsFailures = 0;
1665
1685
  let fetchPromptFailures = 0;
1666
- const fetchPromises = [];
1667
- for (const client of clients) {
1686
+ const autoDetectedSkills = (await Promise.all(clients.map(async (client) => {
1687
+ const detectedSkills = [];
1668
1688
  const configuredPromptNames = new Set(client.prompts ? Object.keys(client.prompts) : []);
1669
- const listPromptsPromise = (async () => {
1670
- try {
1671
- const prompts = await client.listPrompts();
1672
- if (!prompts || prompts.length === 0) return;
1673
- const promptFetchPromises = prompts.map(async (promptInfo) => {
1674
- if (configuredPromptNames.has(promptInfo.name)) return;
1675
- try {
1676
- const skillExtraction = extractSkillFrontMatter(((await client.getPrompt(promptInfo.name)).messages || []).map((m) => {
1677
- const content = m.content;
1678
- if (typeof content === "string") return content;
1679
- if (content && typeof content === "object" && "text" in content) return String(content.text);
1680
- return "";
1681
- }).join("\n"));
1682
- if (skillExtraction) autoDetectedSkills.push({
1683
- serverName: client.serverName,
1684
- promptName: promptInfo.name,
1685
- skill: skillExtraction.skill
1686
- });
1687
- } catch (error) {
1688
- fetchPromptFailures++;
1689
- console.error(`${LOG_PREFIX_SKILL_DETECTION} Failed to fetch prompt '${promptInfo.name}' from ${client.serverName}: ${error instanceof Error ? error.message : "Unknown error"}`);
1690
- }
1691
- });
1692
- await Promise.all(promptFetchPromises);
1693
- } catch (error) {
1694
- listPromptsFailures++;
1695
- console.error(`${LOG_PREFIX_SKILL_DETECTION} Failed to list prompts from ${client.serverName}: ${error instanceof Error ? error.message : "Unknown error"}`);
1696
- }
1697
- })();
1698
- fetchPromises.push(listPromptsPromise);
1699
- }
1700
- await Promise.all(fetchPromises);
1689
+ try {
1690
+ const prompts = await client.listPrompts();
1691
+ if (!prompts || prompts.length === 0) return detectedSkills;
1692
+ const promptResults = await Promise.all(prompts.map(async (promptInfo) => {
1693
+ if (configuredPromptNames.has(promptInfo.name)) return null;
1694
+ try {
1695
+ const skillExtraction = extractSkillFrontMatter(((await client.getPrompt(promptInfo.name)).messages || []).map((m) => {
1696
+ const content = m.content;
1697
+ if (typeof content === "string") return content;
1698
+ if (content && typeof content === "object" && "text" in content) return String(content.text);
1699
+ return "";
1700
+ }).join("\n"));
1701
+ if (skillExtraction) return {
1702
+ serverName: client.serverName,
1703
+ promptName: promptInfo.name,
1704
+ skill: skillExtraction.skill
1705
+ };
1706
+ return null;
1707
+ } catch (error) {
1708
+ fetchPromptFailures++;
1709
+ console.error(`${LOG_PREFIX_SKILL_DETECTION} Failed to fetch prompt '${promptInfo.name}' from ${client.serverName}: ${error instanceof Error ? error.message : "Unknown error"}`);
1710
+ return null;
1711
+ }
1712
+ }));
1713
+ for (const result of promptResults) if (result) detectedSkills.push(result);
1714
+ } catch (error) {
1715
+ listPromptsFailures++;
1716
+ console.error(`${LOG_PREFIX_SKILL_DETECTION} Failed to list prompts from ${client.serverName}: ${error instanceof Error ? error.message : "Unknown error"}`);
1717
+ }
1718
+ return detectedSkills;
1719
+ }))).flat();
1701
1720
  if (listPromptsFailures > 0 || fetchPromptFailures > 0) console.error(`${LOG_PREFIX_SKILL_DETECTION} Completed with ${listPromptsFailures} server failure(s) and ${fetchPromptFailures} prompt failure(s). Detected ${autoDetectedSkills.length} skill(s).`);
1702
1721
  this.autoDetectedSkillsCache = autoDetectedSkills;
1703
1722
  return autoDetectedSkills;
@@ -1948,40 +1967,42 @@ var DescribeToolsTool = class DescribeToolsTool {
1948
1967
  serverToolsMap.set(client.serverName, []);
1949
1968
  }
1950
1969
  }));
1951
- const foundTools = [];
1952
- const foundSkills = [];
1953
- const notFoundItems = [];
1954
- for (const requestedName of toolNames) {
1970
+ const lookupResults = await Promise.all(toolNames.map(async (requestedName) => {
1971
+ const result$1 = {
1972
+ tools: [],
1973
+ skills: [],
1974
+ notFound: null
1975
+ };
1955
1976
  if (requestedName.startsWith(SKILL_PREFIX)) {
1956
1977
  const skillName = requestedName.slice(SKILL_PREFIX.length);
1957
1978
  if (this.skillService) {
1958
1979
  const skill = await this.skillService.getSkill(skillName);
1959
1980
  if (skill) {
1960
- foundSkills.push({
1981
+ result$1.skills.push({
1961
1982
  name: skill.name,
1962
1983
  location: skill.basePath,
1963
1984
  instructions: formatSkillInstructions(skill.name, skill.content)
1964
1985
  });
1965
- continue;
1986
+ return result$1;
1966
1987
  }
1967
1988
  }
1968
1989
  const promptSkillContent = await this.getPromptSkillContent(skillName);
1969
1990
  if (promptSkillContent) {
1970
- foundSkills.push(promptSkillContent);
1971
- continue;
1991
+ result$1.skills.push(promptSkillContent);
1992
+ return result$1;
1972
1993
  }
1973
- notFoundItems.push(requestedName);
1974
- continue;
1994
+ result$1.notFound = requestedName;
1995
+ return result$1;
1975
1996
  }
1976
1997
  const { serverName, actualToolName } = parseToolName(requestedName);
1977
1998
  if (serverName) {
1978
1999
  const serverTools = serverToolsMap.get(serverName);
1979
2000
  if (!serverTools) {
1980
- notFoundItems.push(requestedName);
1981
- continue;
2001
+ result$1.notFound = requestedName;
2002
+ return result$1;
1982
2003
  }
1983
2004
  const tool = serverTools.find((t) => t.name === actualToolName);
1984
- if (tool) foundTools.push({
2005
+ if (tool) result$1.tools.push({
1985
2006
  server: serverName,
1986
2007
  tool: {
1987
2008
  name: tool.name,
@@ -1989,52 +2010,61 @@ var DescribeToolsTool = class DescribeToolsTool {
1989
2010
  inputSchema: tool.inputSchema
1990
2011
  }
1991
2012
  });
1992
- else notFoundItems.push(requestedName);
1993
- } else {
1994
- const servers = toolToServers.get(actualToolName);
1995
- if (!servers || servers.length === 0) {
1996
- if (this.skillService) {
1997
- const skill = await this.skillService.getSkill(actualToolName);
1998
- if (skill) {
1999
- foundSkills.push({
2000
- name: skill.name,
2001
- location: skill.basePath,
2002
- instructions: formatSkillInstructions(skill.name, skill.content)
2003
- });
2004
- continue;
2005
- }
2006
- }
2007
- const promptSkillContent = await this.getPromptSkillContent(actualToolName);
2008
- if (promptSkillContent) {
2009
- foundSkills.push(promptSkillContent);
2010
- continue;
2013
+ else result$1.notFound = requestedName;
2014
+ return result$1;
2015
+ }
2016
+ const servers = toolToServers.get(actualToolName);
2017
+ if (!servers || servers.length === 0) {
2018
+ if (this.skillService) {
2019
+ const skill = await this.skillService.getSkill(actualToolName);
2020
+ if (skill) {
2021
+ result$1.skills.push({
2022
+ name: skill.name,
2023
+ location: skill.basePath,
2024
+ instructions: formatSkillInstructions(skill.name, skill.content)
2025
+ });
2026
+ return result$1;
2011
2027
  }
2012
- notFoundItems.push(requestedName);
2013
- continue;
2014
2028
  }
2015
- if (servers.length === 1) {
2016
- const server = servers[0];
2017
- const tool = serverToolsMap.get(server).find((t) => t.name === actualToolName);
2018
- foundTools.push({
2019
- server,
2020
- tool: {
2021
- name: tool.name,
2022
- description: tool.description,
2023
- inputSchema: tool.inputSchema
2024
- }
2025
- });
2026
- } else for (const server of servers) {
2027
- const tool = serverToolsMap.get(server).find((t) => t.name === actualToolName);
2028
- foundTools.push({
2029
- server,
2030
- tool: {
2031
- name: tool.name,
2032
- description: tool.description,
2033
- inputSchema: tool.inputSchema
2034
- }
2035
- });
2029
+ const promptSkillContent = await this.getPromptSkillContent(actualToolName);
2030
+ if (promptSkillContent) {
2031
+ result$1.skills.push(promptSkillContent);
2032
+ return result$1;
2036
2033
  }
2034
+ result$1.notFound = requestedName;
2035
+ return result$1;
2037
2036
  }
2037
+ if (servers.length === 1) {
2038
+ const server = servers[0];
2039
+ const tool = serverToolsMap.get(server).find((t) => t.name === actualToolName);
2040
+ result$1.tools.push({
2041
+ server,
2042
+ tool: {
2043
+ name: tool.name,
2044
+ description: tool.description,
2045
+ inputSchema: tool.inputSchema
2046
+ }
2047
+ });
2048
+ } else for (const server of servers) {
2049
+ const tool = serverToolsMap.get(server).find((t) => t.name === actualToolName);
2050
+ result$1.tools.push({
2051
+ server,
2052
+ tool: {
2053
+ name: tool.name,
2054
+ description: tool.description,
2055
+ inputSchema: tool.inputSchema
2056
+ }
2057
+ });
2058
+ }
2059
+ return result$1;
2060
+ }));
2061
+ const foundTools = [];
2062
+ const foundSkills = [];
2063
+ const notFoundItems = [];
2064
+ for (const result$1 of lookupResults) {
2065
+ foundTools.push(...result$1.tools);
2066
+ foundSkills.push(...result$1.skills);
2067
+ if (result$1.notFound) notFoundItems.push(result$1.notFound);
2038
2068
  }
2039
2069
  if (foundTools.length === 0 && foundSkills.length === 0) return {
2040
2070
  content: [{
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- const require_http = require('./http-C4IfZSwW.cjs');
1
+ const require_http = require('./http-BzrxGEr-.cjs');
2
2
 
3
3
  exports.HttpTransportHandler = require_http.HttpTransportHandler;
4
4
  exports.SseTransportHandler = require_http.SseTransportHandler;
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { i as createServer, n as SseTransportHandler, r as StdioTransportHandler, t as HttpTransportHandler } from "./http-xi_ha63Y.mjs";
1
+ import { i as createServer, n as SseTransportHandler, r as StdioTransportHandler, t as HttpTransportHandler } from "./http-DeUYygKb.mjs";
2
2
 
3
3
  export { HttpTransportHandler, SseTransportHandler, StdioTransportHandler, createServer };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@agiflowai/one-mcp",
3
3
  "description": "One MCP server package",
4
- "version": "0.3.1",
4
+ "version": "0.3.3",
5
5
  "license": "AGPL-3.0",
6
6
  "keywords": [
7
7
  "mcp",
@@ -27,7 +27,7 @@
27
27
  "js-yaml": "^4.1.0",
28
28
  "liquidjs": "^10.21.0",
29
29
  "zod": "^3.24.1",
30
- "@agiflowai/aicode-utils": "1.0.9"
30
+ "@agiflowai/aicode-utils": "1.0.10"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/express": "^5.0.0",