@mastra/mcp 2.7.0 → 2.8.0-alpha.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/client/client.d.ts +20 -1
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/configuration.d.ts +28 -4
- package/dist/client/configuration.d.ts.map +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-tools-mcp-client.md +37 -0
- package/dist/index.cjs +152 -70
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +152 -71
- package/dist/index.js.map +1 -1
- package/dist/server/server.d.ts +6 -0
- package/dist/server/server.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/client/client.d.ts
CHANGED
|
@@ -167,6 +167,25 @@ export declare class InternalMastraMCPClient extends MastraBase {
|
|
|
167
167
|
finishAuth(authorizationCode: string, issuer?: string): Promise<void>;
|
|
168
168
|
private isConnected;
|
|
169
169
|
private reconnectPromise;
|
|
170
|
+
/**
|
|
171
|
+
* Transport of the connect attempt still in flight. The SDK only attaches it to
|
|
172
|
+
* the client once version negotiation finishes, so a server that never answers
|
|
173
|
+
* would otherwise leave nothing that disconnect() or a newer attempt can close.
|
|
174
|
+
*/
|
|
175
|
+
private connectingTransport?;
|
|
176
|
+
/**
|
|
177
|
+
* Closes the transport of an unfinished connect attempt. Closing makes the SDK
|
|
178
|
+
* reject that attempt and reap the child (and any negotiation probe) it spawned.
|
|
179
|
+
*/
|
|
180
|
+
private abandonPendingConnect;
|
|
181
|
+
/**
|
|
182
|
+
* Whether a connect or reconnect is still running on this client. A failed attempt
|
|
183
|
+
* that a newer one replaced reports true here, since the newer attempt owns the client.
|
|
184
|
+
*
|
|
185
|
+
* @internal
|
|
186
|
+
*/
|
|
187
|
+
hasPendingConnect(): boolean;
|
|
188
|
+
private assertSameLifecycle;
|
|
170
189
|
/**
|
|
171
190
|
* Change notifications the caller has asked for. The client keeps exactly one
|
|
172
191
|
* `subscriptions/listen` stream open for this interest set, replaces it when the
|
|
@@ -190,7 +209,7 @@ export declare class InternalMastraMCPClient extends MastraBase {
|
|
|
190
209
|
*
|
|
191
210
|
* @internal
|
|
192
211
|
*/
|
|
193
|
-
connect(): Promise<boolean>;
|
|
212
|
+
connect(generation?: number): Promise<boolean>;
|
|
194
213
|
/**
|
|
195
214
|
* Installs the process-exit and signal handlers that tear this client down when the
|
|
196
215
|
* host process goes away. Idempotent, so repeated connects add at most one of each.
|
|
@@ -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,M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B/D;IAED;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IA2R9B,iEAAiE;IACjE,IAAI,KAAK,IAAI,IAAI,CAAC,aAAa,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC,CAE5D;IAED;;;OAGG;IACH,OAAO,CAAC,wBAAwB;IAShC,uFAAuF;YACzE,aAAa;IAsE3B,OAAO,CAAC,mBAAmB;CAQ5B"}
|
|
@@ -8,10 +8,33 @@ import type { MastraMCPServerDefinition, MCPServerAuthState } from './client.js'
|
|
|
8
8
|
import type { MCPDiscoveryErrorDetails } from './error-utils.js';
|
|
9
9
|
import type { MCPClientWebhookOptions, MCPEventDescriptor, MCPEventSubscribeOptions, MCPEventSubscription } from './events/index.js';
|
|
10
10
|
import type { MCPClientInfo, MCPClientServers, MCPClientTools, MCPClientToolsets, MCPServerImplementation, MCPServerMap, SerializableMCPToolCatalog, SerializableMCPToolDefinition } from './types.js';
|
|
11
|
+
/**
|
|
12
|
+
* `code` of the discovery error reported when a server exceeds `perServerTimeoutMs`.
|
|
13
|
+
* The server's connect keeps running, so a later discovery can still succeed.
|
|
14
|
+
*/
|
|
15
|
+
export declare const MCP_DISCOVERY_TIMEOUT_CODE = "MCP_DISCOVERY_TIMEOUT";
|
|
16
|
+
/** Outcome of one server's discovery, passed to {@link MCPDiscoveryOptions.onServerSettled}. */
|
|
17
|
+
export type MCPServerSettledResult<T> = {
|
|
18
|
+
value: T;
|
|
19
|
+
error?: undefined;
|
|
20
|
+
duration: number;
|
|
21
|
+
} | {
|
|
22
|
+
value?: undefined;
|
|
23
|
+
error: MCPDiscoveryErrorDetails;
|
|
24
|
+
duration: number;
|
|
25
|
+
};
|
|
11
26
|
/** Options for aggregate discovery across configured MCP servers. */
|
|
12
|
-
export interface MCPDiscoveryOptions {
|
|
27
|
+
export interface MCPDiscoveryOptions<T = unknown> {
|
|
13
28
|
/** Maximum time to wait for each server's discovery operation, in milliseconds. */
|
|
14
29
|
perServerTimeoutMs?: number;
|
|
30
|
+
/** Only discover these configured servers. Unknown names are ignored. Defaults to every server. */
|
|
31
|
+
serverNames?: string[];
|
|
32
|
+
/**
|
|
33
|
+
* Called as soon as each server's discovery succeeds, fails, or times out, before the
|
|
34
|
+
* aggregate result resolves. Lets callers report each server independently instead of
|
|
35
|
+
* waiting for the slowest one. Errors thrown by the callback are logged and ignored.
|
|
36
|
+
*/
|
|
37
|
+
onServerSettled?: (serverName: string, result: MCPServerSettledResult<T>) => void;
|
|
15
38
|
}
|
|
16
39
|
/**
|
|
17
40
|
* Configuration options for creating an MCPClient instance.
|
|
@@ -799,7 +822,7 @@ export declare class MCPClient<TServers extends MCPClientServers<TServers> = MCP
|
|
|
799
822
|
* }
|
|
800
823
|
* ```
|
|
801
824
|
*/
|
|
802
|
-
listToolsWithErrors(options?: MCPDiscoveryOptions): Promise<{
|
|
825
|
+
listToolsWithErrors(options?: MCPDiscoveryOptions<Record<string, Tool<any, any, any, any>>>): Promise<{
|
|
803
826
|
tools: MCPClientTools<TServers>;
|
|
804
827
|
errors: Record<string, string>;
|
|
805
828
|
errorDetails: Record<string, MCPDiscoveryErrorDetails>;
|
|
@@ -846,7 +869,7 @@ export declare class MCPClient<TServers extends MCPClientServers<TServers> = MCP
|
|
|
846
869
|
* }
|
|
847
870
|
* ```
|
|
848
871
|
*/
|
|
849
|
-
listToolsetsWithErrors(options?: MCPDiscoveryOptions): Promise<{
|
|
872
|
+
listToolsetsWithErrors(options?: MCPDiscoveryOptions<Record<string, Tool<any, any, any, any>>>): Promise<{
|
|
850
873
|
toolsets: MCPClientToolsets<TServers>;
|
|
851
874
|
errors: Record<string, string>;
|
|
852
875
|
errorDetails: Record<string, MCPDiscoveryErrorDetails>;
|
|
@@ -884,7 +907,7 @@ export declare class MCPClient<TServers extends MCPClientServers<TServers> = MCP
|
|
|
884
907
|
* `errors` remains a string map for compatibility; `errorDetails` preserves
|
|
885
908
|
* machine-readable transport status and error codes when available.
|
|
886
909
|
*/
|
|
887
|
-
listToolDefinitionsWithErrors(options?: MCPDiscoveryOptions): Promise<{
|
|
910
|
+
listToolDefinitionsWithErrors(options?: MCPDiscoveryOptions<Record<string, SerializableMCPToolDefinition>>): Promise<{
|
|
888
911
|
definitions: SerializableMCPToolCatalog;
|
|
889
912
|
errors: Record<string, string>;
|
|
890
913
|
errorDetails: Record<string, MCPDiscoveryErrorDetails>;
|
|
@@ -945,6 +968,7 @@ export declare class MCPClient<TServers extends MCPClientServers<TServers> = MCP
|
|
|
945
968
|
* `prompts.list`.
|
|
946
969
|
*/
|
|
947
970
|
private discoverAcrossServers;
|
|
971
|
+
private discoverServer;
|
|
948
972
|
/**
|
|
949
973
|
* Creates `MCPServerBase` proxy objects for each server connection in this
|
|
950
974
|
* MCPClient. The returned record can be spread directly into Mastra's
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../src/client/configuration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAGjH,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE9E,OAAO,KAAK,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE9E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,KAAK,EACV,uBAAuB,EACvB,kBAAkB,EAClB,wBAAwB,EACxB,oBAAoB,EACrB,MAAM,UAAU,CAAC;AAQlB,OAAO,KAAK,EACV,aAAa,E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AU,GACX,EAAE;QACD,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,6BAA6B,CAAC;KAC3C,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAOpC;IAED;;;;;;;;;;;;;;;OAeG;IACU,oBAAoB,CAAC,EAChC,WAAW,EAAE,OAAO,GACrB,EAAE;QACD,WAAW,EAAE,0BAA0B,CAAC;KACzC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAuBpD;YAEa,uBAAuB;YAcvB,+BAA+B;YAiB/B,qBAAqB;YAcrB,wBAAwB;IA8BtC;;;;;;;;;;;OAWG;YACW,qBAAqB;YAuCrB,cAAc;IAuE5B;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACI,kBAAkB,IAAI,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAQzD;IAED;;;;;;;;OAQG;IACI,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAIxD;IAED,OAAO,CAAC,eAAe;YAQT,iBAAiB;YAsCjB,kBAAkB;IAchC,OAAO,CAAC,kBAAkB;YA+BZ,2BAA2B;YAI3B,kBAAkB;YAIlB,iBAAiB;CAuBhC"}
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -462,6 +462,43 @@ console.log(errors, errorDetails, durations)
|
|
|
462
462
|
|
|
463
463
|
When called without options, the method omits only `durations`; `toolsets`, `errors`, and `errorDetails` are always returned.
|
|
464
464
|
|
|
465
|
+
#### Report each server as it settles
|
|
466
|
+
|
|
467
|
+
The returned promise resolves only after every server finishes, so one slow server delays the whole result. Pass `onServerSettled` to handle each server as soon as its discovery succeeds, fails, or times out. The callback receives the server name and either `value` (that server's tools, keyed by the server's own tool names) or `error`, plus `duration` in milliseconds. This option is also available on `listToolsWithErrors()` and `listToolDefinitionsWithErrors()`.
|
|
468
|
+
|
|
469
|
+
```typescript
|
|
470
|
+
await mcp.listToolsetsWithErrors({
|
|
471
|
+
perServerTimeoutMs: 60_000,
|
|
472
|
+
onServerSettled: (serverName, { value, error, duration }) => {
|
|
473
|
+
if (error) {
|
|
474
|
+
console.error(`${serverName} failed after ${duration}ms: ${error.message}`)
|
|
475
|
+
} else {
|
|
476
|
+
console.log(`${serverName} ready with ${Object.keys(value).length} tools`)
|
|
477
|
+
}
|
|
478
|
+
},
|
|
479
|
+
})
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
Errors thrown by the callback are logged and don't affect discovery. The same is true for an `async` callback that rejects: the rejection is logged and never becomes an unhandled rejection.
|
|
483
|
+
|
|
484
|
+
#### Discover only some servers
|
|
485
|
+
|
|
486
|
+
Pass `serverNames` to discover only the named servers, for example to retry the ones that timed out without starting every other server again. Names that aren't configured are ignored. This option is also available on `listToolsWithErrors()` and `listToolDefinitionsWithErrors()`.
|
|
487
|
+
|
|
488
|
+
```typescript
|
|
489
|
+
const { errorDetails } = await mcp.listToolsetsWithErrors({ perServerTimeoutMs: 3_000 })
|
|
490
|
+
|
|
491
|
+
// Only servers that timed out are worth retrying. A server that failed for
|
|
492
|
+
// another reason (bad config, auth refused) will just fail again.
|
|
493
|
+
const timedOut = Object.entries(errorDetails)
|
|
494
|
+
.filter(([, details]) => details.code === MCP_DISCOVERY_TIMEOUT_CODE)
|
|
495
|
+
.map(([serverName]) => serverName)
|
|
496
|
+
|
|
497
|
+
const retry = await mcp.listToolsetsWithErrors({ serverNames: timedOut })
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
`MCP_DISCOVERY_TIMEOUT_CODE` is exported from `@mastra/mcp`. It marks the errors that `perServerTimeoutMs` produced, so you can tell a slow server apart from a broken one.
|
|
501
|
+
|
|
465
502
|
### `listToolDefinitions()`
|
|
466
503
|
|
|
467
504
|
Returns every server's tools as plain, serializable definitions, grouped by server name and keyed by the server's own tool name (without the `serverName_toolName` namespacing that `listTools()` applies).
|
package/dist/index.cjs
CHANGED
|
@@ -16125,7 +16125,7 @@ var InternalMastraMCPClient = class extends _mastra_core_base.MastraBase {
|
|
|
16125
16125
|
...configured
|
|
16126
16126
|
};
|
|
16127
16127
|
}
|
|
16128
|
-
async connectStdio(command) {
|
|
16128
|
+
async connectStdio(command, generation) {
|
|
16129
16129
|
this.log("debug", `Using Stdio transport for command: ${command}`);
|
|
16130
16130
|
const transport = new _modelcontextprotocol_client_stdio.StdioClientTransport({
|
|
16131
16131
|
command,
|
|
@@ -16135,7 +16135,9 @@ var InternalMastraMCPClient = class extends _mastra_core_base.MastraBase {
|
|
|
16135
16135
|
cwd: this.serverConfig.cwd
|
|
16136
16136
|
});
|
|
16137
16137
|
observeEventStreamRequests(transport, this.noteEventStreamSent);
|
|
16138
|
+
this.connectingTransport = transport;
|
|
16138
16139
|
try {
|
|
16140
|
+
this.assertSameLifecycle(generation);
|
|
16139
16141
|
await this.client.connect(transport, {
|
|
16140
16142
|
timeout: this.serverConfig.timeout ?? this.timeout,
|
|
16141
16143
|
prior: this.priorDiscovery
|
|
@@ -16147,9 +16149,11 @@ var InternalMastraMCPClient = class extends _mastra_core_base.MastraBase {
|
|
|
16147
16149
|
this.log("error", e instanceof Error ? e.stack || e.message : JSON.stringify(e));
|
|
16148
16150
|
await transport.close().catch(() => {});
|
|
16149
16151
|
throw e;
|
|
16152
|
+
} finally {
|
|
16153
|
+
if (this.connectingTransport === transport) this.connectingTransport = void 0;
|
|
16150
16154
|
}
|
|
16151
16155
|
}
|
|
16152
|
-
async connectHttp(url) {
|
|
16156
|
+
async connectHttp(url, generation) {
|
|
16153
16157
|
const { requestInit, authProvider, connectTimeout, fetch: userFetch, allowedHosts } = this.serverConfig;
|
|
16154
16158
|
if (allowedHosts !== void 0) assertHostAllowed(url, allowedHosts);
|
|
16155
16159
|
const policyUserFetch = userFetch && allowedHosts !== void 0 ? wrapFetchWithHostPolicy(userFetch, allowedHosts) : void 0;
|
|
@@ -16169,7 +16173,9 @@ var InternalMastraMCPClient = class extends _mastra_core_base.MastraBase {
|
|
|
16169
16173
|
fetch
|
|
16170
16174
|
});
|
|
16171
16175
|
observeEventStreamRequests(transport, this.noteEventStreamSent);
|
|
16176
|
+
this.connectingTransport = transport;
|
|
16172
16177
|
try {
|
|
16178
|
+
this.assertSameLifecycle(generation);
|
|
16173
16179
|
await this.client.connect(transport, {
|
|
16174
16180
|
timeout: connectTimeout ?? DEFAULT_SERVER_CONNECT_TIMEOUT_MSEC,
|
|
16175
16181
|
prior: this.priorDiscovery
|
|
@@ -16183,6 +16189,8 @@ var InternalMastraMCPClient = class extends _mastra_core_base.MastraBase {
|
|
|
16183
16189
|
this.log("debug", `Streamable HTTP transport failed: ${error}`);
|
|
16184
16190
|
if (authProvider && error instanceof _modelcontextprotocol_client.UnauthorizedError) this.markNeedsAuth(transport);
|
|
16185
16191
|
throw error;
|
|
16192
|
+
} finally {
|
|
16193
|
+
if (this.connectingTransport === transport) this.connectingTransport = void 0;
|
|
16186
16194
|
}
|
|
16187
16195
|
}
|
|
16188
16196
|
/**
|
|
@@ -16272,6 +16280,34 @@ var InternalMastraMCPClient = class extends _mastra_core_base.MastraBase {
|
|
|
16272
16280
|
isConnected = null;
|
|
16273
16281
|
reconnectPromise = null;
|
|
16274
16282
|
/**
|
|
16283
|
+
* Transport of the connect attempt still in flight. The SDK only attaches it to
|
|
16284
|
+
* the client once version negotiation finishes, so a server that never answers
|
|
16285
|
+
* would otherwise leave nothing that disconnect() or a newer attempt can close.
|
|
16286
|
+
*/
|
|
16287
|
+
connectingTransport;
|
|
16288
|
+
/**
|
|
16289
|
+
* Closes the transport of an unfinished connect attempt. Closing makes the SDK
|
|
16290
|
+
* reject that attempt and reap the child (and any negotiation probe) it spawned.
|
|
16291
|
+
*/
|
|
16292
|
+
async abandonPendingConnect() {
|
|
16293
|
+
const pending = this.connectingTransport;
|
|
16294
|
+
if (!pending) return;
|
|
16295
|
+
this.connectingTransport = void 0;
|
|
16296
|
+
await pending.close().catch(() => {});
|
|
16297
|
+
}
|
|
16298
|
+
/**
|
|
16299
|
+
* Whether a connect or reconnect is still running on this client. A failed attempt
|
|
16300
|
+
* that a newer one replaced reports true here, since the newer attempt owns the client.
|
|
16301
|
+
*
|
|
16302
|
+
* @internal
|
|
16303
|
+
*/
|
|
16304
|
+
hasPendingConnect() {
|
|
16305
|
+
return this.isConnected !== null || this.reconnectPromise !== null;
|
|
16306
|
+
}
|
|
16307
|
+
assertSameLifecycle(generation) {
|
|
16308
|
+
if (this.lifecycleGeneration !== generation) throw new Error("MCP client was disconnected while connecting");
|
|
16309
|
+
}
|
|
16310
|
+
/**
|
|
16275
16311
|
* Change notifications the caller has asked for. The client keeps exactly one
|
|
16276
16312
|
* `subscriptions/listen` stream open for this interest set, replaces it when the
|
|
16277
16313
|
* set changes and reopens it after a reconnect.
|
|
@@ -16303,14 +16339,15 @@ var InternalMastraMCPClient = class extends _mastra_core_base.MastraBase {
|
|
|
16303
16339
|
*
|
|
16304
16340
|
* @internal
|
|
16305
16341
|
*/
|
|
16306
|
-
async connect() {
|
|
16342
|
+
async connect(generation = this.lifecycleGeneration) {
|
|
16307
16343
|
if (this.isConnected) return this.isConnected;
|
|
16308
|
-
|
|
16344
|
+
const attempt = new Promise(async (resolve, reject) => {
|
|
16309
16345
|
try {
|
|
16346
|
+
await this.abandonPendingConnect();
|
|
16310
16347
|
await this.detachStaleClientTransport();
|
|
16311
16348
|
const { command, url } = this.serverConfig;
|
|
16312
|
-
if (command) await this.connectStdio(command);
|
|
16313
|
-
else if (url) await this.connectHttp(url);
|
|
16349
|
+
if (command) await this.connectStdio(command, generation);
|
|
16350
|
+
else if (url) await this.connectHttp(url, generation);
|
|
16314
16351
|
else throw new Error("Server configuration must include either a command or a url.");
|
|
16315
16352
|
this.serverInstructions = this.client.getInstructions();
|
|
16316
16353
|
this.serverImplementation = this.client.getServerVersion();
|
|
@@ -16345,12 +16382,15 @@ var InternalMastraMCPClient = class extends _mastra_core_base.MastraBase {
|
|
|
16345
16382
|
this.clientConnectionOnClose = connectionOnClose;
|
|
16346
16383
|
this.client.onclose = connectionOnClose;
|
|
16347
16384
|
} catch (e) {
|
|
16348
|
-
if (
|
|
16349
|
-
|
|
16385
|
+
if (this.isConnected === attempt) {
|
|
16386
|
+
if (!this.transport) this.unregisterProcessHooks();
|
|
16387
|
+
this.isConnected = null;
|
|
16388
|
+
}
|
|
16350
16389
|
this.priorDiscovery = void 0;
|
|
16351
16390
|
reject(e);
|
|
16352
16391
|
}
|
|
16353
16392
|
});
|
|
16393
|
+
this.isConnected = attempt;
|
|
16354
16394
|
if (this.processHooks) this.registerProcessHooks();
|
|
16355
16395
|
return this.isConnected;
|
|
16356
16396
|
}
|
|
@@ -16433,6 +16473,7 @@ var InternalMastraMCPClient = class extends _mastra_core_base.MastraBase {
|
|
|
16433
16473
|
}
|
|
16434
16474
|
async disconnect() {
|
|
16435
16475
|
this.lifecycleGeneration++;
|
|
16476
|
+
await this.abandonPendingConnect();
|
|
16436
16477
|
const reconnectPromise = this.reconnectPromise;
|
|
16437
16478
|
if (reconnectPromise) await reconnectPromise.catch(() => {});
|
|
16438
16479
|
this.closePendingAuthTransport();
|
|
@@ -16471,6 +16512,7 @@ var InternalMastraMCPClient = class extends _mastra_core_base.MastraBase {
|
|
|
16471
16512
|
this.log("debug", "Reconnection already in progress; waiting for it to complete");
|
|
16472
16513
|
return await this.reconnectPromise;
|
|
16473
16514
|
}
|
|
16515
|
+
const generation = this.lifecycleGeneration;
|
|
16474
16516
|
const reconnectPromise = (async () => {
|
|
16475
16517
|
this.log("debug", "Forcing reconnection to MCP server...");
|
|
16476
16518
|
this.closePendingAuthTransport();
|
|
@@ -16488,7 +16530,8 @@ var InternalMastraMCPClient = class extends _mastra_core_base.MastraBase {
|
|
|
16488
16530
|
this.serverInstructions = void 0;
|
|
16489
16531
|
this.serverImplementation = void 0;
|
|
16490
16532
|
}
|
|
16491
|
-
|
|
16533
|
+
this.assertSameLifecycle(generation);
|
|
16534
|
+
await this.connect(generation);
|
|
16492
16535
|
this.log("debug", "Successfully reconnected to MCP server");
|
|
16493
16536
|
})();
|
|
16494
16537
|
this.reconnectPromise = reconnectPromise;
|
|
@@ -17958,6 +18001,11 @@ function cachedClient(id) {
|
|
|
17958
18001
|
return mcpClientInstances.get(id);
|
|
17959
18002
|
}
|
|
17960
18003
|
const TOOL_DISCOVERY_MAX_ATTEMPTS = 2;
|
|
18004
|
+
/**
|
|
18005
|
+
* `code` of the discovery error reported when a server exceeds `perServerTimeoutMs`.
|
|
18006
|
+
* The server's connect keeps running, so a later discovery can still succeed.
|
|
18007
|
+
*/
|
|
18008
|
+
const MCP_DISCOVERY_TIMEOUT_CODE = "MCP_DISCOVERY_TIMEOUT";
|
|
17961
18009
|
const LOOPBACK_IPV4 = /^127\.(?:\d{1,3})\.(?:\d{1,3})\.(?:\d{1,3})$/;
|
|
17962
18010
|
function isLoopbackHostname(hostname) {
|
|
17963
18011
|
return hostname === "localhost" || hostname === "[::1]" || hostname === "::1" || LOOPBACK_IPV4.test(hostname);
|
|
@@ -18737,14 +18785,14 @@ onListChanged: async (serverName, handler) => {
|
|
|
18737
18785
|
await client.connect();
|
|
18738
18786
|
return;
|
|
18739
18787
|
} catch (error) {
|
|
18740
|
-
if (!(error instanceof _modelcontextprotocol_client.UnauthorizedError)) throw this.handleConnectError(serverName, error);
|
|
18788
|
+
if (!(error instanceof _modelcontextprotocol_client.UnauthorizedError)) throw this.handleConnectError(serverName, error, client);
|
|
18741
18789
|
}
|
|
18742
18790
|
const { code, iss } = await callbackServer.waitForCode(options);
|
|
18743
18791
|
await client.finishAuth(code, iss);
|
|
18744
18792
|
try {
|
|
18745
18793
|
await client.connect();
|
|
18746
18794
|
} catch (error) {
|
|
18747
|
-
throw error instanceof _modelcontextprotocol_client.UnauthorizedError ? error : this.handleConnectError(serverName, error);
|
|
18795
|
+
throw error instanceof _modelcontextprotocol_client.UnauthorizedError ? error : this.handleConnectError(serverName, error, client);
|
|
18748
18796
|
}
|
|
18749
18797
|
} finally {
|
|
18750
18798
|
this.authCallbackServersByServer.delete(serverName);
|
|
@@ -19107,53 +19155,73 @@ onListChanged: async (serverName, handler) => {
|
|
|
19107
19155
|
* `prompts.list`.
|
|
19108
19156
|
*/
|
|
19109
19157
|
async discoverAcrossServers(operation, onError, options) {
|
|
19110
|
-
const
|
|
19111
|
-
|
|
19112
|
-
|
|
19113
|
-
|
|
19158
|
+
const only = options?.serverNames;
|
|
19159
|
+
const serverNames = Object.keys(this.serverConfigs).filter((name) => !only || only.includes(name));
|
|
19160
|
+
const onServerSettled = options?.onServerSettled;
|
|
19161
|
+
const notifySettled = (result) => {
|
|
19162
|
+
if (!onServerSettled) return result;
|
|
19163
|
+
const logCallbackError = (error) => {
|
|
19164
|
+
this.logger.error("MCP onServerSettled callback threw:", {
|
|
19165
|
+
serverName: result.serverName,
|
|
19166
|
+
error: error instanceof Error ? error.message : String(error)
|
|
19167
|
+
});
|
|
19168
|
+
};
|
|
19114
19169
|
try {
|
|
19115
|
-
const
|
|
19116
|
-
|
|
19117
|
-
|
|
19118
|
-
value: options?.perServerTimeoutMs === void 0 ? await operationPromise : await Promise.race([operationPromise, new Promise((_, reject) => {
|
|
19119
|
-
timer = setTimeout(() => reject(/* @__PURE__ */ new Error(`Discovery timed out after ${options.perServerTimeoutMs}ms`)), options.perServerTimeoutMs);
|
|
19120
|
-
timer.unref?.();
|
|
19121
|
-
})]),
|
|
19122
|
-
error: void 0,
|
|
19123
|
-
duration: performance.now() - startedAt
|
|
19124
|
-
};
|
|
19170
|
+
const { serverName, ...settled } = result;
|
|
19171
|
+
const outcome = onServerSettled(serverName, settled);
|
|
19172
|
+
if (outcome && typeof outcome.then === "function") Promise.resolve(outcome).catch(logCallbackError);
|
|
19125
19173
|
} catch (error) {
|
|
19126
|
-
|
|
19127
|
-
try {
|
|
19128
|
-
const mastraError = new _mastra_core_error.MastraError({
|
|
19129
|
-
id: onError.errorId,
|
|
19130
|
-
domain: _mastra_core_error.ErrorDomain.MCP,
|
|
19131
|
-
category: _mastra_core_error.ErrorCategory.THIRD_PARTY,
|
|
19132
|
-
details: { serverName }
|
|
19133
|
-
}, error);
|
|
19134
|
-
this.logger.trackException(mastraError);
|
|
19135
|
-
this.logger.error(onError.logMessage, { error: mastraError.toString() });
|
|
19136
|
-
} catch {
|
|
19137
|
-
const fallbackError = new _mastra_core_error.MastraError({
|
|
19138
|
-
id: onError.errorId,
|
|
19139
|
-
domain: _mastra_core_error.ErrorDomain.MCP,
|
|
19140
|
-
category: _mastra_core_error.ErrorCategory.THIRD_PARTY,
|
|
19141
|
-
text: discoveryError.message,
|
|
19142
|
-
details: { serverName }
|
|
19143
|
-
});
|
|
19144
|
-
this.logger.trackException(fallbackError);
|
|
19145
|
-
this.logger.error(onError.logMessage, { error: fallbackError.toString() });
|
|
19146
|
-
}
|
|
19147
|
-
return {
|
|
19148
|
-
serverName,
|
|
19149
|
-
value: void 0,
|
|
19150
|
-
error: discoveryError,
|
|
19151
|
-
duration: performance.now() - startedAt
|
|
19152
|
-
};
|
|
19153
|
-
} finally {
|
|
19154
|
-
clearTimeout(timer);
|
|
19174
|
+
logCallbackError(error);
|
|
19155
19175
|
}
|
|
19156
|
-
|
|
19176
|
+
return result;
|
|
19177
|
+
};
|
|
19178
|
+
return Promise.all(serverNames.map(async (serverName) => notifySettled(await this.discoverServer(serverName, operation, onError, options?.perServerTimeoutMs))));
|
|
19179
|
+
}
|
|
19180
|
+
async discoverServer(serverName, operation, onError, perServerTimeoutMs) {
|
|
19181
|
+
const startedAt = performance.now();
|
|
19182
|
+
let timer;
|
|
19183
|
+
try {
|
|
19184
|
+
const operationPromise = operation(serverName);
|
|
19185
|
+
return {
|
|
19186
|
+
serverName,
|
|
19187
|
+
value: perServerTimeoutMs === void 0 ? await operationPromise : await Promise.race([operationPromise, new Promise((_, reject) => {
|
|
19188
|
+
timer = setTimeout(() => reject(Object.assign(/* @__PURE__ */ new Error(`Discovery timed out after ${perServerTimeoutMs}ms`), { code: MCP_DISCOVERY_TIMEOUT_CODE })), perServerTimeoutMs);
|
|
19189
|
+
timer.unref?.();
|
|
19190
|
+
})]),
|
|
19191
|
+
error: void 0,
|
|
19192
|
+
duration: performance.now() - startedAt
|
|
19193
|
+
};
|
|
19194
|
+
} catch (error) {
|
|
19195
|
+
const discoveryError = getMCPDiscoveryErrorDetails(error);
|
|
19196
|
+
try {
|
|
19197
|
+
const mastraError = new _mastra_core_error.MastraError({
|
|
19198
|
+
id: onError.errorId,
|
|
19199
|
+
domain: _mastra_core_error.ErrorDomain.MCP,
|
|
19200
|
+
category: _mastra_core_error.ErrorCategory.THIRD_PARTY,
|
|
19201
|
+
details: { serverName }
|
|
19202
|
+
}, error);
|
|
19203
|
+
this.logger.trackException(mastraError);
|
|
19204
|
+
this.logger.error(onError.logMessage, { error: mastraError.toString() });
|
|
19205
|
+
} catch {
|
|
19206
|
+
const fallbackError = new _mastra_core_error.MastraError({
|
|
19207
|
+
id: onError.errorId,
|
|
19208
|
+
domain: _mastra_core_error.ErrorDomain.MCP,
|
|
19209
|
+
category: _mastra_core_error.ErrorCategory.THIRD_PARTY,
|
|
19210
|
+
text: discoveryError.message,
|
|
19211
|
+
details: { serverName }
|
|
19212
|
+
});
|
|
19213
|
+
this.logger.trackException(fallbackError);
|
|
19214
|
+
this.logger.error(onError.logMessage, { error: fallbackError.toString() });
|
|
19215
|
+
}
|
|
19216
|
+
return {
|
|
19217
|
+
serverName,
|
|
19218
|
+
value: void 0,
|
|
19219
|
+
error: discoveryError,
|
|
19220
|
+
duration: performance.now() - startedAt
|
|
19221
|
+
};
|
|
19222
|
+
} finally {
|
|
19223
|
+
clearTimeout(timer);
|
|
19224
|
+
}
|
|
19157
19225
|
}
|
|
19158
19226
|
/**
|
|
19159
19227
|
* Creates `MCPServerBase` proxy objects for each server connection in this
|
|
@@ -19238,12 +19306,12 @@ onListChanged: async (serverName, handler) => {
|
|
|
19238
19306
|
try {
|
|
19239
19307
|
await mcpClient.connect();
|
|
19240
19308
|
} catch (e) {
|
|
19241
|
-
throw this.handleConnectError(name, e);
|
|
19309
|
+
throw this.handleConnectError(name, e, mcpClient);
|
|
19242
19310
|
}
|
|
19243
19311
|
this.logger.debug("Connected to MCP server", { name });
|
|
19244
19312
|
return mcpClient;
|
|
19245
19313
|
}
|
|
19246
|
-
handleConnectError(name, error) {
|
|
19314
|
+
handleConnectError(name, error, client) {
|
|
19247
19315
|
const mastraError = new _mastra_core_error.MastraError({
|
|
19248
19316
|
id: "MCP_CLIENT_CONNECT_FAILED",
|
|
19249
19317
|
domain: _mastra_core_error.ErrorDomain.MCP,
|
|
@@ -19253,7 +19321,7 @@ onListChanged: async (serverName, handler) => {
|
|
|
19253
19321
|
}, error);
|
|
19254
19322
|
this.logger.trackException(mastraError);
|
|
19255
19323
|
this.logger.error("MCPClient errored connecting to MCP server:", { error: mastraError.toString() });
|
|
19256
|
-
if (!(error instanceof _modelcontextprotocol_client.UnauthorizedError)) this.mcpClientsById.delete(name);
|
|
19324
|
+
if (!(error instanceof _modelcontextprotocol_client.UnauthorizedError) && !client.hasPendingConnect() && this.mcpClientsById.get(name) === client) this.mcpClientsById.delete(name);
|
|
19257
19325
|
return mastraError;
|
|
19258
19326
|
}
|
|
19259
19327
|
async getConnectedClientForServer(serverName) {
|
|
@@ -22664,7 +22732,8 @@ var MCPServer = class extends _mastra_core_mcp.MCPServerBase {
|
|
|
22664
22732
|
tracingContext: {},
|
|
22665
22733
|
mastra: this.mastra,
|
|
22666
22734
|
logger: this.logger,
|
|
22667
|
-
description: "description" in tool ? tool.description : void 0
|
|
22735
|
+
description: "description" in tool ? tool.description : void 0,
|
|
22736
|
+
resolveExecuteFGA: ({ user, requestContext }) => this.toolFGACheck(name, user, requestContext)
|
|
22668
22737
|
});
|
|
22669
22738
|
converted[name] = {
|
|
22670
22739
|
...coreTool,
|
|
@@ -23977,37 +24046,49 @@ var MCPServer = class extends _mastra_core_mcp.MCPServerBase {
|
|
|
23977
24046
|
const fgaProvider = this.mastra?.getServer?.()?.fga;
|
|
23978
24047
|
if (!fgaProvider) return;
|
|
23979
24048
|
const { getMCPToolFGAResourceId, requireFGA, FGADeniedError, MastraFGAPermissions } = await import("@mastra/core/auth/ee");
|
|
23980
|
-
const resourceId = getMCPToolFGAResourceId(this.id, toolId);
|
|
23981
24049
|
const user = requestContext.get("user");
|
|
23982
24050
|
if (!user) throw new FGADeniedError({ id: "unknown" }, {
|
|
23983
24051
|
type: "tool",
|
|
23984
|
-
id:
|
|
24052
|
+
id: getMCPToolFGAResourceId(this.id, toolId)
|
|
23985
24053
|
}, MastraFGAPermissions.TOOLS_EXECUTE);
|
|
23986
|
-
const permission = this.fga?.permissionMapping?.[MastraFGAPermissions.TOOLS_EXECUTE] ?? MastraFGAPermissions.TOOLS_EXECUTE;
|
|
23987
|
-
const mapping = this.fga?.resourceMapping?.tool ?? this.fga?.resourceMapping?.tools;
|
|
23988
24054
|
await requireFGA({
|
|
23989
24055
|
fgaProvider,
|
|
23990
24056
|
user,
|
|
24057
|
+
requestContext,
|
|
24058
|
+
...await this.toolFGACheck(toolId, user, requestContext)
|
|
24059
|
+
});
|
|
24060
|
+
}
|
|
24061
|
+
/**
|
|
24062
|
+
* The check for one of this server's tools: its MCP tool resource, or the server's `fga` mapping.
|
|
24063
|
+
* The tools it builds run the same check, so they keep it when used outside the server, such as
|
|
24064
|
+
* through `tools()` on an agent.
|
|
24065
|
+
*/
|
|
24066
|
+
async toolFGACheck(toolId, user, requestContext) {
|
|
24067
|
+
const { getMCPToolFGAResourceId, MastraFGAPermissions } = await import("@mastra/core/auth/ee");
|
|
24068
|
+
const resourceId = getMCPToolFGAResourceId(this.id, toolId);
|
|
24069
|
+
const permission = this.fga?.permissionMapping?.[MastraFGAPermissions.TOOLS_EXECUTE] ?? MastraFGAPermissions.TOOLS_EXECUTE;
|
|
24070
|
+
const mapping = this.fga?.resourceMapping?.tool ?? this.fga?.resourceMapping?.tools;
|
|
24071
|
+
const derivedId = mapping && user ? mapping.deriveId?.({
|
|
24072
|
+
user,
|
|
24073
|
+
resourceId,
|
|
24074
|
+
requestContext
|
|
24075
|
+
}) : void 0;
|
|
24076
|
+
return {
|
|
23991
24077
|
resource: mapping ? {
|
|
23992
24078
|
type: mapping.fgaResourceType,
|
|
23993
|
-
id:
|
|
23994
|
-
user,
|
|
23995
|
-
resourceId,
|
|
23996
|
-
requestContext
|
|
23997
|
-
}) ?? resourceId
|
|
24079
|
+
id: derivedId ?? resourceId
|
|
23998
24080
|
} : {
|
|
23999
24081
|
type: "tool",
|
|
24000
24082
|
id: resourceId
|
|
24001
24083
|
},
|
|
24002
24084
|
permission,
|
|
24003
|
-
requestContext,
|
|
24004
24085
|
context: { resourceId },
|
|
24005
24086
|
metadata: {
|
|
24006
24087
|
mcpServerId: this.id,
|
|
24007
24088
|
mcpServerName: this.name,
|
|
24008
24089
|
toolId
|
|
24009
24090
|
}
|
|
24010
|
-
}
|
|
24091
|
+
};
|
|
24011
24092
|
}
|
|
24012
24093
|
async authorizedToolEntries(requestContext) {
|
|
24013
24094
|
const entries = Object.entries(this.convertedTools);
|
|
@@ -25146,6 +25227,7 @@ exports.MCPTaskLimitError = MCPTaskLimitError;
|
|
|
25146
25227
|
exports.MCP_CALL_TOOL_CONTENT = MCP_CALL_TOOL_CONTENT;
|
|
25147
25228
|
exports.MCP_CALL_TOOL_META = MCP_CALL_TOOL_META;
|
|
25148
25229
|
exports.MCP_CLIENT_PROTOCOL_VERSION = MCP_CLIENT_PROTOCOL_VERSION;
|
|
25230
|
+
exports.MCP_DISCOVERY_TIMEOUT_CODE = MCP_DISCOVERY_TIMEOUT_CODE;
|
|
25149
25231
|
exports.MCP_PROTOCOL_VERSION = MCP_PROTOCOL_VERSION;
|
|
25150
25232
|
exports.ServerEventActions = ServerEventActions;
|
|
25151
25233
|
exports.ServerPromptActions = ServerPromptActions;
|