@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/CHANGELOG.md +40 -0
- package/dist/client/client.d.ts +1 -0
- package/dist/client/client.d.ts.map +1 -1
- package/dist/index.cjs +22 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +22 -3
- package/dist/index.js.map +1 -1
- package/dist/server/server.d.ts.map +1 -1
- package/package.json +3 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,45 @@
|
|
|
1
1
|
# @mastra/mcp
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Add support for `instructions` field in MCPServer ([#11421](https://github.com/mastra-ai/mastra/pull/11421))
|
|
8
|
+
|
|
9
|
+
Implements the official MCP specification's `instructions` field, which allows MCP servers to provide system-wide prompts that are automatically sent to clients during initialization. This eliminates the need for per-project configuration files (like AGENTS.md) by centralizing the system prompt in the server definition.
|
|
10
|
+
|
|
11
|
+
**What's New:**
|
|
12
|
+
- Added `instructions` optional field to `MCPServerConfig` type
|
|
13
|
+
- Instructions are passed to the underlying MCP SDK Server during initialization
|
|
14
|
+
- Instructions are sent to clients in the `InitializeResult` response
|
|
15
|
+
- Fully compatible with all MCP clients (Cursor, Windsurf, Claude Desktop, etc.)
|
|
16
|
+
|
|
17
|
+
**Example Usage:**
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
const server = new MCPServer({
|
|
21
|
+
name: 'GitHub MCP Server',
|
|
22
|
+
version: '1.0.0',
|
|
23
|
+
instructions:
|
|
24
|
+
'Use the available tools to help users manage GitHub repositories, issues, and pull requests. Always search before creating to avoid duplicates.',
|
|
25
|
+
tools: { searchIssues, createIssue, listPRs },
|
|
26
|
+
});
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
- Updated dependencies [[`3d93a15`](https://github.com/mastra-ai/mastra/commit/3d93a15796b158c617461c8b98bede476ebb43e2), [`efe406a`](https://github.com/mastra-ai/mastra/commit/efe406a1353c24993280ebc2ed61dd9f65b84b26), [`119e5c6`](https://github.com/mastra-ai/mastra/commit/119e5c65008f3e5cfca954eefc2eb85e3bf40da4), [`74e504a`](https://github.com/mastra-ai/mastra/commit/74e504a3b584eafd2f198001c6a113bbec589fd3), [`e33fdbd`](https://github.com/mastra-ai/mastra/commit/e33fdbd07b33920d81e823122331b0c0bee0bb59), [`929f69c`](https://github.com/mastra-ai/mastra/commit/929f69c3436fa20dd0f0e2f7ebe8270bd82a1529), [`8a73529`](https://github.com/mastra-ai/mastra/commit/8a73529ca01187f604b1f3019d0a725ac63ae55f)]:
|
|
30
|
+
- @mastra/core@1.0.0-beta.16
|
|
31
|
+
|
|
32
|
+
## 1.0.0-beta.6
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- Add "Not connected" error detection to MCP auto-reconnection ([#10994](https://github.com/mastra-ai/mastra/pull/10994))
|
|
37
|
+
|
|
38
|
+
Enhanced the MCPClient auto-reconnection feature to also detect and handle "Not connected" protocol errors. When the MCP SDK's transport layer throws this error (typically when the connection is in a disconnected state), the client will now automatically reconnect and retry the operation.
|
|
39
|
+
|
|
40
|
+
- Updated dependencies [[`72df8ae`](https://github.com/mastra-ai/mastra/commit/72df8ae595584cdd7747d5c39ffaca45e4507227), [`9198899`](https://github.com/mastra-ai/mastra/commit/91988995c427b185c33714b7f3be955367911324), [`653e65a`](https://github.com/mastra-ai/mastra/commit/653e65ae1f9502c2958a32f47a5a2df11e612a92), [`c6fd6fe`](https://github.com/mastra-ai/mastra/commit/c6fd6fedd09e9cf8004b03a80925f5e94826ad7e), [`0bed332`](https://github.com/mastra-ai/mastra/commit/0bed332843f627202c6520eaf671771313cd20f3)]:
|
|
41
|
+
- @mastra/core@1.0.0-beta.9
|
|
42
|
+
|
|
3
43
|
## 1.0.0-beta.5
|
|
4
44
|
|
|
5
45
|
### Minor Changes
|
package/dist/client/client.d.ts
CHANGED
|
@@ -120,6 +120,7 @@ export declare class InternalMastraMCPClient extends MastraBase {
|
|
|
120
120
|
* Common session-related errors include:
|
|
121
121
|
* - "No valid session ID provided" (HTTP 400)
|
|
122
122
|
* - "Server not initialized" (HTTP 400)
|
|
123
|
+
* - "Not connected" (protocol state error)
|
|
123
124
|
* - Connection refused errors
|
|
124
125
|
*
|
|
125
126
|
* @param error - The error to check
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAQ/C,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EAElB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAKL,iCAAiC,EAQlC,MAAM,oCAAoC,CAAC;AAG5C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,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;AAC3D,OAAO,KAAK,EAEV,kBAAkB,EAClB,eAAe,EAEf,8BAA8B,EAC9B,IAAI,EACL,MAAM,SAAS,CAAC;AAGjB,YAAY,EACV,YAAY,EACZ,UAAU,EACV,UAAU,EACV,kBAAkB,EAClB,eAAe,EACf,yBAAyB,EACzB,8BAA8B,EAC9B,IAAI,GACL,MAAM,SAAS,CAAC;AA8BjB;;;;;;;GAOG;AACH,qBAAa,uBAAwB,SAAQ,UAAU;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC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B,CAAC,GAAG,EAAE,MAAM;IAO/B,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAO3B;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAO/C;;;;;OAKG;IACG,SAAS,CAAC,EACd,IAAI,EACJ,IAAI,EACJ,OAAO,GACR,EAAE;QACD,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,eAAe,CAAC;IAS5B;;;OAGG;IACH,uCAAuC,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,IAAI;IAOlE,qCAAqC,CACnC,OAAO,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAC,QAAQ,CAAC,KAAK,IAAI,GACrF,IAAI;IAOP,yCAAyC,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,IAAI;IAOpE,4BAA4B,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI;IAQ/D,8BAA8B,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;YAOhD,kBAAkB;YA0ClB,mBAAmB;IA2C3B,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;CA+FjE"}
|
package/dist/index.cjs
CHANGED
|
@@ -736,6 +736,7 @@ var InternalMastraMCPClient = class extends base.MastraBase {
|
|
|
736
736
|
* Common session-related errors include:
|
|
737
737
|
* - "No valid session ID provided" (HTTP 400)
|
|
738
738
|
* - "Server not initialized" (HTTP 400)
|
|
739
|
+
* - "Not connected" (protocol state error)
|
|
739
740
|
* - Connection refused errors
|
|
740
741
|
*
|
|
741
742
|
* @param error - The error to check
|
|
@@ -748,7 +749,7 @@ var InternalMastraMCPClient = class extends base.MastraBase {
|
|
|
748
749
|
return false;
|
|
749
750
|
}
|
|
750
751
|
const errorMessage = error.message.toLowerCase();
|
|
751
|
-
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");
|
|
752
|
+
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");
|
|
752
753
|
}
|
|
753
754
|
/**
|
|
754
755
|
* Forces a reconnection to the MCP server by disconnecting and reconnecting.
|
|
@@ -2377,7 +2378,16 @@ var MCPServer = class extends mcp.MCPServerBase {
|
|
|
2377
2378
|
if (opts.prompts) {
|
|
2378
2379
|
capabilities.prompts = { listChanged: true };
|
|
2379
2380
|
}
|
|
2380
|
-
this.server = new index_js$1.Server(
|
|
2381
|
+
this.server = new index_js$1.Server(
|
|
2382
|
+
{
|
|
2383
|
+
name: this.name,
|
|
2384
|
+
version: this.version
|
|
2385
|
+
},
|
|
2386
|
+
{
|
|
2387
|
+
capabilities,
|
|
2388
|
+
...this.instructions ? { instructions: this.instructions } : {}
|
|
2389
|
+
}
|
|
2390
|
+
);
|
|
2381
2391
|
this.logger.info(
|
|
2382
2392
|
`Initialized MCPServer '${this.name}' v${this.version} (ID: ${this.id}) with tools: ${Object.keys(this.convertedTools).join(", ")} and resources. Capabilities: ${JSON.stringify(capabilities)}`
|
|
2383
2393
|
);
|
|
@@ -2474,7 +2484,16 @@ var MCPServer = class extends mcp.MCPServerBase {
|
|
|
2474
2484
|
if (this.promptOptions) {
|
|
2475
2485
|
capabilities.prompts = { listChanged: true };
|
|
2476
2486
|
}
|
|
2477
|
-
const serverInstance = new index_js$1.Server(
|
|
2487
|
+
const serverInstance = new index_js$1.Server(
|
|
2488
|
+
{
|
|
2489
|
+
name: this.name,
|
|
2490
|
+
version: this.version
|
|
2491
|
+
},
|
|
2492
|
+
{
|
|
2493
|
+
capabilities,
|
|
2494
|
+
...this.instructions ? { instructions: this.instructions } : {}
|
|
2495
|
+
}
|
|
2496
|
+
);
|
|
2478
2497
|
this.registerHandlersOnServer(serverInstance);
|
|
2479
2498
|
return serverInstance;
|
|
2480
2499
|
}
|