@mastra/mcp 1.11.0 → 1.12.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/index.js CHANGED
@@ -1927,8 +1927,31 @@ To fix this you have three different options:
1927
1927
  * ```
1928
1928
  */
1929
1929
  async listTools() {
1930
+ const result = await this.listToolsWithErrors();
1931
+ return result.tools;
1932
+ }
1933
+ /**
1934
+ * Retrieves all tools from all configured servers with namespaced names,
1935
+ * along with any per-server errors.
1936
+ *
1937
+ * Like listTools(), but also returns errors for servers that failed to connect
1938
+ * or list tools. This allows callers to report specific failure reasons per server.
1939
+ *
1940
+ * @returns Object with `tools` (successful tools) and `errors` (failed servers with error messages).
1941
+ * Transient connection failures are retried once after reconnecting the affected server.
1942
+ *
1943
+ * @example
1944
+ * ```typescript
1945
+ * const { tools, errors } = await mcp.listToolsWithErrors();
1946
+ * for (const [name, err] of Object.entries(errors)) {
1947
+ * console.error(`Server ${name} failed: ${err}`);
1948
+ * }
1949
+ * ```
1950
+ */
1951
+ async listToolsWithErrors() {
1930
1952
  this.addToInstanceCache();
1931
1953
  const connectedTools = {};
1954
+ const errors = {};
1932
1955
  for (const serverName of Object.keys(this.serverConfigs)) {
1933
1956
  try {
1934
1957
  const tools = await this.getToolsForServer(serverName);
@@ -1949,9 +1972,10 @@ To fix this you have three different options:
1949
1972
  );
1950
1973
  this.logger.trackException(mastraError);
1951
1974
  this.logger.error("Failed to list tools from server:", { error: mastraError.toString() });
1975
+ errors[serverName] = error instanceof Error ? error.message : String(error);
1952
1976
  }
1953
1977
  }
1954
- return connectedTools;
1978
+ return { tools: connectedTools, errors };
1955
1979
  }
1956
1980
  /**
1957
1981
  * Returns toolsets organized by server name for dynamic tool injection.
@@ -2350,7 +2374,7 @@ function createSimpleTokenProvider(accessToken, options) {
2350
2374
  });
2351
2375
  }
2352
2376
 
2353
- // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/hono/4.12.21/c401a6c1b505d0adf80740e6e7d31122a2ebd9abaf1de7e5dee418ae2a608e7a/node_modules/hono/dist/utils/stream.js
2377
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/hono/4.12.25/56d2d0ad7d061ad7c69e37ba3e5d5b4b8565e67d753d2ff1fcac3c36501e42df/node_modules/hono/dist/utils/stream.js
2354
2378
  var StreamingApi = class {
2355
2379
  writer;
2356
2380
  encoder;
@@ -2429,7 +2453,7 @@ var StreamingApi = class {
2429
2453
  }
2430
2454
  };
2431
2455
 
2432
- // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/hono/4.12.21/c401a6c1b505d0adf80740e6e7d31122a2ebd9abaf1de7e5dee418ae2a608e7a/node_modules/hono/dist/helper/streaming/utils.js
2456
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/hono/4.12.25/56d2d0ad7d061ad7c69e37ba3e5d5b4b8565e67d753d2ff1fcac3c36501e42df/node_modules/hono/dist/helper/streaming/utils.js
2433
2457
  var isOldBunVersion = () => {
2434
2458
  const version = typeof Bun !== "undefined" ? Bun.version : void 0;
2435
2459
  if (version === void 0) {
@@ -2440,7 +2464,7 @@ var isOldBunVersion = () => {
2440
2464
  return result;
2441
2465
  };
2442
2466
 
2443
- // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/hono/4.12.21/c401a6c1b505d0adf80740e6e7d31122a2ebd9abaf1de7e5dee418ae2a608e7a/node_modules/hono/dist/utils/html.js
2467
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/hono/4.12.25/56d2d0ad7d061ad7c69e37ba3e5d5b4b8565e67d753d2ff1fcac3c36501e42df/node_modules/hono/dist/utils/html.js
2444
2468
  var HtmlEscapedCallbackPhase = {
2445
2469
  Stringify: 1};
2446
2470
  var resolveCallback = async (str, phase, preserveCallbacks, context, buffer) => {
@@ -2471,7 +2495,7 @@ var resolveCallback = async (str, phase, preserveCallbacks, context, buffer) =>
2471
2495
  }
2472
2496
  };
2473
2497
 
2474
- // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/hono/4.12.21/c401a6c1b505d0adf80740e6e7d31122a2ebd9abaf1de7e5dee418ae2a608e7a/node_modules/hono/dist/helper/streaming/sse.js
2498
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/hono/4.12.25/56d2d0ad7d061ad7c69e37ba3e5d5b4b8565e67d753d2ff1fcac3c36501e42df/node_modules/hono/dist/helper/streaming/sse.js
2475
2499
  var SSEStreamingApi = class extends StreamingApi {
2476
2500
  constructor(writable, readable) {
2477
2501
  super(writable, readable);