@mastra/mcp 1.0.0-beta.5 → 1.0.0-beta.7

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
@@ -729,6 +729,7 @@ var InternalMastraMCPClient = class extends MastraBase {
729
729
  * Common session-related errors include:
730
730
  * - "No valid session ID provided" (HTTP 400)
731
731
  * - "Server not initialized" (HTTP 400)
732
+ * - "Not connected" (protocol state error)
732
733
  * - Connection refused errors
733
734
  *
734
735
  * @param error - The error to check
@@ -741,7 +742,7 @@ var InternalMastraMCPClient = class extends MastraBase {
741
742
  return false;
742
743
  }
743
744
  const errorMessage = error.message.toLowerCase();
744
- return errorMessage.includes("no valid session") || errorMessage.includes("session") || errorMessage.includes("server not initialized") || errorMessage.includes("http 400") || errorMessage.includes("http 401") || errorMessage.includes("http 403") || errorMessage.includes("econnrefused") || errorMessage.includes("fetch failed") || errorMessage.includes("connection refused");
745
+ return errorMessage.includes("no valid session") || errorMessage.includes("session") || errorMessage.includes("server not initialized") || errorMessage.includes("not connected") || errorMessage.includes("http 400") || errorMessage.includes("http 401") || errorMessage.includes("http 403") || errorMessage.includes("econnrefused") || errorMessage.includes("fetch failed") || errorMessage.includes("connection refused");
745
746
  }
746
747
  /**
747
748
  * Forces a reconnection to the MCP server by disconnecting and reconnecting.
@@ -2370,7 +2371,16 @@ var MCPServer = class extends MCPServerBase {
2370
2371
  if (opts.prompts) {
2371
2372
  capabilities.prompts = { listChanged: true };
2372
2373
  }
2373
- this.server = new Server({ name: this.name, version: this.version }, { capabilities });
2374
+ this.server = new Server(
2375
+ {
2376
+ name: this.name,
2377
+ version: this.version
2378
+ },
2379
+ {
2380
+ capabilities,
2381
+ ...this.instructions ? { instructions: this.instructions } : {}
2382
+ }
2383
+ );
2374
2384
  this.logger.info(
2375
2385
  `Initialized MCPServer '${this.name}' v${this.version} (ID: ${this.id}) with tools: ${Object.keys(this.convertedTools).join(", ")} and resources. Capabilities: ${JSON.stringify(capabilities)}`
2376
2386
  );
@@ -2467,7 +2477,16 @@ var MCPServer = class extends MCPServerBase {
2467
2477
  if (this.promptOptions) {
2468
2478
  capabilities.prompts = { listChanged: true };
2469
2479
  }
2470
- const serverInstance = new Server({ name: this.name, version: this.version }, { capabilities });
2480
+ const serverInstance = new Server(
2481
+ {
2482
+ name: this.name,
2483
+ version: this.version
2484
+ },
2485
+ {
2486
+ capabilities,
2487
+ ...this.instructions ? { instructions: this.instructions } : {}
2488
+ }
2489
+ );
2471
2490
  this.registerHandlersOnServer(serverInstance);
2472
2491
  return serverInstance;
2473
2492
  }