@mastra/mcp 1.18.1-alpha.3 → 2.0.0-alpha.4
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/actions/resource.d.ts +9 -59
- package/dist/client/actions/resource.d.ts.map +1 -1
- package/dist/client/client.d.ts +71 -124
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/configuration.d.ts +30 -120
- package/dist/client/configuration.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/index.d.ts +2 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/oauth-callback-server.d.ts +8 -4
- package/dist/client/oauth-callback-server.d.ts.map +1 -1
- package/dist/client/oauth-provider.d.ts +91 -45
- package/dist/client/oauth-provider.d.ts.map +1 -1
- package/dist/client/server-proxy.d.ts +26 -46
- package/dist/client/server-proxy.d.ts.map +1 -1
- package/dist/client/types.d.ts +106 -143
- package/dist/client/types.d.ts.map +1 -1
- package/dist/conformance/fixture.d.ts +3 -0
- package/dist/conformance/fixture.d.ts.map +1 -0
- package/dist/conformance/run.d.ts +2 -0
- package/dist/conformance/run.d.ts.map +1 -0
- package/dist/conformance/stdio-server.d.ts +2 -0
- package/dist/conformance/stdio-server.d.ts.map +1 -0
- package/dist/docs/SKILL.md +2 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-migrations-mcp-v2.md +268 -0
- package/dist/docs/references/reference-tools-mcp-client.md +36 -14
- package/dist/docs/references/reference-tools-mcp-server.md +24 -83
- package/dist/index.cjs +1561 -3323
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1564 -3327
- package/dist/index.js.map +1 -1
- package/dist/server/actions.d.ts +34 -0
- package/dist/server/actions.d.ts.map +1 -0
- package/dist/server/oauth-middleware.d.ts +1 -1
- package/dist/server/request.d.ts +54 -0
- package/dist/server/request.d.ts.map +1 -0
- package/dist/server/server.d.ts +112 -808
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/types.d.ts +82 -138
- package/dist/server/types.d.ts.map +1 -1
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/oauth-types.d.ts +3 -3
- package/dist/shared/oauth-types.d.ts.map +1 -1
- package/dist/shared/trace-context.d.ts +20 -0
- package/dist/shared/trace-context.d.ts.map +1 -0
- package/package.json +11 -16
- package/dist/_types/hono/dist/types/client/client.d.ts +0 -4
- package/dist/_types/hono/dist/types/client/fetch-result-please.d.ts +0 -35
- package/dist/_types/hono/dist/types/client/index.d.ts +0 -7
- package/dist/_types/hono/dist/types/client/types.d.ts +0 -229
- package/dist/_types/hono/dist/types/client/utils.d.ts +0 -18
- package/dist/_types/hono/dist/types/context.d.ts +0 -459
- package/dist/_types/hono/dist/types/helper/streaming/index.d.ts +0 -8
- package/dist/_types/hono/dist/types/helper/streaming/sse.d.ts +0 -13
- package/dist/_types/hono/dist/types/helper/streaming/stream.d.ts +0 -3
- package/dist/_types/hono/dist/types/helper/streaming/text.d.ts +0 -3
- package/dist/_types/hono/dist/types/hono-base.d.ts +0 -221
- package/dist/_types/hono/dist/types/hono.d.ts +0 -19
- package/dist/_types/hono/dist/types/index.d.ts +0 -37
- package/dist/_types/hono/dist/types/request/constants.d.ts +0 -1
- package/dist/_types/hono/dist/types/request.d.ts +0 -324
- package/dist/_types/hono/dist/types/router.d.ts +0 -97
- package/dist/_types/hono/dist/types/types.d.ts +0 -573
- package/dist/_types/hono/dist/types/utils/body.d.ts +0 -79
- package/dist/_types/hono/dist/types/utils/headers.d.ts +0 -8
- package/dist/_types/hono/dist/types/utils/http-status.d.ts +0 -32
- package/dist/_types/hono/dist/types/utils/mime.d.ts +0 -70
- package/dist/_types/hono/dist/types/utils/stream.d.ts +0 -31
- package/dist/_types/hono/dist/types/utils/types.d.ts +0 -74
- package/dist/_types/hono/package.json +0 -1
- package/dist/_types/hono-mcp-server-sse-transport/build/index.d.ts +0 -1
- package/dist/_types/hono-mcp-server-sse-transport/build/sse.d.ts +0 -25
- package/dist/_types/hono-mcp-server-sse-transport/package.json +0 -1
- package/dist/client/actions/elicitation.d.ts +0 -63
- package/dist/client/actions/elicitation.d.ts.map +0 -1
- package/dist/server/__tests__/mock-extra.d.ts +0 -15
- package/dist/server/__tests__/mock-extra.d.ts.map +0 -1
- package/dist/server/mrtrElicitation.d.ts +0 -39
- package/dist/server/mrtrElicitation.d.ts.map +0 -1
- package/dist/server/notificationBroadcast.d.ts +0 -24
- package/dist/server/notificationBroadcast.d.ts.map +0 -1
- package/dist/server/promptActions.d.ts +0 -49
- package/dist/server/promptActions.d.ts.map +0 -1
- package/dist/server/resourceActions.d.ts +0 -72
- package/dist/server/resourceActions.d.ts.map +0 -1
- package/dist/server/toolActions.d.ts +0 -84
- package/dist/server/toolActions.d.ts.map +0 -1
|
@@ -102,75 +102,25 @@ export declare class ResourceClientActions {
|
|
|
102
102
|
})[];
|
|
103
103
|
}>;
|
|
104
104
|
/**
|
|
105
|
-
* Subscribes to
|
|
105
|
+
* Subscribes to update notifications for a resource. The client carries every
|
|
106
|
+
* subscription on one `subscriptions/listen` stream and reopens it after reconnects.
|
|
106
107
|
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
* @param uri - URI of the resource to subscribe to
|
|
111
|
-
* @returns Promise resolving when subscription is established
|
|
112
|
-
* @throws {Error} If subscription fails
|
|
108
|
+
* @param uri - URI of the resource to watch
|
|
109
|
+
* @throws {Error} If the server declines the subscription
|
|
113
110
|
*
|
|
114
111
|
* @example
|
|
115
112
|
* ```typescript
|
|
113
|
+
* await client.resources.onUpdated(({ uri }) => console.log(`updated ${uri}`));
|
|
116
114
|
* await client.resources.subscribe('file://data/config.json');
|
|
117
115
|
* ```
|
|
118
116
|
*/
|
|
119
|
-
subscribe(uri: string): Promise<
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
"io.modelcontextprotocol/serverInfo"?: {
|
|
123
|
-
version: string;
|
|
124
|
-
websiteUrl?: string | undefined;
|
|
125
|
-
description?: string | undefined;
|
|
126
|
-
icons?: {
|
|
127
|
-
src: string;
|
|
128
|
-
mimeType?: string | undefined;
|
|
129
|
-
sizes?: string[] | undefined;
|
|
130
|
-
theme?: "dark" | "light" | undefined;
|
|
131
|
-
}[] | undefined;
|
|
132
|
-
name: string;
|
|
133
|
-
title?: string | undefined;
|
|
134
|
-
} | undefined;
|
|
135
|
-
} | undefined;
|
|
136
|
-
}>;
|
|
137
|
-
/**
|
|
138
|
-
* Unsubscribes from updates for a specific resource.
|
|
139
|
-
*
|
|
140
|
-
* Stops receiving notifications for this resource URI.
|
|
141
|
-
*
|
|
142
|
-
* @param uri - URI of the resource to unsubscribe from
|
|
143
|
-
* @returns Promise resolving when unsubscription is complete
|
|
144
|
-
* @throws {Error} If unsubscription fails
|
|
145
|
-
*
|
|
146
|
-
* @example
|
|
147
|
-
* ```typescript
|
|
148
|
-
* await client.resources.unsubscribe('file://data/config.json');
|
|
149
|
-
* ```
|
|
150
|
-
*/
|
|
151
|
-
unsubscribe(uri: string): Promise<{
|
|
152
|
-
_meta?: {
|
|
153
|
-
[x: string]: unknown;
|
|
154
|
-
"io.modelcontextprotocol/serverInfo"?: {
|
|
155
|
-
version: string;
|
|
156
|
-
websiteUrl?: string | undefined;
|
|
157
|
-
description?: string | undefined;
|
|
158
|
-
icons?: {
|
|
159
|
-
src: string;
|
|
160
|
-
mimeType?: string | undefined;
|
|
161
|
-
sizes?: string[] | undefined;
|
|
162
|
-
theme?: "dark" | "light" | undefined;
|
|
163
|
-
}[] | undefined;
|
|
164
|
-
name: string;
|
|
165
|
-
title?: string | undefined;
|
|
166
|
-
} | undefined;
|
|
167
|
-
} | undefined;
|
|
168
|
-
}>;
|
|
117
|
+
subscribe(uri: string): Promise<void>;
|
|
118
|
+
/** Stops update notifications for a resource previously passed to {@link subscribe}. */
|
|
119
|
+
unsubscribe(uri: string): Promise<void>;
|
|
169
120
|
/**
|
|
170
121
|
* Sets a notification handler for when subscribed resources are updated.
|
|
171
122
|
*
|
|
172
|
-
*
|
|
173
|
-
* for any resource you've subscribed to.
|
|
123
|
+
* Updates arrive for resources passed to {@link subscribe}.
|
|
174
124
|
*
|
|
175
125
|
* @param handler - Callback function receiving the updated resource URI
|
|
176
126
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../../src/client/actions/resource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEnF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAEzD,UAAU,2BAA2B;IACnC,MAAM,EAAE,uBAAuB,CAAC;IAChC,MAAM,EAAE,aAAa,CAAC;CACvB;AAED;;;;;;GAMG;AACH,qBAAa,qBAAqB;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0B;IACjD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;IAEvC;;OAEG;IACH,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,2BAA2B,EAG1D;IAED;;;;;;;;;;;;;;;OAeG;IACU,IAAI,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC,CAyBvC;IAED;;;;;;;;;;;;;;;;OAgBG;IACU,SAAS,IAAI,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAyBxD;IAED;;;;;;;;;;;;OAYG;IACU,IAAI,CAAC,GAAG,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAE5B;IAED
|
|
1
|
+
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../../src/client/actions/resource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EA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
import { MastraBase } from '@mastra/core/base';
|
|
3
3
|
import type { Tool } from '@mastra/core/tools';
|
|
4
|
-
import type {
|
|
5
|
-
import { ElicitationClientActions } from './actions/elicitation.js';
|
|
4
|
+
import type { GetPromptResult, ListPromptsResult, ListResourcesResult, ListResourceTemplatesResult, ReadResourceResult } from '@modelcontextprotocol/client';
|
|
6
5
|
import { ProgressClientActions } from './actions/progress.js';
|
|
7
6
|
import { PromptClientActions } from './actions/prompt.js';
|
|
8
7
|
import { ResourceClientActions } from './actions/resource.js';
|
|
9
|
-
import type {
|
|
10
|
-
export type { LoggingLevel, LogMessage, LogHandler,
|
|
8
|
+
import type { ProgressHandler, InternalMastraMCPClientOptions, SerializableMCPToolDefinition } from './types.js';
|
|
9
|
+
export type { LoggingLevel, LogMessage, LogHandler, ProgressHandler, MastraFetchLike, MastraMCPServerDefinition, MCPClientCapabilities, MCPClientProtocolVersion, MCPInputRequest, MCPInputRequestHandler, InternalMastraMCPClientOptions, RequireToolApproval, RequireToolApprovalFn, RequireToolApprovalContext, SerializableMCPToolDefinition, } from './types.js';
|
|
11
10
|
/**
|
|
12
11
|
* OAuth authorization state of an MCP server connection.
|
|
13
12
|
*
|
|
@@ -50,8 +49,12 @@ export declare function getMcpCallToolMeta(output: unknown): Record<string, unkn
|
|
|
50
49
|
/**
|
|
51
50
|
* Internal MCP client implementation for connecting to a single MCP server.
|
|
52
51
|
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
52
|
+
* Probes the server with `server/discover` unless `protocolVersion` pins a
|
|
53
|
+
* revision, then speaks whichever revision was negotiated. On 2026-07-28 there is
|
|
54
|
+
* no session, embedded input requests are answered through the configured
|
|
55
|
+
* `inputRequests` handler, and change notifications arrive on one managed
|
|
56
|
+
* `subscriptions/listen` stream (see {@link subscribeResource}). Those two
|
|
57
|
+
* facilities fail on a legacy negotiation; everything else works on either revision.
|
|
55
58
|
*
|
|
56
59
|
* @internal
|
|
57
60
|
*/
|
|
@@ -60,8 +63,8 @@ export declare class InternalMastraMCPClient extends MastraBase {
|
|
|
60
63
|
private client;
|
|
61
64
|
private readonly timeout;
|
|
62
65
|
private logHandler?;
|
|
63
|
-
private
|
|
64
|
-
private enableProgressTracking
|
|
66
|
+
private readonly serverLogLevel?;
|
|
67
|
+
private enableProgressTracking;
|
|
65
68
|
private serverConfig;
|
|
66
69
|
private transport?;
|
|
67
70
|
private pendingAuthTransport?;
|
|
@@ -73,68 +76,32 @@ export declare class InternalMastraMCPClient extends MastraBase {
|
|
|
73
76
|
private sigTermHandler?;
|
|
74
77
|
private sigHupHandler?;
|
|
75
78
|
private serverInstructions?;
|
|
76
|
-
|
|
77
|
-
private
|
|
79
|
+
/** The verdict of the last successful probe, reused so reconnects skip it. */
|
|
80
|
+
private priorDiscovery?;
|
|
78
81
|
private readonly requireToolApproval;
|
|
79
82
|
private readonly onToolError;
|
|
80
|
-
|
|
83
|
+
private jsonSchemaValidator?;
|
|
84
|
+
private jsonSchemaValidatorPromise?;
|
|
85
|
+
/** Provides access to resource operations (list, read, notifications) */
|
|
81
86
|
readonly resources: ResourceClientActions;
|
|
82
87
|
/** Provides access to prompt operations (list, get, notifications) */
|
|
83
88
|
readonly prompts: PromptClientActions;
|
|
84
|
-
/** Provides access to elicitation operations (request handling) */
|
|
85
|
-
readonly elicitation: ElicitationClientActions;
|
|
86
89
|
/** Provides access to progress operations (notifications) */
|
|
87
90
|
readonly progress: ProgressClientActions;
|
|
88
91
|
/**
|
|
89
92
|
* @internal
|
|
90
93
|
*/
|
|
91
|
-
constructor({ name, version, server,
|
|
94
|
+
constructor({ name, version, server, timeout }: InternalMastraMCPClientOptions);
|
|
92
95
|
/**
|
|
93
96
|
* Log a message at the specified level
|
|
94
|
-
* @param level Log level
|
|
95
|
-
* @param message Log message
|
|
96
|
-
* @param details Optional additional details
|
|
97
97
|
*/
|
|
98
98
|
private log;
|
|
99
|
-
private setupLogging;
|
|
100
99
|
/**
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
* When a server sends a roots/list request, the client responds with the configured roots.
|
|
105
|
-
*/
|
|
106
|
-
private setupRootsHandler;
|
|
107
|
-
/**
|
|
108
|
-
* Get the currently configured roots.
|
|
109
|
-
*
|
|
110
|
-
* @returns Array of configured filesystem roots
|
|
100
|
+
* Request metadata every outgoing request carries: the per-request log-level
|
|
101
|
+
* opt-in (when enabled) and the W3C trace fields resolved for this request,
|
|
102
|
+
* merged under caller-supplied keys.
|
|
111
103
|
*/
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Update the list of filesystem roots and notify the server.
|
|
115
|
-
*
|
|
116
|
-
* Per MCP spec, when roots change, the client sends a `notifications/roots/list_changed`
|
|
117
|
-
* notification to inform the server that it should re-fetch the roots list.
|
|
118
|
-
*
|
|
119
|
-
* @param roots - New list of filesystem roots
|
|
120
|
-
*
|
|
121
|
-
* @example
|
|
122
|
-
* ```typescript
|
|
123
|
-
* await client.setRoots([
|
|
124
|
-
* { uri: 'file:///home/user/projects', name: 'Projects' },
|
|
125
|
-
* { uri: 'file:///tmp', name: 'Temp' }
|
|
126
|
-
* ]);
|
|
127
|
-
* ```
|
|
128
|
-
*/
|
|
129
|
-
setRoots(roots: Root[]): Promise<void>;
|
|
130
|
-
/**
|
|
131
|
-
* Send a roots/list_changed notification to the server.
|
|
132
|
-
*
|
|
133
|
-
* Per MCP spec, clients that support `listChanged` MUST send this notification
|
|
134
|
-
* when the list of roots changes. The server will then call roots/list to get
|
|
135
|
-
* the updated list.
|
|
136
|
-
*/
|
|
137
|
-
sendRootsListChanged(): Promise<void>;
|
|
104
|
+
private requestMeta;
|
|
138
105
|
private buildStdioEnv;
|
|
139
106
|
private connectStdio;
|
|
140
107
|
private connectHttp;
|
|
@@ -142,27 +109,21 @@ export declare class InternalMastraMCPClient extends MastraBase {
|
|
|
142
109
|
* Detaches whatever transport is still attached to the underlying SDK Client.
|
|
143
110
|
*
|
|
144
111
|
* The SDK assigns its internal `_transport` before `transport.start()` and never
|
|
145
|
-
* clears it when `start()` throws,
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
* own `this.transport` is only assigned after a successful connect, so
|
|
150
|
-
* disconnect/forceReconnect never see the stale one. Calling this before every
|
|
151
|
-
* connect attempt restores the invariant that a connect starts from a detached
|
|
152
|
-
* SDK client.
|
|
112
|
+
* clears it when `start()` throws, so a stale transport can remain attached and
|
|
113
|
+
* make every subsequent `client.connect()` throw "Already connected to a
|
|
114
|
+
* transport". Mastra's own `this.transport` is only assigned after a successful
|
|
115
|
+
* connect, so disconnect/forceReconnect never see the stale one.
|
|
153
116
|
*/
|
|
154
117
|
private detachStaleClientTransport;
|
|
155
118
|
/**
|
|
156
119
|
* Severs the mutual references between the SDK client and a stale transport
|
|
157
|
-
* without closing it
|
|
158
|
-
*
|
|
159
|
-
* the state of a newer live connection.
|
|
120
|
+
* without closing it, so a later close() of the stale transport cannot reach
|
|
121
|
+
* into the SDK client and clear the state of a newer live connection.
|
|
160
122
|
*/
|
|
161
123
|
private severClientTransportLink;
|
|
162
124
|
/**
|
|
163
125
|
* Closes and clears any transport retained from an unfinished authorization
|
|
164
|
-
* flow. Safe to call when nothing is pending.
|
|
165
|
-
* success, disconnect, and forceReconnect all release the same resource.
|
|
126
|
+
* flow. Safe to call when nothing is pending.
|
|
166
127
|
*/
|
|
167
128
|
private closePendingAuthTransport;
|
|
168
129
|
/**
|
|
@@ -181,68 +142,55 @@ export declare class InternalMastraMCPClient extends MastraBase {
|
|
|
181
142
|
*
|
|
182
143
|
* Exchanges the authorization code captured at the redirect URI on the same
|
|
183
144
|
* transport that started the flow, then leaves the client ready to connect().
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
* @throws {Error} If no authorization flow is pending for this server
|
|
145
|
+
* The RFC 9207 `iss` captured at the redirect is validated against the
|
|
146
|
+
* discovered authorization server before the code is exchanged.
|
|
187
147
|
*
|
|
188
148
|
* @internal
|
|
189
149
|
*/
|
|
190
|
-
finishAuth(authorizationCode: string): Promise<void>;
|
|
150
|
+
finishAuth(authorizationCode: string, issuer?: string): Promise<void>;
|
|
191
151
|
private isConnected;
|
|
192
152
|
private reconnectPromise;
|
|
153
|
+
/**
|
|
154
|
+
* Change notifications the caller has asked for. The client keeps exactly one
|
|
155
|
+
* `subscriptions/listen` stream open for this interest set, replaces it when the
|
|
156
|
+
* set changes and reopens it after a reconnect.
|
|
157
|
+
*/
|
|
158
|
+
private subscriptionInterest;
|
|
159
|
+
private subscriptionStream?;
|
|
160
|
+
private subscriptionUpdate;
|
|
193
161
|
private lifecycleGeneration;
|
|
194
162
|
/**
|
|
195
163
|
* Connects to the MCP server using the configured transport.
|
|
196
164
|
*
|
|
197
|
-
* Automatically detects transport type based on configuration (stdio vs HTTP).
|
|
198
165
|
* Safe to call multiple times - returns existing connection if already connected.
|
|
199
166
|
*
|
|
200
|
-
* @returns Promise resolving to true when connected
|
|
201
|
-
* @throws {MastraError} If connection fails
|
|
202
|
-
*
|
|
203
167
|
* @internal
|
|
204
168
|
*/
|
|
205
169
|
connect(): Promise<boolean>;
|
|
206
|
-
/**
|
|
207
|
-
* Gets the current session ID if using Streamable HTTP transport.
|
|
208
|
-
*
|
|
209
|
-
* Returns undefined if not connected or not using Streamable HTTP transport.
|
|
210
|
-
*
|
|
211
|
-
* @returns Session ID string or undefined
|
|
212
|
-
*
|
|
213
|
-
* @internal
|
|
214
|
-
*/
|
|
215
|
-
get sessionId(): string | undefined;
|
|
216
170
|
/**
|
|
217
171
|
* Gets the stderr stream of the child process, if using stdio transport with `stderr: 'pipe'`.
|
|
218
172
|
*
|
|
219
|
-
* Returns null if not connected, not using stdio transport, or stderr is not piped.
|
|
220
|
-
*
|
|
221
173
|
* @internal
|
|
222
174
|
*/
|
|
223
175
|
get stderr(): Stream | null;
|
|
224
176
|
get instructions(): string | undefined;
|
|
177
|
+
/** The protocol revision negotiated with the server; `undefined` until connected. */
|
|
178
|
+
get negotiatedProtocolVersion(): string | undefined;
|
|
179
|
+
private rememberNegotiation;
|
|
180
|
+
/** Fails a call that only the 2026-07-28 revision supports when the server negotiated an older one. */
|
|
181
|
+
private assertCurrentRevision;
|
|
225
182
|
get forwardInstructions(): boolean;
|
|
226
183
|
get instructionsMaxLength(): number;
|
|
227
|
-
private refreshServerInstructions;
|
|
228
184
|
disconnect(): Promise<void>;
|
|
229
185
|
/**
|
|
230
186
|
* Forces a reconnection to the MCP server by disconnecting and reconnecting.
|
|
231
187
|
*
|
|
232
|
-
* This is useful when the session becomes invalid (e.g., after server restart)
|
|
233
|
-
* and the client needs to establish a fresh connection.
|
|
234
|
-
*
|
|
235
|
-
* @returns Promise resolving when reconnection is complete
|
|
236
|
-
* @throws {Error} If reconnection fails
|
|
237
|
-
*
|
|
238
188
|
* @internal
|
|
239
189
|
*/
|
|
240
190
|
forceReconnect(): Promise<void>;
|
|
241
191
|
private reconnectAfterTransportFailure;
|
|
242
192
|
listResources(): Promise<ListResourcesResult>;
|
|
243
193
|
readResource(uri: string): Promise<ReadResourceResult>;
|
|
244
|
-
subscribeResource(uri: string): Promise<EmptyResult>;
|
|
245
|
-
unsubscribeResource(uri: string): Promise<EmptyResult>;
|
|
246
194
|
listResourceTemplates(): Promise<ListResourceTemplatesResult>;
|
|
247
195
|
/**
|
|
248
196
|
* Fetch the list of available prompts from the MCP server.
|
|
@@ -250,27 +198,40 @@ export declare class InternalMastraMCPClient extends MastraBase {
|
|
|
250
198
|
listPrompts(): Promise<ListPromptsResult>;
|
|
251
199
|
/**
|
|
252
200
|
* Get a prompt and its dynamic messages from the server.
|
|
253
|
-
* @param name The prompt name
|
|
254
|
-
* @param args Arguments for the prompt
|
|
255
201
|
*/
|
|
256
202
|
getPrompt({ name, args }: {
|
|
257
203
|
name: string;
|
|
258
204
|
args?: Record<string, any>;
|
|
259
205
|
}): Promise<GetPromptResult>;
|
|
206
|
+
private hasSubscriptionInterest;
|
|
207
|
+
private subscriptionFilter;
|
|
208
|
+
/** Serializes stream replacements so concurrent mutations apply in order. */
|
|
209
|
+
private enqueueSubscriptionUpdate;
|
|
260
210
|
/**
|
|
261
|
-
*
|
|
262
|
-
*
|
|
211
|
+
* Opens a `subscriptions/listen` stream for the current interest set, then closes the
|
|
212
|
+
* previous one so no notification is lost between filters. Resource subscriptions the
|
|
213
|
+
* server declines are an error; declined list-changed bits only mean the server has
|
|
214
|
+
* nothing to announce.
|
|
263
215
|
*/
|
|
264
|
-
|
|
216
|
+
private replaceSubscriptionStream;
|
|
217
|
+
private closeSubscriptionStream;
|
|
218
|
+
/** Applies an interest change to the live stream when connected; otherwise connect() opens it. */
|
|
219
|
+
private applySubscriptionInterest;
|
|
265
220
|
/**
|
|
266
|
-
*
|
|
267
|
-
*
|
|
221
|
+
* Subscribes to `notifications/resources/updated` for a resource. The subscription is
|
|
222
|
+
* carried on the client's single `subscriptions/listen` stream and survives reconnects.
|
|
268
223
|
*/
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
224
|
+
subscribeResource(uri: string): Promise<void>;
|
|
225
|
+
unsubscribeResource(uri: string): Promise<void>;
|
|
226
|
+
private updateResourceSubscriptions;
|
|
227
|
+
setPromptListChangedNotificationHandler(handler: () => void): Promise<void>;
|
|
228
|
+
setToolListChangedNotificationHandler(handler: () => void): Promise<void>;
|
|
229
|
+
setResourceUpdatedNotificationHandler(handler: (params: {
|
|
230
|
+
uri: string;
|
|
231
|
+
}) => void): void;
|
|
232
|
+
setResourceListChangedNotificationHandler(handler: () => void): Promise<void>;
|
|
273
233
|
setProgressNotificationHandler(handler: ProgressHandler): void;
|
|
234
|
+
private getJsonSchemaValidator;
|
|
274
235
|
private convertInputSchema;
|
|
275
236
|
/**
|
|
276
237
|
* Wraps the output schema with a validator that always succeeds. The tool's execute wrapper
|
|
@@ -283,34 +244,20 @@ export declare class InternalMastraMCPClient extends MastraBase {
|
|
|
283
244
|
private convertOutputSchema;
|
|
284
245
|
/**
|
|
285
246
|
* Returns the server's tool catalog as plain, serializable definitions.
|
|
286
|
-
*
|
|
287
|
-
* Unlike {@link tools}, this performs no schema conversion and creates no executable
|
|
288
|
-
* wrappers, so the result can be cached and reused by other processes. Pass a definition
|
|
289
|
-
* back to {@link toolFromDefinition} to rebuild the executable tool without rediscovery.
|
|
290
247
|
*/
|
|
291
248
|
toolDefinitions(): Promise<Record<string, SerializableMCPToolDefinition>>;
|
|
292
|
-
/**
|
|
293
|
-
* Captures a `tools/list` entry plus the server metadata that is only reachable from a live
|
|
294
|
-
* connection, so a hydrated tool is indistinguishable from a freshly discovered one.
|
|
295
|
-
*/
|
|
296
249
|
private toSerializableDefinition;
|
|
297
250
|
/**
|
|
298
251
|
* Rebuilds an executable Mastra tool from a cached {@link SerializableMCPToolDefinition}.
|
|
299
|
-
*
|
|
300
|
-
* No connection is opened here. The client connects lazily, the first time the returned tool
|
|
301
|
-
* is actually executed, which is what makes a cached catalog useful for cold starts.
|
|
252
|
+
* The client connects lazily on the first execution.
|
|
302
253
|
*/
|
|
303
254
|
toolFromDefinition({ definition }: {
|
|
304
255
|
definition: SerializableMCPToolDefinition;
|
|
305
256
|
}): Tool<any, any, any, any>;
|
|
306
257
|
tools(): Promise<Record<string, Tool<any, any, any, any>>>;
|
|
307
258
|
/**
|
|
308
|
-
* Single conversion path shared by live discovery and cached hydration
|
|
309
|
-
*
|
|
310
|
-
* Keeping both callers on this one method is what guarantees the issue's requirement that
|
|
311
|
-
* hydrated tools behave identically to discovered ones: strict-mode metadata, approval
|
|
312
|
-
* policies, structured content, in-band tool errors, progress metadata, abort signals and
|
|
313
|
-
* reconnect/retry all come from here rather than being reimplemented per call site.
|
|
259
|
+
* Single conversion path shared by live discovery and cached hydration, so hydrated
|
|
260
|
+
* tools behave identically to discovered ones.
|
|
314
261
|
*/
|
|
315
262
|
private buildToolFromListEntry;
|
|
316
263
|
private stampServerIdInMeta;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAE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