@mastra/mcp 2.9.0-alpha.0 → 2.9.0-alpha.2
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/client/client.d.ts +42 -0
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/error-utils.d.ts +9 -0
- package/dist/client/error-utils.d.ts.map +1 -1
- package/dist/client/oauth-callback-server.d.ts.map +1 -1
- package/dist/client/types.d.ts +5 -2
- package/dist/client/types.d.ts.map +1 -1
- package/dist/docs/SKILL.md +1 -4
- package/dist/docs/assets/SOURCE_MAP.json +32 -32
- package/dist/docs/references/docs-connections-mcp.md +27 -61
- package/dist/docs/references/reference-tools-mcp-client.md +15 -6
- package/dist/docs/references/reference-tools-mcp-server.md +6 -2
- package/dist/index.cjs +276 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +276 -6
- package/dist/index.js.map +1 -1
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/uri-template.d.ts +15 -0
- package/dist/server/uri-template.d.ts.map +1 -0
- package/package.json +5 -5
- package/dist/docs/references/docs-connections-overview.md +0 -96
- package/dist/docs/references/reference-migrations-mcp-v2.md +0 -268
- package/dist/docs/references/reference-migrations-upgrade-to-v1-mcp.md +0 -103
package/dist/client/client.d.ts
CHANGED
|
@@ -79,6 +79,19 @@ export declare class InternalMastraMCPClient extends MastraBase {
|
|
|
79
79
|
private clientConnectionOnClose?;
|
|
80
80
|
private _authState?;
|
|
81
81
|
private operationContextStore;
|
|
82
|
+
/**
|
|
83
|
+
* The requestContext of the tool call whose execution opened the connection. Only the
|
|
84
|
+
* transport's fetch reads it, so the handshake and the streams the connection keeps open are
|
|
85
|
+
* sent as that call. Messages arriving on those streams are delivered outside it, so server logs
|
|
86
|
+
* are not labelled with it and requests their handlers send are not sent as that call.
|
|
87
|
+
*/
|
|
88
|
+
private connectionContextStore;
|
|
89
|
+
/**
|
|
90
|
+
* The connection context of the transport a server message arrived on, as it was when that
|
|
91
|
+
* transport was created, set while the message is delivered. The transport's fetch reads it only for the client's replies to server requests,
|
|
92
|
+
* which belong to the connection rather than to the handler that produced them.
|
|
93
|
+
*/
|
|
94
|
+
private replyContextStore;
|
|
82
95
|
private exitHookUnsubscribe?;
|
|
83
96
|
private sigTermHandler?;
|
|
84
97
|
private sigHupHandler?;
|
|
@@ -122,6 +135,35 @@ export declare class InternalMastraMCPClient extends MastraBase {
|
|
|
122
135
|
private buildStdioEnv;
|
|
123
136
|
private connectStdio;
|
|
124
137
|
private connectHttp;
|
|
138
|
+
/**
|
|
139
|
+
* Connects as a tool call: the handshake and the streams the connection keeps open reach the
|
|
140
|
+
* transport's fetch with the call's requestContext, through the connection context. Any enclosing
|
|
141
|
+
* operation scope is exited first. It would take priority in fetch, and the new streams and stdio
|
|
142
|
+
* child would deliver every later server message in it.
|
|
143
|
+
*/
|
|
144
|
+
private connectAsCall;
|
|
145
|
+
/**
|
|
146
|
+
* The requestContext the transport's fetch passes on for an outgoing request. An operation scope
|
|
147
|
+
* owns its requests, even when its requestContext is null. Outside one, the handshake and the
|
|
148
|
+
* streams the connection keeps open use the connection context, and a reply to a server request
|
|
149
|
+
* uses the context of the connection that delivered the request.
|
|
150
|
+
*/
|
|
151
|
+
private fetchRequestContext;
|
|
152
|
+
/**
|
|
153
|
+
* Delivers every message the server sends outside the connection context, from the handshake on.
|
|
154
|
+
* A server log, notification or request arriving on a stream the opening call started belongs to
|
|
155
|
+
* no call, so a request its handler sends must not be sent as that call. The client's reply to a
|
|
156
|
+
* server request still is, through `replyContextStore`.
|
|
157
|
+
*
|
|
158
|
+
* The reply context is the connection context this transport was created in, captured once. Read
|
|
159
|
+
* at delivery time, it would carry over to a connection that a handler of an older connection's
|
|
160
|
+
* message opens, such as a `reconnectServer()` from a server log callback.
|
|
161
|
+
*
|
|
162
|
+
* The SDK assigns `onmessage` during `connect()` and swaps it while probing the server, so every
|
|
163
|
+
* assignment is wrapped. A handler that wraps an already wrapped one (`interceptTaskResults`, or
|
|
164
|
+
* the probe restoring its saved handler) runs with the same reply context.
|
|
165
|
+
*/
|
|
166
|
+
private deliverOutsideConnectionContext;
|
|
125
167
|
/**
|
|
126
168
|
* Detaches whatever transport is still attached to the underlying SDK Client.
|
|
127
169
|
*
|
|
@@ -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;AAE1C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAA8B,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAG7E,OAAO,KAAK,EAAmB,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAShE,OAAO,KAAK,EAGV,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,2BAA2B,EAG3B,kBAAkB,EAMnB,MAAM,8BAA8B,CAAC;AAatC,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,uBAAuB,EACvB,gBAAgB,EAChB,4BAA4B,EAC5B,qBAAqB,EACrB,8BAA8B,EAC/B,MAAM,kBAAkB,CAAC;AAO1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,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,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGpD,OAAO,KAAK,EAAc,kBAAkB,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAIrH,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAMlD,OAAO,KAAK,EAGV,eAAe,EAEf,8BAA8B,EAG9B,uBAAuB,EAGvB,6BAA6B,EAC9B,MAA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QACnC,MAAM,CAAC,EAAE,WAAW,CAAC;KACtB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAiBhC;YAEa,wBAAwB;IAMtC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAWzB;YAEY,sBAAsB;IAUpC,OAAO,CAAC,kBAAkB;IAO1B;;;;;;;OAOG;IACH,OAAO,CAAC,mBAAmB;IAc3B;;OAEG;IACG,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,6BAA6B,CAAC,CAAC,CAU9E;IAED,OAAO,CAAC,wBAAwB;IAoBhC;;;OAGG;IACH,kBAAkB,CAAC,EAAE,UAAU,EAAE,EAAE;QAAE,UAAU,EAAE,6BAA6B,CAAA;KAAE,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CA4B1G;IAEK,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAiB/D;IAED;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IAoW9B,iEAAiE;IACjE,IAAI,KAAK,IAAI,IAAI,CAAC,aAAa,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC,CAE5D;IAED;;;OAGG;IACH,OAAO,CAAC,wBAAwB;IAShC;;;;;OAKG;YACW,aAAa;IA6F3B,OAAO,CAAC,mBAAmB;CAQ5B"}
|
|
@@ -8,6 +8,15 @@
|
|
|
8
8
|
* protocol errors are never reconnectable.
|
|
9
9
|
*/
|
|
10
10
|
export declare function isReconnectableMCPError(error: unknown): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Whether a reconnectable failure proves the request never reached the server's
|
|
13
|
+
* handler, so sending it again cannot repeat its effects.
|
|
14
|
+
*
|
|
15
|
+
* A reset socket (`fetch failed` with `UND_ERR_SOCKET`), a cut-off response
|
|
16
|
+
* (`terminated`) or a closed transport (`Connection closed`) can all follow a
|
|
17
|
+
* request the server already received and ran, so they return false.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isUnsentRequestError(error: unknown): boolean;
|
|
11
20
|
/**
|
|
12
21
|
* Whether a failed `tasks/get` poll should be retried while waiting out an outage.
|
|
13
22
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-utils.d.ts","sourceRoot":"","sources":["../../src/client/error-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAmB/D;AAID;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAMlE;AAED,0EAA0E;AAC1E,MAAM,WAAW,wBAAwB;IACvC,8FAA8F;IAC9F,OAAO,EAAE,MAAM,CAAC;IAChB,0DAA0D;IAC1D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qGAAqG;IACrG,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB;AAoCD;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,wBAAwB,CAmDpF"}
|
|
1
|
+
{"version":3,"file":"error-utils.d.ts","sourceRoot":"","sources":["../../src/client/error-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAmB/D;AAKD;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAoB5D;AAID;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAMlE;AAED,0EAA0E;AAC1E,MAAM,WAAW,wBAAwB;IACvC,8FAA8F;IAC9F,OAAO,EAAE,MAAM,CAAC;IAChB,0DAA0D;IAC1D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qGAAqG;IACrG,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB;AAoCD;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,wBAAwB,CAmDpF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-callback-server.d.ts","sourceRoot":"","sources":["../../src/client/oauth-callback-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAkCH;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC;;;;;;;;;OASG;IACH,WAAW,EAAE,MAAM,GAAG,GAAG,CAAC;IAE1B;;;;;;OAMG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,GAAG,EAAE,GAAG,CAAC;IAET;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;;;;OAOG;IACH,WAAW,CAAC,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAE5E;;;OAGG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,MAAM,GAAG,GAAG,GAAG,GAAG,EAAE,CAezE;AAmCD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,yBAAyB,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,mBAAmB,CAAC,
|
|
1
|
+
{"version":3,"file":"oauth-callback-server.d.ts","sourceRoot":"","sources":["../../src/client/oauth-callback-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAkCH;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC;;;;;;;;;OASG;IACH,WAAW,EAAE,MAAM,GAAG,GAAG,CAAC;IAE1B;;;;;;OAMG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,GAAG,EAAE,GAAG,CAAC;IAET;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;;;;OAOG;IACH,WAAW,CAAC,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAE5E;;;OAGG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,MAAM,GAAG,GAAG,GAAG,GAAG,EAAE,CAezE;AAmCD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,yBAAyB,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAgJjH"}
|
package/dist/client/types.d.ts
CHANGED
|
@@ -64,8 +64,11 @@ export type MCPClientProtocolVersion = typeof MCP_CLIENT_PROTOCOL_VERSION | 'leg
|
|
|
64
64
|
* This allows custom fetch implementations to access request-scoped data (e.g., authentication
|
|
65
65
|
* cookies, bearer tokens) from the incoming request and forward them to the MCP server.
|
|
66
66
|
*
|
|
67
|
-
* The `requestContext` parameter is `null` when no context is available (e.g., during
|
|
68
|
-
*
|
|
67
|
+
* The `requestContext` parameter is `null` when no context is available (e.g., during a
|
|
68
|
+
* connection handshake that no tool call started, such as the one `listTools()` opens, or when a
|
|
69
|
+
* tool is called without a request context). When a tool call opens the connection (a tool rebuilt
|
|
70
|
+
* from a cached definition on its first execution, or a reconnect during a call), the handshake
|
|
71
|
+
* receives that call's `requestContext`, and streams the connection keeps open afterwards keep it.
|
|
69
72
|
*
|
|
70
73
|
* @example
|
|
71
74
|
* ```typescript
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,EACV,cAAc,EACd,oCAAoC,EACpC,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,sFAAsF;AACtF,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC,CAAC;AAE1G;;;GAGG;AACH,MAAM,MAAM,gBAAgB,CAAC,QAAQ,IAAI;KAAG,MAAM,IAAI,MAAM,QAAQ,GAAG,YAAY,CAAC,MAAM,CAAC;CAAE,CAAC;AAE9F,K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B,uCAAuC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,gFAAgF;IAChF,OAAO,CAAC,EAAE,kBAAkB,CAAC;CAC9B,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,6BAA6B,GAAG;IAC1C,kFAAkF;IAClF,IAAI,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sEAAsE;IACtE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+EAA+E;IAC/E,WAAW,EAAE,OAAO,CAAC;IACrB,oFAAoF;IACpF,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,iFAAiF;IACjF,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,wEAAwE;IACxE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC;;;;;;OAMG;IACH,MAAM,EAAE;QACN,gDAAgD;QAChD,IAAI,EAAE,MAAM,CAAC;QACb,wDAAwD;QACxD,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,iEAAiE;QACjE,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;CACH,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,0BAA0B,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,6BAA6B,CAAC,CAAC,CAAC"}
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -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: "2.9.0-alpha.
|
|
6
|
+
version: "2.9.0-alpha.2"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -18,14 +18,11 @@ Read the individual reference documents for detailed explanations and code examp
|
|
|
18
18
|
|
|
19
19
|
- [Fine-Grained Authorization (FGA)](references/docs-auth-fga.md) - Configure Mastra Fine-Grained Authorization for resource-level permissions that map routes to actions and scope stored resources for enterprise users.
|
|
20
20
|
- [MCP](references/docs-connections-mcp.md) - Connect Mastra agents to remote MCP servers, expose Mastra tools through MCPServer, manage approvals, subscribe to MCP events, and build interactive MCP Apps for Studio.
|
|
21
|
-
- [Connections](references/docs-connections-overview.md) - Connect Mastra to remote agents, coding agents, SDK runtimes, MCP servers, and external tools by choosing the protocol that fits your application.
|
|
22
21
|
- [MCP authentication and authorization](references/docs-guides-mcp-authentication-authorization.md) - Choose credentials for MCP connections, protect a Mastra MCP server, and separate delegated access from tool and data permissions.
|
|
23
22
|
|
|
24
23
|
### Reference
|
|
25
24
|
|
|
26
25
|
- [Reference: Tool configuration](references/reference-editor-tools.md) - Configure Editor agent tools from Mastra, MCP, workspace, and provider sources, including descriptions, display conditions, and resolution order.
|
|
27
|
-
- [Migration: @mastra/mcp v1 to v2](references/reference-migrations-mcp-v2.md) - Migrate @mastra/mcp to v2, which serves only the MCP 2026-07-28 revision and replaces elicitation with suspend/resume. Clients still connect to older servers.
|
|
28
|
-
- [MCP](references/reference-migrations-upgrade-to-v1-mcp.md) - MCP (Model Context Protocol) tool execution context has been reorganized, and deprecated client classes have been removed.
|
|
29
26
|
- [Reference: MCPClient](references/reference-tools-mcp-client.md) - The MCPClient class provides a way to manage multiple MCP server connections and their tools in a Mastra application.
|
|
30
27
|
- [Reference: MCPServer](references/reference-tools-mcp-server.md) - The MCPServer class provides the functionality to expose your existing Mastra tools and Agents as a Model Context Protocol (MCP) server.
|
|
31
28
|
|
|
@@ -1,71 +1,71 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.9.0-alpha.
|
|
2
|
+
"version": "2.9.0-alpha.2",
|
|
3
3
|
"package": "@mastra/mcp",
|
|
4
4
|
"exports": {
|
|
5
5
|
"InMemoryMCPEventCursorStore": {
|
|
6
6
|
"types": "dist/integrations/events-cursor-store.d.ts",
|
|
7
7
|
"implementation": "dist/index.js",
|
|
8
|
-
"line":
|
|
8
|
+
"line": 25427
|
|
9
9
|
},
|
|
10
10
|
"InMemoryMCPTaskStore": {
|
|
11
11
|
"types": "dist/server/tasks/in-memory-store.d.ts",
|
|
12
12
|
"implementation": "dist/index.js",
|
|
13
|
-
"line":
|
|
13
|
+
"line": 22202
|
|
14
14
|
},
|
|
15
15
|
"InMemoryOAuthStorage": {
|
|
16
16
|
"types": "dist/client/oauth-provider.d.ts",
|
|
17
17
|
"implementation": "dist/index.js",
|
|
18
|
-
"line":
|
|
18
|
+
"line": 17800
|
|
19
19
|
},
|
|
20
20
|
"InMemoryWebhookSubscriptionStore": {
|
|
21
21
|
"types": "dist/server/events/webhook-store.d.ts",
|
|
22
22
|
"implementation": "dist/index.js",
|
|
23
|
-
"line":
|
|
23
|
+
"line": 20572
|
|
24
24
|
},
|
|
25
25
|
"InternalMastraMCPClient": {
|
|
26
26
|
"types": "dist/client/client.d.ts",
|
|
27
27
|
"implementation": "dist/index.js",
|
|
28
|
-
"line":
|
|
28
|
+
"line": 16070
|
|
29
29
|
},
|
|
30
30
|
"MCPClient": {
|
|
31
31
|
"types": "dist/client/configuration.d.ts",
|
|
32
32
|
"implementation": "dist/index.js",
|
|
33
|
-
"line":
|
|
33
|
+
"line": 18293
|
|
34
34
|
},
|
|
35
35
|
"MCPClientServerProxy": {
|
|
36
36
|
"types": "dist/client/server-proxy.d.ts",
|
|
37
37
|
"implementation": "dist/index.js",
|
|
38
|
-
"line":
|
|
38
|
+
"line": 18141
|
|
39
39
|
},
|
|
40
40
|
"MCPEventsSignalProvider": {
|
|
41
41
|
"types": "dist/integrations/events-signals.d.ts",
|
|
42
42
|
"implementation": "dist/index.js",
|
|
43
|
-
"line":
|
|
43
|
+
"line": 25612
|
|
44
44
|
},
|
|
45
45
|
"MCPOAuthClientProvider": {
|
|
46
46
|
"types": "dist/client/oauth-provider.d.ts",
|
|
47
47
|
"implementation": "dist/index.js",
|
|
48
|
-
"line":
|
|
48
|
+
"line": 17852
|
|
49
49
|
},
|
|
50
50
|
"MCPServer": {
|
|
51
51
|
"types": "dist/server/server.d.ts",
|
|
52
52
|
"implementation": "dist/index.js",
|
|
53
|
-
"line":
|
|
53
|
+
"line": 23217
|
|
54
54
|
},
|
|
55
55
|
"MCPTaskLimitError": {
|
|
56
56
|
"types": "dist/server/tasks/store.d.ts",
|
|
57
57
|
"implementation": "dist/index.js",
|
|
58
|
-
"line":
|
|
58
|
+
"line": 21384
|
|
59
59
|
},
|
|
60
60
|
"MCP_CALL_TOOL_CONTENT": {
|
|
61
61
|
"types": "dist/client/client.d.ts",
|
|
62
62
|
"implementation": "dist/index.js",
|
|
63
|
-
"line":
|
|
63
|
+
"line": 15914
|
|
64
64
|
},
|
|
65
65
|
"MCP_CALL_TOOL_META": {
|
|
66
66
|
"types": "dist/client/client.d.ts",
|
|
67
67
|
"implementation": "dist/index.js",
|
|
68
|
-
"line":
|
|
68
|
+
"line": 15916
|
|
69
69
|
},
|
|
70
70
|
"MCP_CLIENT_PROTOCOL_VERSION": {
|
|
71
71
|
"types": "dist/client/types.d.ts",
|
|
@@ -75,62 +75,62 @@
|
|
|
75
75
|
"MCP_DISCOVERY_TIMEOUT_CODE": {
|
|
76
76
|
"types": "dist/client/configuration.d.ts",
|
|
77
77
|
"implementation": "dist/index.js",
|
|
78
|
-
"line":
|
|
78
|
+
"line": 18262
|
|
79
79
|
},
|
|
80
80
|
"MCP_PROTOCOL_VERSION": {
|
|
81
81
|
"types": "dist/server/types.d.ts",
|
|
82
82
|
"implementation": "dist/index.js",
|
|
83
|
-
"line":
|
|
83
|
+
"line": 25154
|
|
84
84
|
},
|
|
85
85
|
"ServerEventActions": {
|
|
86
86
|
"types": "dist/server/events/actions.d.ts",
|
|
87
87
|
"implementation": "dist/index.js",
|
|
88
|
-
"line":
|
|
88
|
+
"line": 19673
|
|
89
89
|
},
|
|
90
90
|
"ServerPromptActions": {
|
|
91
91
|
"types": "dist/server/actions.d.ts",
|
|
92
92
|
"implementation": "dist/index.js",
|
|
93
|
-
"line":
|
|
93
|
+
"line": 19653
|
|
94
94
|
},
|
|
95
95
|
"ServerResourceActions": {
|
|
96
96
|
"types": "dist/server/actions.d.ts",
|
|
97
97
|
"implementation": "dist/index.js",
|
|
98
|
-
"line":
|
|
98
|
+
"line": 19639
|
|
99
99
|
},
|
|
100
100
|
"ServerToolActions": {
|
|
101
101
|
"types": "dist/server/actions.d.ts",
|
|
102
102
|
"implementation": "dist/index.js",
|
|
103
|
-
"line":
|
|
103
|
+
"line": 19621
|
|
104
104
|
},
|
|
105
105
|
"createIntrospectionValidator": {
|
|
106
106
|
"types": "dist/server/oauth-middleware.d.ts",
|
|
107
107
|
"implementation": "dist/index.js",
|
|
108
|
-
"line":
|
|
108
|
+
"line": 25346
|
|
109
109
|
},
|
|
110
110
|
"createOAuthCallbackServer": {
|
|
111
111
|
"types": "dist/client/oauth-callback-server.d.ts",
|
|
112
112
|
"implementation": "dist/index.js",
|
|
113
|
-
"line":
|
|
113
|
+
"line": 17682
|
|
114
114
|
},
|
|
115
115
|
"createOAuthMiddleware": {
|
|
116
116
|
"types": "dist/server/oauth-middleware.d.ts",
|
|
117
117
|
"implementation": "dist/index.js",
|
|
118
|
-
"line":
|
|
118
|
+
"line": 25199
|
|
119
119
|
},
|
|
120
120
|
"createSimpleTokenProvider": {
|
|
121
121
|
"types": "dist/client/oauth-provider.d.ts",
|
|
122
122
|
"implementation": "dist/index.js",
|
|
123
|
-
"line":
|
|
123
|
+
"line": 18115
|
|
124
124
|
},
|
|
125
125
|
"createStaticTokenValidator": {
|
|
126
126
|
"types": "dist/server/oauth-middleware.d.ts",
|
|
127
127
|
"implementation": "dist/index.js",
|
|
128
|
-
"line":
|
|
128
|
+
"line": 25315
|
|
129
129
|
},
|
|
130
130
|
"defineEvent": {
|
|
131
131
|
"types": "dist/server/events/define-event.d.ts",
|
|
132
132
|
"implementation": "dist/index.js",
|
|
133
|
-
"line":
|
|
133
|
+
"line": 25417
|
|
134
134
|
},
|
|
135
135
|
"extractBearerToken": {
|
|
136
136
|
"types": "dist/shared/oauth-types.d.ts",
|
|
@@ -150,32 +150,32 @@
|
|
|
150
150
|
"getCallbackUrlCandidates": {
|
|
151
151
|
"types": "dist/client/oauth-callback-server.d.ts",
|
|
152
152
|
"implementation": "dist/index.js",
|
|
153
|
-
"line":
|
|
153
|
+
"line": 17615
|
|
154
154
|
},
|
|
155
155
|
"getMcpCallToolContent": {
|
|
156
156
|
"types": "dist/client/client.d.ts",
|
|
157
157
|
"implementation": "dist/index.js",
|
|
158
|
-
"line":
|
|
158
|
+
"line": 15936
|
|
159
159
|
},
|
|
160
160
|
"getMcpCallToolMeta": {
|
|
161
161
|
"types": "dist/client/client.d.ts",
|
|
162
162
|
"implementation": "dist/index.js",
|
|
163
|
-
"line":
|
|
163
|
+
"line": 15945
|
|
164
164
|
},
|
|
165
165
|
"isMCPTaskStoreAdmin": {
|
|
166
166
|
"types": "dist/server/tasks/store.d.ts",
|
|
167
167
|
"implementation": "dist/index.js",
|
|
168
|
-
"line":
|
|
168
|
+
"line": 21435
|
|
169
169
|
},
|
|
170
170
|
"isWorkflowTaskContext": {
|
|
171
171
|
"types": "dist/server/tasks/workflow-runs.d.ts",
|
|
172
172
|
"implementation": "dist/index.js",
|
|
173
|
-
"line":
|
|
173
|
+
"line": 22975
|
|
174
174
|
},
|
|
175
175
|
"principalKeyOf": {
|
|
176
176
|
"types": "dist/server/tasks/store.d.ts",
|
|
177
177
|
"implementation": "dist/index.js",
|
|
178
|
-
"line":
|
|
178
|
+
"line": 21376
|
|
179
179
|
},
|
|
180
180
|
"taskKeyOf": {
|
|
181
181
|
"types": "dist/shared/tasks/task-id.d.ts",
|
|
@@ -8,7 +8,7 @@ Mastra supports the [Model Context Protocol (MCP)](https://modelcontextprotocol.
|
|
|
8
8
|
|
|
9
9
|
Use [`MCPClient`](https://mastra.ai/reference/tools/mcp-client) to connect to MCP servers. Use [`MCPServer`](https://mastra.ai/reference/tools/mcp-server) to expose Mastra agents, tools, workflows, prompts, and resources to other MCP-compatible systems. Both speak the MCP `2026-07-28` revision over stdio and Streamable HTTP.
|
|
10
10
|
|
|
11
|
-
For hosted MCP servers such as Neon and Canva, [Connect](https://mastra.ai/docs/mastra-platform/connect
|
|
11
|
+
For hosted MCP servers such as [Neon](https://mastra.ai/integrations/databases/neon) and [Canva](https://mastra.ai/integrations/other/canva), [Connect](https://mastra.ai/docs/mastra-platform/connect) on Mastra platform can manage the OAuth flow and credentials for you, so agents get the server's tools through [`tools()`](https://mastra.ai/reference/connect/tools) without a hand-configured `MCPClient`.
|
|
12
12
|
|
|
13
13
|
> **Note:** Upgrading from `@mastra/mcp` 1.x? See the [migration guide](https://mastra.ai/reference/migrations/mcp-v2).
|
|
14
14
|
|
|
@@ -445,7 +445,7 @@ Tools loaded through `listTools()` include a `serverId` in `_meta.ui`, allowing
|
|
|
445
445
|
|
|
446
446
|
### Use prebuilt Mastra apps
|
|
447
447
|
|
|
448
|
-
The `@mastra/mcp-apps-components` package includes prebuilt MCP Apps
|
|
448
|
+
The `@mastra/mcp-apps-components` package includes prebuilt MCP Apps. Each one is a self-contained HTML page that you register as an app resource, next to the tools it talks to.
|
|
449
449
|
|
|
450
450
|
**npm**:
|
|
451
451
|
|
|
@@ -471,76 +471,42 @@ yarn add @mastra/mcp-apps-components
|
|
|
471
471
|
bun add @mastra/mcp-apps-components
|
|
472
472
|
```
|
|
473
473
|
|
|
474
|
-
|
|
474
|
+
`greetingApp` greets someone by name. The host sends it the arguments of the tool that opened it, and the app reads `name`. It then calls the `getGreeting` tool on the same server for its data and shows the `greeting` from the result. Mark `getGreeting` as app-only with `visibility: ['app']`, so the model doesn't see it:
|
|
475
475
|
|
|
476
476
|
```typescript
|
|
477
|
-
import type { DashboardDefinition } from '@mastra/core/storage/dashboards'
|
|
478
477
|
import { createTool } from '@mastra/core/tools'
|
|
479
478
|
import { MCPServer } from '@mastra/mcp'
|
|
480
|
-
import {
|
|
481
|
-
dashboardRendererApp,
|
|
482
|
-
dashboardRendererInputSchema,
|
|
483
|
-
} from '@mastra/mcp-apps-components/dashboard-renderer'
|
|
484
|
-
import { observabilityAppTools } from '@mastra/mcp-apps-components/observability-tools'
|
|
479
|
+
import { greetingApp } from '@mastra/mcp-apps-components'
|
|
485
480
|
import { z } from 'zod'
|
|
486
481
|
|
|
487
|
-
const
|
|
488
|
-
|
|
489
|
-
const agentRuns: DashboardDefinition = {
|
|
490
|
-
schemaVersion: 1,
|
|
491
|
-
defaults: { datePreset: '7d' },
|
|
492
|
-
rows: [
|
|
493
|
-
{
|
|
494
|
-
widgets: [
|
|
495
|
-
{
|
|
496
|
-
id: 'runs',
|
|
497
|
-
span: 12,
|
|
498
|
-
kind: 'kpis',
|
|
499
|
-
views: [
|
|
500
|
-
{
|
|
501
|
-
queries: [
|
|
502
|
-
{
|
|
503
|
-
id: 'runs',
|
|
504
|
-
source: 'metrics',
|
|
505
|
-
request: 'aggregate',
|
|
506
|
-
name: ['mastra_agent_duration_ms'],
|
|
507
|
-
aggregation: 'count',
|
|
508
|
-
},
|
|
509
|
-
],
|
|
510
|
-
options: {
|
|
511
|
-
items: [{ label: 'Agent runs', format: 'count', value: { query: 'runs' } }],
|
|
512
|
-
},
|
|
513
|
-
},
|
|
514
|
-
],
|
|
515
|
-
},
|
|
516
|
-
],
|
|
517
|
-
},
|
|
518
|
-
],
|
|
519
|
-
}
|
|
482
|
+
const uri = 'ui://mastra/greeting'
|
|
520
483
|
|
|
521
|
-
const
|
|
522
|
-
id: '
|
|
523
|
-
|
|
524
|
-
inputSchema: z.object({}),
|
|
525
|
-
outputSchema: dashboardRendererInputSchema,
|
|
526
|
-
mcp: { _meta: { ui: { resourceUri: DASHBOARD_APP_URI } } },
|
|
527
|
-
execute: async () => ({ definition: agentRuns, scope: 'project' as const }),
|
|
528
|
-
})
|
|
529
|
-
|
|
530
|
-
export const dashboardServer = new MCPServer({
|
|
531
|
-
id: 'dashboard-server',
|
|
532
|
-
name: 'Dashboard Server',
|
|
484
|
+
export const greetingServer = new MCPServer({
|
|
485
|
+
id: 'greeting-server',
|
|
486
|
+
name: 'Greeting Server',
|
|
533
487
|
version: '1.0.0',
|
|
534
|
-
appResources: { [
|
|
535
|
-
tools: {
|
|
488
|
+
appResources: { [uri]: greetingApp },
|
|
489
|
+
tools: {
|
|
490
|
+
showGreeting: createTool({
|
|
491
|
+
id: 'showGreeting',
|
|
492
|
+
description: 'Shows a greeting card for someone',
|
|
493
|
+
inputSchema: z.object({ name: z.string() }),
|
|
494
|
+
mcp: { _meta: { ui: { resourceUri: uri } } },
|
|
495
|
+
execute: async ({ name }) => ({ name }),
|
|
496
|
+
}),
|
|
497
|
+
getGreeting: createTool({
|
|
498
|
+
id: 'getGreeting',
|
|
499
|
+
description: 'Returns the greeting for a name',
|
|
500
|
+
inputSchema: z.object({ name: z.string() }),
|
|
501
|
+
outputSchema: z.object({ greeting: z.string() }),
|
|
502
|
+
mcp: { _meta: { ui: { resourceUri: uri, visibility: ['app'] } } },
|
|
503
|
+
execute: async ({ name }) => ({ greeting: `Hello, ${name}!` }),
|
|
504
|
+
}),
|
|
505
|
+
},
|
|
536
506
|
})
|
|
537
507
|
```
|
|
538
508
|
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
Each tool runs its observability route in-process as the signed-in caller through [`invokeRoute()`](https://mastra.ai/reference/server/invoke-route), with the route's own validation, permission, and authorization checks. The app sees the same data the caller can read over HTTP.
|
|
542
|
-
|
|
543
|
-
> **Note:** When server auth is configured, the tools need the caller resolved by Mastra server auth. Serve the MCP server through a Mastra server adapter, such as Hono, Express, Fastify, Koa, Elysia, or NestJS. Calls without an authenticated caller return `401`.
|
|
509
|
+
`getGreeting` runs on your server, so it can call any API with your server's credentials. The app's iframe has no network access of its own.
|
|
544
510
|
|
|
545
511
|
### Sandbox security
|
|
546
512
|
|
|
@@ -1764,7 +1764,9 @@ With hooks disabled, your application is responsible for closing MCP connections
|
|
|
1764
1764
|
|
|
1765
1765
|
For HTTP servers, you can provide a custom `fetch` function to handle runtime-defined authentication or request interception. It can also handle other custom behavior. This is particularly useful when you need to refresh tokens on each request or forward user credentials from the incoming request to the MCP server.
|
|
1766
1766
|
|
|
1767
|
-
The custom `fetch` function receives an optional third `requestContext` parameter, which provides access to request-scoped data (e.g., authentication cookies, bearer tokens) set by middleware or passed during agent/tool execution. The `requestContext` is `null`
|
|
1767
|
+
The custom `fetch` function receives an optional third `requestContext` parameter, which provides access to request-scoped data (e.g., authentication cookies, bearer tokens) set by middleware or passed during agent/tool execution. The `requestContext` is `null` for requests that no tool call sends, such as `listTools()` and the connection handshake it opens. When a tool call opens the connection, either because a tool rebuilt with `toolsFromDefinitions()` or `toolFromDefinition()` connects on its first execution or because the call reconnects, the handshake receives that call's `requestContext`. Streams the connection keeps open afterward, such as the server-to-client event stream, keep using that same `requestContext`, and so do the client's replies to server requests on them, such as an answer to an input request. A request your own code starts from a server log or notification on those streams gets `null`.
|
|
1768
|
+
|
|
1769
|
+
A server that authenticates every request therefore needs a credential for discovery as well as for tool calls. The following example forwards the user's cookie when a tool call provides a `requestContext`, and sends the app's own token when there's none, as in `listTools()`. Any request without a `requestContext` gets that token, so have the server limit it to discovery, for example listing tools but not calling them.
|
|
1768
1770
|
|
|
1769
1771
|
When `fetch` is provided, `requestInit` and `authProvider` become optional, as you can handle these concerns within your custom fetch function.
|
|
1770
1772
|
|
|
@@ -1775,10 +1777,15 @@ const mcpClient = new MCPClient({
|
|
|
1775
1777
|
url: new URL('https://api.example.com/mcp'),
|
|
1776
1778
|
fetch: async (url, init, requestContext) => {
|
|
1777
1779
|
const headers = new Headers(init?.headers)
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1780
|
+
if (requestContext) {
|
|
1781
|
+
// A tool call: forward the auth cookie from the incoming request
|
|
1782
|
+
const cookie = requestContext.get('cookie')
|
|
1783
|
+
if (cookie) {
|
|
1784
|
+
headers.set('cookie', cookie)
|
|
1785
|
+
}
|
|
1786
|
+
} else {
|
|
1787
|
+
// No requestContext, as in listTools(): a token the server only accepts for discovery
|
|
1788
|
+
headers.set('authorization', `Bearer ${process.env.MCP_DISCOVERY_TOKEN}`)
|
|
1782
1789
|
}
|
|
1783
1790
|
return fetch(url, { ...init, headers })
|
|
1784
1791
|
},
|
|
@@ -1800,9 +1807,11 @@ await agent.generate('Hello!', {
|
|
|
1800
1807
|
})
|
|
1801
1808
|
```
|
|
1802
1809
|
|
|
1810
|
+
If the server accepts only per-user credentials, skip `listTools()` at startup. Build the catalog with [`listToolDefinitions()`](#listtooldefinitions) from a client that has a credential of its own, for example in a build step with a static `requestInit` header, and store it. At runtime, rebuild the tools with [`toolsFromDefinitions()`](#toolsfromdefinitions). Each rebuilt tool opens the connection on its first call, so the handshake carries that call's `requestContext`.
|
|
1811
|
+
|
|
1803
1812
|
## Handling auth failures inside custom fetch
|
|
1804
1813
|
|
|
1805
|
-
A custom `fetch` shouldn't `throw` when authentication is unavailable.
|
|
1814
|
+
A custom `fetch` shouldn't `throw` when authentication is unavailable. JSON-RPC requests such as `tools/call` are `POST`s, and the SDK surfaces a non-2xx response as an error to the caller of `listTools()`, `tools/call` and so on, which is the behavior you want. A thrown `fetch` is reported the same way but loses the server's status and body. On a 2025-11-25 server, the client also sends a `GET` with no body after the handshake to open the server-to-client event stream, so check `init.method` rather than assuming a `POST` body. Long-lived streams are reopened after a failure: the `subscriptions/listen` `POST` the client opens for `resources.subscribe()` and the `GET` event stream if it drops. An unauthenticated `subscriptions/listen` stream can loop. Wait for the token, then forward the request:
|
|
1806
1815
|
|
|
1807
1816
|
```typescript
|
|
1808
1817
|
async function waitForToken(timeoutMs = 5000): Promise<string | null> {
|
|
@@ -625,6 +625,8 @@ export type MCPServerResourceContent = { text?: string } | { blob?: string }
|
|
|
625
625
|
|
|
626
626
|
Every callback receives `extra`, the same protocol context tools see as `context.mcp.extra` (cancellation `signal`, `requestId`, `authInfo`, `_meta`), and `requestContext`, the trusted application context that carries `authInfo` and the user mapped by `mapAuthInfoToUser`. Use them to scope what a caller can list and read.
|
|
627
627
|
|
|
628
|
+
A `resources/read` request resolves its URI against `listResources` first. When no listed resource matches, the URI is matched against the caller's `resourceTemplates`, and `getResourceContent` receives the expanded URI. Optional expressions such as `{?format}` or `{/section}` may be left out of the URI. Variable values must be percent-encoded as RFC 6570 expansion produces them, so `file://data?format=a/b` doesn't match `file://data{?format}`. The response uses the `mimeType` and `_meta` of the matching resource or template. A URI that matches neither fails with `Resource not found`.
|
|
629
|
+
|
|
628
630
|
`getResourceContent` also receives `suspend`, `resumeData` and `suspendPayload` (the `MCPServerRequest` members). Declare `resumeSchema` to make `suspend` usable. It works exactly as it does for tools.
|
|
629
631
|
|
|
630
632
|
Example:
|
|
@@ -640,11 +642,13 @@ import type {
|
|
|
640
642
|
|
|
641
643
|
// Resources/resource templates will generally be dynamically fetched.
|
|
642
644
|
const myResources: Resource[] = [
|
|
643
|
-
{ uri: 'file://data/
|
|
645
|
+
{ uri: 'file://data/readme', name: 'Readme', mimeType: 'text/plain' },
|
|
644
646
|
]
|
|
645
647
|
|
|
646
648
|
const myResourceContents: Record<string, MCPServerResourceContent> = {
|
|
647
|
-
'file://data
|
|
649
|
+
'file://data/readme': { text: 'Read this first.' },
|
|
650
|
+
// Not listed; readable as an expansion of the `file://data/{id}` template
|
|
651
|
+
'file://data/123': { text: 'This is the content of data file 123.' },
|
|
648
652
|
}
|
|
649
653
|
|
|
650
654
|
const myResourceTemplates: ResourceTemplate[] = [
|