@mastra/mcp 1.15.1-alpha.0 → 1.15.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @mastra/mcp
2
2
 
3
+ ## 1.15.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Fixed concurrent MCP tool calls failing while the client reconnects after a dropped connection. ([#20530](https://github.com/mastra-ai/mastra/pull/20530))
8
+
9
+ - Speed up MCP discovery when an `MCPClient` is configured with multiple servers. `listTools()`, `listToolsets()`, `resources.list()`, `resources.templates()`, and `prompts.list()` now query all configured servers concurrently instead of one at a time, so total discovery time is roughly the slowest single server rather than the sum of all of them, and one slow or unresponsive server no longer stalls discovery for the rest. Tool, resource, and prompt ordering and per-server error reporting are unchanged. ([#19919](https://github.com/mastra-ai/mastra/pull/19919))
10
+
11
+ - Updated dependencies [[`4844167`](https://github.com/mastra-ai/mastra/commit/4844167cff2d5ec5004e94edd34970833040fa3f), [`c5e56ff`](https://github.com/mastra-ai/mastra/commit/c5e56ff3bcabdf062708f2d48744fec304df6792), [`594f7b2`](https://github.com/mastra-ai/mastra/commit/594f7b28f5263fb9982fd50d95c471fb971ea984), [`7f4e26d`](https://github.com/mastra-ai/mastra/commit/7f4e26dd57bd9b23c278ea21235ab823a3810a6c), [`311f943`](https://github.com/mastra-ai/mastra/commit/311f943bee60e8fdf5c84499ea50e884276c936c), [`322daa6`](https://github.com/mastra-ai/mastra/commit/322daa6d90552909204044790d850958f6745fed), [`db4e6ff`](https://github.com/mastra-ai/mastra/commit/db4e6ff744503112eb64deeaf6c2b54bf26a54c7), [`5faf93f`](https://github.com/mastra-ai/mastra/commit/5faf93f03e19daea394b9e2a923f2e4f833407f2), [`82201f7`](https://github.com/mastra-ai/mastra/commit/82201f75fae8e050a8de2df08b74875ee74c6b83), [`cadaa13`](https://github.com/mastra-ai/mastra/commit/cadaa1372e1077c8e85eb64c5499ba8803caa323), [`0c89896`](https://github.com/mastra-ai/mastra/commit/0c8989673fb7d106837098398131e570c6023b68), [`6d19a65`](https://github.com/mastra-ai/mastra/commit/6d19a6517f5da3911023d446b7e2d5dad8adb1cb), [`23b4238`](https://github.com/mastra-ai/mastra/commit/23b423844ad0bcf2a502a68dd62866d6160f9f6d), [`80ad891`](https://github.com/mastra-ai/mastra/commit/80ad891f8cd10379aa5b5af7510c763783b2ab56), [`fb18da5`](https://github.com/mastra-ai/mastra/commit/fb18da56fc35689ae370621a8f10b5b0d8606e20), [`fb18da5`](https://github.com/mastra-ai/mastra/commit/fb18da56fc35689ae370621a8f10b5b0d8606e20), [`e320a76`](https://github.com/mastra-ai/mastra/commit/e320a763feaf65c6be3cebecf746defcbde161b3), [`03b4918`](https://github.com/mastra-ai/mastra/commit/03b4918c80d188ce375334c393e131c6e94bd7eb), [`14ef73a`](https://github.com/mastra-ai/mastra/commit/14ef73a4bbd73e7808414816eb0628ce1d80b5d7), [`b582f7f`](https://github.com/mastra-ai/mastra/commit/b582f7fa2f9c1f87d19efc63d344fbe5dda2608c), [`0a6598b`](https://github.com/mastra-ai/mastra/commit/0a6598bde80bde008986ad6616bed9632b9294cb), [`06000d7`](https://github.com/mastra-ai/mastra/commit/06000d73712911572e913b8a83339270296d0a22), [`1d677d5`](https://github.com/mastra-ai/mastra/commit/1d677d5f99d7db403f7828585e8c25f299f72628), [`9e1dad8`](https://github.com/mastra-ai/mastra/commit/9e1dad8f7b1cab2bb7ade90e5b7561f24577b88a), [`2f43145`](https://github.com/mastra-ai/mastra/commit/2f4314504c03cbba280414ac81ba3197448ee6b0), [`4e35a56`](https://github.com/mastra-ai/mastra/commit/4e35a56cdf8d74a5ff6d5eda01f2c1deaf6cc7be), [`d94b8e1`](https://github.com/mastra-ai/mastra/commit/d94b8e1cee67416d518a8c30099040061bef6a1c), [`93e28ec`](https://github.com/mastra-ai/mastra/commit/93e28ecce9031c02397e0ae8406593e5c7a95883), [`729dab4`](https://github.com/mastra-ai/mastra/commit/729dab408faccfaef0cbb048e5a4338f9172847e), [`484003d`](https://github.com/mastra-ai/mastra/commit/484003d33ff59330c86b19863e4a38732d7e4155), [`3de0188`](https://github.com/mastra-ai/mastra/commit/3de0188bfaf9a9c09c95fe322b53838cf52c70b6), [`34d34d8`](https://github.com/mastra-ai/mastra/commit/34d34d8c811df512fef4dd5459f79b7821be1866), [`b582f7f`](https://github.com/mastra-ai/mastra/commit/b582f7fa2f9c1f87d19efc63d344fbe5dda2608c), [`933d291`](https://github.com/mastra-ai/mastra/commit/933d291146b789c19442ad206f94da3e4be90c64), [`a1cb98d`](https://github.com/mastra-ai/mastra/commit/a1cb98d11990b560b98482292a1f34aa1a2d9092), [`598ad82`](https://github.com/mastra-ai/mastra/commit/598ad82d41c41389a686338a1d0e50b7400e1938), [`1fd6aad`](https://github.com/mastra-ai/mastra/commit/1fd6aad1ea4a9d32f65efa832307c35e981a4c0a)]:
12
+ - @mastra/core@1.56.0
13
+
14
+ ## 1.15.1-alpha.1
15
+
16
+ ### Patch Changes
17
+
18
+ - Fixed concurrent MCP tool calls failing while the client reconnects after a dropped connection. ([#20530](https://github.com/mastra-ai/mastra/pull/20530))
19
+
20
+ - Updated dependencies [[`82201f7`](https://github.com/mastra-ai/mastra/commit/82201f75fae8e050a8de2df08b74875ee74c6b83), [`fb18da5`](https://github.com/mastra-ai/mastra/commit/fb18da56fc35689ae370621a8f10b5b0d8606e20), [`fb18da5`](https://github.com/mastra-ai/mastra/commit/fb18da56fc35689ae370621a8f10b5b0d8606e20), [`0a6598b`](https://github.com/mastra-ai/mastra/commit/0a6598bde80bde008986ad6616bed9632b9294cb), [`9e1dad8`](https://github.com/mastra-ai/mastra/commit/9e1dad8f7b1cab2bb7ade90e5b7561f24577b88a), [`2f43145`](https://github.com/mastra-ai/mastra/commit/2f4314504c03cbba280414ac81ba3197448ee6b0), [`34d34d8`](https://github.com/mastra-ai/mastra/commit/34d34d8c811df512fef4dd5459f79b7821be1866)]:
21
+ - @mastra/core@1.56.0-alpha.6
22
+
3
23
  ## 1.15.1-alpha.0
4
24
 
5
25
  ### Patch Changes
@@ -159,6 +159,8 @@ export declare class InternalMastraMCPClient extends MastraBase {
159
159
  */
160
160
  finishAuth(authorizationCode: string): Promise<void>;
161
161
  private isConnected;
162
+ private reconnectPromise;
163
+ private lifecycleGeneration;
162
164
  /**
163
165
  * Connects to the MCP server using the configured transport.
164
166
  *
@@ -206,6 +208,7 @@ export declare class InternalMastraMCPClient extends MastraBase {
206
208
  * @internal
207
209
  */
208
210
  forceReconnect(): Promise<void>;
211
+ private reconnectAfterTransportFailure;
209
212
  listResources(): Promise<ListResourcesResult>;
210
213
  readResource(uri: string): Promise<ReadResourceResult>;
211
214
  subscribeResource(uri: string): Promise<EmptyResult>;
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI/C,OAAO,KAAK,EAAmB,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAShE,OAAO,KAAK,EACV,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,2BAA2B,EAE3B,kBAAkB,EAEnB,MAAM,oCAAoC,CAAC;AAsB5C,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,KAAK,EAGV,kBAAkB,EAClB,eAAe,EAEf,8BAA8B,EAC9B,IAAI,EAEL,MAAM,SAAS,CAAC;AAGjB,YAAY,EACV,YAAY,EACZ,UAAU,EACV,UAAU,EACV,kBAAkB,EAClB,eAAe,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AC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,eAAe,CAAC;IASvG;;;OAGG;IACH,uCAAuC,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,IAAI;IAOlE;;;OAGG;IACH,qCAAqC,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,IAAI;IAOhE,qCAAqC,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI;IAO3E,yCAAyC,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,IAAI;IAOpE,4BAA4B,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI;IAoB/D,8BAA8B,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;YAOhD,kBAAkB;IAMhC;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAcrB,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IAiMhE,OAAO,CAAC,mBAAmB;CAQ5B"}
@@ -3,7 +3,7 @@ name: mastra-mcp
3
3
  description: Documentation for @mastra/mcp. Use when working with @mastra/mcp APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/mcp"
6
- version: "1.15.1-alpha.0"
6
+ version: "1.15.1"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -22,6 +22,7 @@ Read the individual reference documents for detailed explanations and code examp
22
22
 
23
23
  ### Reference
24
24
 
25
+ - [Reference: Tool configuration](references/reference-editor-tools.md) - Reference for Editor tool sources, providers, descriptions, conditions, MCP clients, and resolution order.
25
26
  - [Reference: MCPClient](references/reference-tools-mcp-client.md) - API Reference for MCPClient - A class for managing multiple Model Context Protocol servers and their tools.
26
27
  - [Reference: MCPServer](references/reference-tools-mcp-server.md) - API Reference for MCPServer - A class for exposing Mastra tools and capabilities as a Model Context Protocol server.
27
28
 
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.15.1-alpha.0",
2
+ "version": "1.15.1",
3
3
  "package": "@mastra/mcp",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -0,0 +1,100 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
3
+ # Tool configuration
4
+
5
+ Editor stores tool selections as part of an agent version. A stored configuration can add registered tools, tools from integration providers, and tools from Model Context Protocol (MCP) clients.
6
+
7
+ See [Editor tools](https://mastra.ai/docs/editor/overview) for the Studio workflow and common uses.
8
+
9
+ ## Tool sources
10
+
11
+ | Source | Description |
12
+ | ------------------------------------------------------------------ | ------------------------------------------------------------------------------------ |
13
+ | Registered tools | Tools registered in the Mastra runtime tool registry |
14
+ | MCP clients | Tools exposed by stored local or remote MCP server configurations |
15
+ | Integration tools | Tools resolved by legacy integration-provider configuration |
16
+ | [Tool providers](https://mastra.ai/reference/editor/tool-provider) | Tools resolved by providers registered on `MastraEditor`, such as Composio or Arcade |
17
+
18
+ Code-defined agents keep their existing tools. The [`editor` override setting](https://mastra.ai/reference/agents/agent) controls whether Editor can add and remove tools or only change descriptions.
19
+
20
+ ## Description overrides
21
+
22
+ Each selected tool can store an agent-specific description. The description changes what the model sees without modifying the original tool definition.
23
+
24
+ In description-only mode, Editor applies overrides only to tools that already exist on the code-defined agent. For MCP tools, an agent-level description takes priority over the description stored on the MCP client.
25
+
26
+ If two sources resolve the same tool ID, the later source replaces the complete earlier tool, including its description. See [Resolution order](#resolution-order).
27
+
28
+ ## Conditional tool sets
29
+
30
+ Editor can store conditional variants for the `tools`, `mcpClients`, `integrationTools`, and `toolProviders` fields. At runtime, matching variants are shallow-merged based on request-context values.
31
+
32
+ The rule language uses the same operators and nesting behavior as [prompt block display conditions](https://mastra.ai/reference/editor/prompt-blocks).
33
+
34
+ Conditions apply to a tool field variant or MCP client reference. Per-tool `rules` values in stored tool entries aren't evaluated by the current Editor resolver.
35
+
36
+ ## Stored MCP clients
37
+
38
+ The `editor.mcp` namespace manages reusable MCP client configurations. See the [`mcp` namespace](https://mastra.ai/reference/editor/mastra-editor) for CRUD method signatures.
39
+
40
+ `@mastra/mcp` is an optional peer dependency of `@mastra/editor`. Install it before configuring stored MCP clients so Editor can load their tools at runtime:
41
+
42
+ **npm**:
43
+
44
+ ```bash
45
+ npm install @mastra/mcp
46
+ ```
47
+
48
+ **pnpm**:
49
+
50
+ ```bash
51
+ pnpm add @mastra/mcp
52
+ ```
53
+
54
+ **Yarn**:
55
+
56
+ ```bash
57
+ yarn add @mastra/mcp
58
+ ```
59
+
60
+ **Bun**:
61
+
62
+ ```bash
63
+ bun add @mastra/mcp
64
+ ```
65
+
66
+ ### Transports
67
+
68
+ | Transport | Stored configuration |
69
+ | --------- | ---------------------------------------------------- |
70
+ | `stdio` | `command` with optional `args`, `env`, and `timeout` |
71
+ | HTTP | `url` with optional `timeout` |
72
+
73
+ Stored HTTP definitions don't accept arbitrary headers. When the reserved `mastra__authToken` value is present in request context, Editor forwards it as an `Authorization: Bearer` header.
74
+
75
+ ### Filtering
76
+
77
+ MCP tools can be allowlisted at two levels:
78
+
79
+ 1. **Server level**: The stored server's `tools` map limits tools for every agent that uses the client.
80
+ 2. **Agent level**: The agent's MCP client reference limits the remaining tools for that agent.
81
+
82
+ Agent-level tool names can use namespaced or bare names. An explicit empty `tools` map selects all tools. With the current resolver, omitting `tools` from an agent-level MCP reference selects none.
83
+
84
+ ### Namespacing
85
+
86
+ MCP tools use `serverName_toolName` IDs to avoid conflicts. A `search` tool from the `docs` server becomes `docs_search`.
87
+
88
+ ## Resolution order
89
+
90
+ Editor merges tool records in the following order. Later records replace earlier records with the same ID.
91
+
92
+ 1. Code-defined tools
93
+ 2. Registered stored tools
94
+ 3. MCP tools
95
+ 4. Legacy integration tools
96
+ 5. V1 tool-provider tools
97
+
98
+ Standalone stored agents use the same order without code-defined tools. Static code-agent overrides stop after legacy integration tools.
99
+
100
+ Use unique tool IDs across sources when possible. A collision replaces the complete earlier tool rather than merging its fields.
package/dist/index.cjs CHANGED
@@ -9911,7 +9911,7 @@ function toStandardSchema$4(schema) {
9911
9911
  return new AiSdkSchemaWrapper(schema);
9912
9912
  }
9913
9913
  //#endregion
9914
- //#region ../schema-compat/dist/json-schema-DwHzF7au.js
9914
+ //#region ../schema-compat/dist/json-schema-BstKYbJi.js
9915
9915
  var require_code$1 = /* @__PURE__ */ __commonJSMin$1(((exports) => {
9916
9916
  Object.defineProperty(exports, "__esModule", { value: true });
9917
9917
  exports.regexpCode = exports.getEsmExportName = exports.getProperty = exports.safeStringify = exports.stringify = exports.strConcat = exports.addCodeArg = exports.str = exports._ = exports.nil = exports._Code = exports.Name = exports.IDENTIFIER = exports._CodeOrName = void 0;
@@ -13084,7 +13084,10 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
13084
13084
  */
13085
13085
  function resolve(baseURI, relativeURI, options) {
13086
13086
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
13087
- const resolved = resolveComponent(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true);
13087
+ const { parsed: baseParsed, malformedAuthorityOrPort: baseMalformed } = parseWithStatus(baseURI, schemelessOptions);
13088
+ const { parsed: relativeParsed, malformedAuthorityOrPort: relativeMalformed } = parseWithStatus(relativeURI, schemelessOptions);
13089
+ if (baseMalformed || relativeMalformed) throw new Error(baseParsed.error || relativeParsed.error || "URI is malformed.");
13090
+ const resolved = resolveComponent(baseParsed, relativeParsed, schemelessOptions, true);
13088
13091
  schemelessOptions.skipEscape = true;
13089
13092
  return serialize(resolved, schemelessOptions);
13090
13093
  }
@@ -13201,6 +13204,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
13201
13204
  }
13202
13205
  const URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
13203
13206
  const AUTHORITY_PREFIX = /^(?:[^#/:?]+:)?\/\/([^/?#]*)/;
13207
+ const AUTHORITY_INTRODUCER_REGION = /^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;
13204
13208
  /**
13205
13209
  * @param {import('./types/index').URIComponent} parsed
13206
13210
  * @param {RegExpMatchArray} matches
@@ -13236,6 +13240,20 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
13236
13240
  parsed.error = "URI authority must not contain a literal backslash.";
13237
13241
  malformedAuthorityOrPort = true;
13238
13242
  }
13243
+ const introducerMatch = uri.match(AUTHORITY_INTRODUCER_REGION);
13244
+ if (introducerMatch !== null) {
13245
+ const region = introducerMatch[1];
13246
+ const normalizedRegion = region.replace(/[\t\n\r]/g, "");
13247
+ if (normalizedRegion.length >= 2) {
13248
+ if (normalizedRegion.slice(0, 2) !== "//") {
13249
+ parsed.error = parsed.error || "URI authority must not contain a literal backslash.";
13250
+ malformedAuthorityOrPort = true;
13251
+ } else if (region.length !== normalizedRegion.length) {
13252
+ parsed.error = parsed.error || "URI authority introducer must not contain whitespace.";
13253
+ malformedAuthorityOrPort = true;
13254
+ }
13255
+ }
13256
+ }
13239
13257
  const matches = uri.match(URI_PARSE);
13240
13258
  if (matches) {
13241
13259
  parsed.scheme = matches[1];
@@ -16601,7 +16619,7 @@ function toStandardSchema$2(zodSchema) {
16601
16619
  return wrapper;
16602
16620
  }
16603
16621
  //#endregion
16604
- //#region ../schema-compat/dist/schema-Ba6HLBWs.js
16622
+ //#region ../schema-compat/dist/schema-Bv9OdW1f.js
16605
16623
  /**
16606
16624
  * Supported JSON Schema targets for z.toJSONSchema().
16607
16625
  * Works with both real Zod v4 and Zod 3.25's v4 compat layer.
@@ -21472,6 +21490,8 @@ var InternalMastraMCPClient = class extends _mastra_core_base.MastraBase {
21472
21490
  }
21473
21491
  }
21474
21492
  isConnected = null;
21493
+ reconnectPromise = null;
21494
+ lifecycleGeneration = 0;
21475
21495
  /**
21476
21496
  * Connects to the MCP server using the configured transport.
21477
21497
  *
@@ -21569,6 +21589,9 @@ var InternalMastraMCPClient = class extends _mastra_core_base.MastraBase {
21569
21589
  this.serverInstructions = this.client.getInstructions();
21570
21590
  }
21571
21591
  async disconnect() {
21592
+ this.lifecycleGeneration++;
21593
+ const reconnectPromise = this.reconnectPromise;
21594
+ if (reconnectPromise) await reconnectPromise.catch(() => {});
21572
21595
  this.closePendingAuthTransport();
21573
21596
  if (!this.transport) {
21574
21597
  await this.detachStaleClientTransport();
@@ -21614,21 +21637,52 @@ var InternalMastraMCPClient = class extends _mastra_core_base.MastraBase {
21614
21637
  * @internal
21615
21638
  */
21616
21639
  async forceReconnect() {
21617
- this.log("debug", "Forcing reconnection to MCP server...");
21618
- this.closePendingAuthTransport();
21619
- const disconnectedTransport = this.transport;
21640
+ if (this.reconnectPromise) {
21641
+ this.log("debug", "Reconnection already in progress; waiting for it to complete");
21642
+ return await this.reconnectPromise;
21643
+ }
21644
+ const reconnectPromise = (async () => {
21645
+ this.log("debug", "Forcing reconnection to MCP server...");
21646
+ this.closePendingAuthTransport();
21647
+ const disconnectedTransport = this.transport;
21648
+ try {
21649
+ if (disconnectedTransport) await disconnectedTransport.close();
21650
+ } catch (e) {
21651
+ this.log("debug", "Error during force disconnect (ignored)", { error: e instanceof Error ? e.message : String(e) });
21652
+ } finally {
21653
+ if (disconnectedTransport) this.severClientTransportLink(disconnectedTransport);
21654
+ }
21655
+ if (!disconnectedTransport || this.transport === disconnectedTransport) {
21656
+ this.transport = void 0;
21657
+ this.isConnected = null;
21658
+ this.serverInstructions = void 0;
21659
+ }
21660
+ await this.connect();
21661
+ this.log("debug", "Successfully reconnected to MCP server");
21662
+ })();
21663
+ this.reconnectPromise = reconnectPromise;
21620
21664
  try {
21621
- if (disconnectedTransport) await disconnectedTransport.close();
21622
- } catch (e) {
21623
- this.log("debug", "Error during force disconnect (ignored)", { error: e instanceof Error ? e.message : String(e) });
21665
+ await reconnectPromise;
21624
21666
  } finally {
21625
- if (disconnectedTransport) this.severClientTransportLink(disconnectedTransport);
21667
+ if (this.reconnectPromise === reconnectPromise) this.reconnectPromise = null;
21668
+ }
21669
+ }
21670
+ async reconnectAfterTransportFailure(failedTransport, lifecycleGeneration) {
21671
+ while (true) {
21672
+ if (this.lifecycleGeneration !== lifecycleGeneration) throw new Error("MCP client was disconnected while recovering the failed transport");
21673
+ const reconnectPromise = this.reconnectPromise;
21674
+ if (reconnectPromise) {
21675
+ await reconnectPromise;
21676
+ continue;
21677
+ }
21678
+ if (failedTransport && this.transport && this.transport !== failedTransport) {
21679
+ this.log("debug", "Connection was already replaced after the failed operation; skipping reconnect");
21680
+ return;
21681
+ }
21682
+ await this.forceReconnect();
21683
+ if (this.lifecycleGeneration !== lifecycleGeneration) throw new Error("MCP client was disconnected while recovering the failed transport");
21684
+ return;
21626
21685
  }
21627
- this.transport = void 0;
21628
- this.isConnected = null;
21629
- this.serverInstructions = void 0;
21630
- await this.connect();
21631
- this.log("debug", "Successfully reconnected to MCP server");
21632
21686
  }
21633
21687
  async listResources() {
21634
21688
  this.log("debug", `Requesting resources from MCP server`);
@@ -21830,13 +21884,15 @@ var InternalMastraMCPClient = class extends _mastra_core_base.MastraBase {
21830
21884
  if (res.structuredContent !== void 0) return res.structuredContent;
21831
21885
  return res;
21832
21886
  };
21887
+ const failedTransport = this.transport;
21888
+ const lifecycleGeneration = this.lifecycleGeneration;
21833
21889
  try {
21834
21890
  return await executeToolCall();
21835
21891
  } catch (e) {
21836
21892
  if (isReconnectableMCPError(e)) {
21837
21893
  this.log("debug", `Session error detected for tool ${tool.name}, attempting reconnection...`, { error: e instanceof Error ? e.message : String(e) });
21838
21894
  try {
21839
- await this.forceReconnect();
21895
+ await this.reconnectAfterTransportFailure(failedTransport, lifecycleGeneration);
21840
21896
  this.log("debug", `Retrying tool ${tool.name} after reconnection...`);
21841
21897
  return await executeToolCall();
21842
21898
  } catch (reconnectError) {
@@ -23748,7 +23804,7 @@ var streamSSE = (c, cb, onError) => {
23748
23804
  return c.newResponse(stream.responseReadable);
23749
23805
  };
23750
23806
  //#endregion
23751
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/hono-mcp-server-sse-transport/0.0.7/cca448b28e692a7c0ee32da4a941ecaa73adf28248dca4347dd108a429e51b1e/node_modules/hono-mcp-server-sse-transport/build/sse.js
23807
+ //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/hono-mcp-server-sse-transport/0.0.7/518df2f53e0bbb46e48def5118fc7f6b5bba3a268854c8a5c7e83260299d376e/node_modules/hono-mcp-server-sse-transport/build/sse.js
23752
23808
  const MAXIMUM_MESSAGE_SIZE = 4 * 1024 * 1024;
23753
23809
  var SSETransport = class {
23754
23810
  messageUrl;