@mastra/mcp 1.16.0-alpha.0 → 1.16.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/CHANGELOG.md +39 -0
- package/dist/client/client.d.ts +38 -2
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/configuration.d.ts +73 -0
- package/dist/client/configuration.d.ts.map +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/types.d.ts +46 -0
- package/dist/client/types.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 +51 -0
- package/dist/index.cjs +9577 -9389
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +9577 -9390
- package/dist/index.js.map +1 -1
- package/dist/server/server.d.ts.map +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# @mastra/mcp
|
|
2
2
|
|
|
3
|
+
## 1.16.0-alpha.2
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Add serializable MCP tool definitions and lazy hydration. ([#21119](https://github.com/mastra-ai/mastra/pull/21119))
|
|
8
|
+
|
|
9
|
+
`MCPClient` can now export its tool catalog as plain JSON and rebuild executable tools from it later, without reconnecting at startup. This removes the need to connect to every MCP server on every cold start just to discover tools that may never be called.
|
|
10
|
+
|
|
11
|
+
- `listToolDefinitions()` returns definitions grouped by server and keyed by tool name. The result is JSON-serializable, so it can be cached in Redis, a database, or a build artifact.
|
|
12
|
+
- `listToolDefinitionsWithErrors()` also reports per-server failures, so a partial catalog isn't cached silently.
|
|
13
|
+
- `toolFromDefinition({ serverName, definition })` rebuilds a single tool from a cached definition.
|
|
14
|
+
- `toolsFromDefinitions({ definitions })` rebuilds a whole namespaced tool map, matching the `serverName_toolName` keys from `listTools()`.
|
|
15
|
+
|
|
16
|
+
Hydrated tools connect lazily on first execution and behave the same as discovered tools, including strict-mode metadata, approval policies, structured content, tool error handling, progress metadata, abort signals, and reconnect and retry behavior. Definitions capture the server version and instructions recorded at discovery time so that metadata isn't lost.
|
|
17
|
+
|
|
18
|
+
Existing `listTools()` and `listToolsets()` behavior is unchanged.
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [[`b8ce7ec`](https://github.com/mastra-ai/mastra/commit/b8ce7ec96e39343c6c2f36d12d68a9ad816c09f7), [`a3a3624`](https://github.com/mastra-ai/mastra/commit/a3a3624f646b98e409424d8defccbd334da9e8b8), [`6246914`](https://github.com/mastra-ai/mastra/commit/62469146636911f3cbbe0880bd011c6a897a59a7), [`3f73c07`](https://github.com/mastra-ai/mastra/commit/3f73c076727e8c36b4fff7a1b40290fb68957fa8), [`7c1ebb1`](https://github.com/mastra-ai/mastra/commit/7c1ebb15690c4b3f0eabb19077cf8af573311e57), [`32980a3`](https://github.com/mastra-ai/mastra/commit/32980a3e2413d0274ac244d32c37d910edc13f00), [`4bcdfaf`](https://github.com/mastra-ai/mastra/commit/4bcdfaf0eac3199d7cb171b0a19a92c9c341eea4), [`af4636a`](https://github.com/mastra-ai/mastra/commit/af4636a74463275d71c1d13a38f7d2b738f128bf), [`a463cdf`](https://github.com/mastra-ai/mastra/commit/a463cdf1c95c3059e70f0bff27959e8558bb899d), [`0ea6b80`](https://github.com/mastra-ai/mastra/commit/0ea6b8001408ce02b56e8be0536b0fd8cbaf8ad2)]:
|
|
23
|
+
- @mastra/core@1.58.0-alpha.11
|
|
24
|
+
|
|
25
|
+
## 1.16.0-alpha.1
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- **Fixed spurious MCP reconnects when tool-execution errors contain transport-like substrings.** ([#20793](https://github.com/mastra-ai/mastra/pull/20793))
|
|
30
|
+
|
|
31
|
+
When an MCP tool returns an in-band error (\`isError: true\`) whose text contains words like "session", "404", or "connection closed", the client no longer misclassifies it as a transport failure and triggers a reconnect + retry. This prevents duplicate calls for non-idempotent tools (e.g. payments, writes).
|
|
32
|
+
|
|
33
|
+
**Surface the real failure after a failed reconnect.**
|
|
34
|
+
|
|
35
|
+
When a transport-level reconnect fails, the caller now receives the actual reconnection error instead of the stale tool/transport error that triggered the recovery attempt.
|
|
36
|
+
|
|
37
|
+
- Fixed MCP tools with outputSchema to send LLM-facing content text to the model via toModelOutput while keeping structuredContent on tool.execute() results. ([#20176](https://github.com/mastra-ai/mastra/pull/20176))
|
|
38
|
+
|
|
39
|
+
- Updated dependencies [[`cdd5c33`](https://github.com/mastra-ai/mastra/commit/cdd5c33ac6c7118a9f139e6dc0e14e6a8ae31658), [`d7cf7fa`](https://github.com/mastra-ai/mastra/commit/d7cf7fafc1ae1b50bd8462dd0e6c671a8606db93), [`0f9a448`](https://github.com/mastra-ai/mastra/commit/0f9a448502157e59f7b76f24360ad497168f5ef8), [`289f4ce`](https://github.com/mastra-ai/mastra/commit/289f4ce16e3293370440172132c52ee787cbc09f), [`4f16ff8`](https://github.com/mastra-ai/mastra/commit/4f16ff824bf2f9b0ddc93f210477c10c8a4fb1ab), [`1c67d85`](https://github.com/mastra-ai/mastra/commit/1c67d85e9da8285662f4dbbf47e0378c3fee0747), [`ba24be6`](https://github.com/mastra-ai/mastra/commit/ba24be662439c331ab23a600041f93803c89eca8), [`842b5fe`](https://github.com/mastra-ai/mastra/commit/842b5fe22b6a7fa811bd14e48eb9af523ac989f2), [`80bdf3a`](https://github.com/mastra-ai/mastra/commit/80bdf3ae16ade6ff63bde0cb16fa2df8ab7dd4dd), [`9ba1247`](https://github.com/mastra-ai/mastra/commit/9ba12470c77f1c03642d720ce67e517e878f666e), [`fd96298`](https://github.com/mastra-ai/mastra/commit/fd96298a8367622f4ebfcaa97b5b6c1fbbd14564), [`6a84954`](https://github.com/mastra-ai/mastra/commit/6a84954a2667f85b6d59da652dab1bbff007ccb0), [`52d8ef0`](https://github.com/mastra-ai/mastra/commit/52d8ef03801f1deb7ee48532fc4190dd4a33916c), [`cdd5c33`](https://github.com/mastra-ai/mastra/commit/cdd5c33ac6c7118a9f139e6dc0e14e6a8ae31658), [`efd5c81`](https://github.com/mastra-ai/mastra/commit/efd5c81cc25fde3c2ddd86fc1178deb4ec176e19), [`0976933`](https://github.com/mastra-ai/mastra/commit/0976933142333ec78451feef265b68bcb45aa5e7), [`242b945`](https://github.com/mastra-ai/mastra/commit/242b94558777bfbdeb42cbfea84afff0b6ad0633), [`fea5cae`](https://github.com/mastra-ai/mastra/commit/fea5caedc7e2cfea51784a15e015952692027abf), [`4b59f78`](https://github.com/mastra-ai/mastra/commit/4b59f786cbc9a7d1ef07a07517dbd4b96865e99d), [`7010c5d`](https://github.com/mastra-ai/mastra/commit/7010c5d15728bf9c5dfe4fb6b1bf80ce23bf143a)]:
|
|
40
|
+
- @mastra/core@1.58.0-alpha.3
|
|
41
|
+
|
|
3
42
|
## 1.16.0-alpha.0
|
|
4
43
|
|
|
5
44
|
### Minor Changes
|
package/dist/client/client.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ import { ElicitationClientActions } from './actions/elicitation.js';
|
|
|
6
6
|
import { ProgressClientActions } from './actions/progress.js';
|
|
7
7
|
import { PromptClientActions } from './actions/prompt.js';
|
|
8
8
|
import { ResourceClientActions } from './actions/resource.js';
|
|
9
|
-
import type { ElicitationHandler, ProgressHandler, InternalMastraMCPClientOptions, Root } from './types.js';
|
|
10
|
-
export type { LoggingLevel, LogMessage, LogHandler, ElicitationHandler, ProgressHandler, MastraFetchLike, MastraMCPServerDefinition, InternalMastraMCPClientOptions, Root, RequireToolApproval, RequireToolApprovalFn, RequireToolApprovalContext, } from './types.js';
|
|
9
|
+
import type { ElicitationHandler, ProgressHandler, InternalMastraMCPClientOptions, Root, SerializableMCPToolDefinition } from './types.js';
|
|
10
|
+
export type { LoggingLevel, LogMessage, LogHandler, ElicitationHandler, ProgressHandler, MastraFetchLike, MastraMCPServerDefinition, InternalMastraMCPClientOptions, Root, RequireToolApproval, RequireToolApprovalFn, RequireToolApprovalContext, SerializableMCPToolDefinition, } from './types.js';
|
|
11
11
|
/**
|
|
12
12
|
* OAuth authorization state of an MCP server connection.
|
|
13
13
|
*
|
|
@@ -18,6 +18,11 @@ export type { LoggingLevel, LogMessage, LogHandler, ElicitationHandler, Progress
|
|
|
18
18
|
* Servers without an authProvider never carry an auth state.
|
|
19
19
|
*/
|
|
20
20
|
export type MCPServerAuthState = 'needs-auth' | 'authorized';
|
|
21
|
+
/**
|
|
22
|
+
* Non-enumerable metadata attached to structured tool execute results so
|
|
23
|
+
* `toModelOutput` can read MCP `content` without changing the execute return shape.
|
|
24
|
+
*/
|
|
25
|
+
export declare const MCP_CALL_TOOL_CONTENT: unique symbol;
|
|
21
26
|
/**
|
|
22
27
|
* Internal MCP client implementation for connecting to a single MCP server.
|
|
23
28
|
*
|
|
@@ -248,7 +253,38 @@ export declare class InternalMastraMCPClient extends MastraBase {
|
|
|
248
253
|
* structuredContent via AJV; the JSON schema is surfaced here for documentation only.
|
|
249
254
|
*/
|
|
250
255
|
private convertOutputSchema;
|
|
256
|
+
/**
|
|
257
|
+
* Returns the server's tool catalog as plain, serializable definitions.
|
|
258
|
+
*
|
|
259
|
+
* Unlike {@link tools}, this performs no schema conversion and creates no executable
|
|
260
|
+
* wrappers, so the result can be cached and reused by other processes. Pass a definition
|
|
261
|
+
* back to {@link toolFromDefinition} to rebuild the executable tool without rediscovery.
|
|
262
|
+
*/
|
|
263
|
+
toolDefinitions(): Promise<Record<string, SerializableMCPToolDefinition>>;
|
|
264
|
+
/**
|
|
265
|
+
* Captures a `tools/list` entry plus the server metadata that is only reachable from a live
|
|
266
|
+
* connection, so a hydrated tool is indistinguishable from a freshly discovered one.
|
|
267
|
+
*/
|
|
268
|
+
private toSerializableDefinition;
|
|
269
|
+
/**
|
|
270
|
+
* Rebuilds an executable Mastra tool from a cached {@link SerializableMCPToolDefinition}.
|
|
271
|
+
*
|
|
272
|
+
* No connection is opened here. The client connects lazily, the first time the returned tool
|
|
273
|
+
* is actually executed, which is what makes a cached catalog useful for cold starts.
|
|
274
|
+
*/
|
|
275
|
+
toolFromDefinition({ definition }: {
|
|
276
|
+
definition: SerializableMCPToolDefinition;
|
|
277
|
+
}): Tool<any, any, any, any>;
|
|
251
278
|
tools(): Promise<Record<string, Tool<any, any, any, any>>>;
|
|
279
|
+
/**
|
|
280
|
+
* Single conversion path shared by live discovery and cached hydration.
|
|
281
|
+
*
|
|
282
|
+
* Keeping both callers on this one method is what guarantees the issue's requirement that
|
|
283
|
+
* hydrated tools behave identically to discovered ones: strict-mode metadata, approval
|
|
284
|
+
* policies, structured content, in-band tool errors, progress metadata, abort signals and
|
|
285
|
+
* reconnect/retry all come from here rather than being reimplemented per call site.
|
|
286
|
+
*/
|
|
287
|
+
private buildToolFromListEntry;
|
|
252
288
|
private stampServerIdInMeta;
|
|
253
289
|
}
|
|
254
290
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -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;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI/C,OAAO,KAAK,EAAmB,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAUhE,OAAO,KAAK,EAEV,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,2BAA2B,EAE3B,kBAAkB,EAEnB,MAAM,8BAA8B,CAAC;AAKtC,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC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C,CAAC;IAmBhE;;;;;;;OAOG;IACH,OAAO,CAAC,sBAAsB;IAkN9B,OAAO,CAAC,mBAAmB;CAQ5B"}
|
|
@@ -4,6 +4,7 @@ import type { MCPServerBase } from '@mastra/core/mcp';
|
|
|
4
4
|
import type { Tool } from '@mastra/core/tools';
|
|
5
5
|
import type { ElicitRequest, ElicitResult, ProgressNotification, Prompt, Resource, ResourceTemplateType } from '@modelcontextprotocol/client';
|
|
6
6
|
import type { MastraMCPServerDefinition, MCPServerAuthState } from './client.js';
|
|
7
|
+
import type { SerializableMCPToolCatalog, SerializableMCPToolDefinition } from './types.js';
|
|
7
8
|
/**
|
|
8
9
|
* Configuration options for creating an MCPClient instance.
|
|
9
10
|
*/
|
|
@@ -767,6 +768,78 @@ export declare class MCPClient extends MastraBase {
|
|
|
767
768
|
toolsets: Record<string, Record<string, Tool<any, any, any, any>>>;
|
|
768
769
|
errors: Record<string, string>;
|
|
769
770
|
}>;
|
|
771
|
+
/**
|
|
772
|
+
* Discovers every configured server's tools as plain, serializable definitions.
|
|
773
|
+
*
|
|
774
|
+
* Unlike `listTools()`/`listToolsets()`, the result contains no functions or references to a
|
|
775
|
+
* live client, so it can be JSON-serialized and cached (Redis, a database, a build artifact)
|
|
776
|
+
* and reused by other processes. Rebuild an executable tool from a cached definition with
|
|
777
|
+
* {@link toolFromDefinition}, which does not reconnect.
|
|
778
|
+
*
|
|
779
|
+
* Definitions are grouped by server and keyed by the server's own tool name, without the
|
|
780
|
+
* `serverName_toolName` namespacing that `listTools()` applies.
|
|
781
|
+
*
|
|
782
|
+
* @example
|
|
783
|
+
* ```typescript
|
|
784
|
+
* // Once, at build time or on the first worker:
|
|
785
|
+
* const definitions = await mcp.listToolDefinitions();
|
|
786
|
+
* await cache.set('mcp-tools', JSON.stringify(definitions));
|
|
787
|
+
*
|
|
788
|
+
* // In every other worker, with no MCP connections opened:
|
|
789
|
+
* const definitions = JSON.parse(await cache.get('mcp-tools'));
|
|
790
|
+
* const tool = mcp.toolFromDefinition('weather', definitions.weather.getForecast);
|
|
791
|
+
* ```
|
|
792
|
+
*/
|
|
793
|
+
listToolDefinitions(): Promise<SerializableMCPToolCatalog>;
|
|
794
|
+
/**
|
|
795
|
+
* Like {@link listToolDefinitions}, but also returns errors for servers that failed to
|
|
796
|
+
* connect instead of surfacing only the servers that succeeded.
|
|
797
|
+
*
|
|
798
|
+
* Useful when caching a catalog, since it lets you avoid persisting a partial manifest that
|
|
799
|
+
* silently omits a server which happened to be down at discovery time.
|
|
800
|
+
*/
|
|
801
|
+
listToolDefinitionsWithErrors(): Promise<{
|
|
802
|
+
definitions: SerializableMCPToolCatalog;
|
|
803
|
+
errors: Record<string, string>;
|
|
804
|
+
}>;
|
|
805
|
+
/**
|
|
806
|
+
* Rebuilds an executable Mastra tool from a cached {@link SerializableMCPToolDefinition}.
|
|
807
|
+
*
|
|
808
|
+
* No MCP connection is opened here — that is the point of the method. The underlying client
|
|
809
|
+
* connects lazily, the first time the returned tool is actually executed, so a worker can
|
|
810
|
+
* reconstruct an entire tool map at startup and only pay for connections to the servers whose
|
|
811
|
+
* tools the model really calls.
|
|
812
|
+
*
|
|
813
|
+
* The returned tool behaves exactly like one from `listTools()`: same strict-mode metadata,
|
|
814
|
+
* approval policy, structured content handling, in-band tool errors, progress metadata, abort
|
|
815
|
+
* signal support, and reconnect/retry behavior.
|
|
816
|
+
*
|
|
817
|
+
* @param serverName Name of the server the definition came from, as configured on this client.
|
|
818
|
+
* @param definition A definition previously obtained from {@link listToolDefinitions}.
|
|
819
|
+
*/
|
|
820
|
+
toolFromDefinition({ serverName, definition, }: {
|
|
821
|
+
serverName: string;
|
|
822
|
+
definition: SerializableMCPToolDefinition;
|
|
823
|
+
}): Promise<Tool<any, any, any, any>>;
|
|
824
|
+
/**
|
|
825
|
+
* Rebuilds an entire cached catalog into a namespaced tool map, without connecting.
|
|
826
|
+
*
|
|
827
|
+
* This is the cached counterpart to `listTools()`: it produces the same `serverName_toolName`
|
|
828
|
+
* keys, so an agent's tool map can be reconstructed on a cold start from a catalog in Redis
|
|
829
|
+
* and dropped straight into the agent, with connections opened lazily per tool call.
|
|
830
|
+
*
|
|
831
|
+
* Servers present in the catalog but no longer configured on this client are skipped, so a
|
|
832
|
+
* stale cached manifest degrades gracefully instead of throwing.
|
|
833
|
+
*
|
|
834
|
+
* @example
|
|
835
|
+
* ```typescript
|
|
836
|
+
* const definitions = JSON.parse(await cache.get('mcp-tools'));
|
|
837
|
+
* const agent = new Agent({ tools: await mcp.toolsFromDefinitions({ definitions }), ... });
|
|
838
|
+
* ```
|
|
839
|
+
*/
|
|
840
|
+
toolsFromDefinitions({ definitions: catalog, }: {
|
|
841
|
+
definitions: SerializableMCPToolCatalog;
|
|
842
|
+
}): Promise<Record<string, Tool<any, any, any, any>>>;
|
|
770
843
|
/**
|
|
771
844
|
* Runs a per-server discovery `operation` against every configured server
|
|
772
845
|
* concurrently, isolating and logging per-server failures. Results are
|
|
@@ -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,EACV,aAAa,EACb,YAAY,EACZ,oBAAoB,EACpB,MAAM,EACN,QAAQ,EACR,oBAAoB,EACrB,MAAM,8BAA8B,CAAC;AAKtC,OAAO,KAAK,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../src/client/configuration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC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G,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IAoBrD;;;;;;;;;;;OAWG;YACW,qBAAqB;IA2BnC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACI,kBAAkB,IAAI,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAU1D;;;;;;;;;;;;;;OAcG;IACH,IAAI,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQvC;IAED;;;;;;;;OAQG;IACI,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAMzD,OAAO,CAAC,eAAe;YAQT,iBAAiB;YAiCjB,kBAAkB;IAchC,OAAO,CAAC,kBAAkB;YAyBZ,2BAA2B;YAI3B,kBAAkB;YAIlB,iBAAiB;CAuBhC"}
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { LoggingLevel, LogMessage, LogHandler, MastraMCPServerDefinition, ElicitationHandler, ProgressHandler, InternalMastraMCPClientOptions, RequireToolApproval, RequireToolApprovalFn, RequireToolApprovalContext, ToolAnnotations, } from './types.js';
|
|
1
|
+
export type { LoggingLevel, LogMessage, LogHandler, MastraMCPServerDefinition, ElicitationHandler, ProgressHandler, InternalMastraMCPClientOptions, RequireToolApproval, RequireToolApprovalFn, RequireToolApprovalContext, ToolAnnotations, SerializableMCPToolDefinition, SerializableMCPToolCatalog, } from './types.js';
|
|
2
2
|
export * from './client.js';
|
|
3
3
|
export * from './configuration.js';
|
|
4
4
|
export * from './oauth-provider.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,YAAY,EACZ,UAAU,EACV,UAAU,EACV,yBAAyB,EACzB,kBAAkB,EAClB,eAAe,EACf,8BAA8B,EAC9B,mBAAmB,EACnB,qBAAqB,EACrB,0BAA0B,EAC1B,eAAe,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,YAAY,EACZ,UAAU,EACV,UAAU,EACV,yBAAyB,EACzB,kBAAkB,EAClB,eAAe,EACf,8BAA8B,EAC9B,mBAAmB,EACnB,qBAAqB,EACrB,0BAA0B,EAC1B,eAAe,EACf,6BAA6B,EAC7B,0BAA0B,GAC3B,MAAM,SAAS,CAAC;AACjB,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/client/types.d.ts
CHANGED
|
@@ -477,4 +477,50 @@ export type InternalMastraMCPClientOptions = {
|
|
|
477
477
|
/** Optional timeout in milliseconds */
|
|
478
478
|
timeout?: number;
|
|
479
479
|
};
|
|
480
|
+
/**
|
|
481
|
+
* A fully serializable description of a single tool advertised by an MCP server.
|
|
482
|
+
*
|
|
483
|
+
* This is the data returned by the MCP `tools/list` response, plus the server metadata needed
|
|
484
|
+
* to reconstruct the tool faithfully. It contains no functions, class instances or references
|
|
485
|
+
* to a live client, so it survives `JSON.stringify` and can be cached in Redis, a database, or
|
|
486
|
+
* a build artifact and reused by other processes.
|
|
487
|
+
*
|
|
488
|
+
* Obtain these via {@link MCPClient.listToolDefinitions} and turn them back into executable
|
|
489
|
+
* tools with {@link MCPClient.toolFromDefinition}.
|
|
490
|
+
*/
|
|
491
|
+
export type SerializableMCPToolDefinition = {
|
|
492
|
+
/** Tool name as advertised by the server, without any server namespace prefix. */
|
|
493
|
+
name: string;
|
|
494
|
+
/** Human readable description from the server, if it supplied one. */
|
|
495
|
+
description?: string;
|
|
496
|
+
/** Raw JSON Schema for the tool's arguments, exactly as sent by the server. */
|
|
497
|
+
inputSchema: unknown;
|
|
498
|
+
/** Raw JSON Schema for the tool's structured output, if the server declared one. */
|
|
499
|
+
outputSchema?: unknown;
|
|
500
|
+
/** Server-advertised annotations (title, readOnlyHint, destructiveHint, ...). */
|
|
501
|
+
annotations?: ToolAnnotations;
|
|
502
|
+
/** Server-supplied `_meta`, including `ui.resourceUri` for MCP Apps. */
|
|
503
|
+
_meta?: Record<string, unknown>;
|
|
504
|
+
/**
|
|
505
|
+
* Metadata about the server that advertised this tool.
|
|
506
|
+
*
|
|
507
|
+
* Captured at discovery time because it is otherwise only available from a live connection.
|
|
508
|
+
* Without it, hydrating a tool would silently drop the server version and instructions that
|
|
509
|
+
* a normally discovered tool carries.
|
|
510
|
+
*/
|
|
511
|
+
server: {
|
|
512
|
+
/** The name this server is configured under. */
|
|
513
|
+
name: string;
|
|
514
|
+
/** Server version reported during the MCP handshake, if any. */
|
|
515
|
+
version?: string;
|
|
516
|
+
/** Instructions the server returned during initialization, if any. */
|
|
517
|
+
instructions?: string;
|
|
518
|
+
};
|
|
519
|
+
};
|
|
520
|
+
/**
|
|
521
|
+
* A serializable catalog of MCP tool definitions, keyed by server name and then tool name.
|
|
522
|
+
*
|
|
523
|
+
* This is the shape returned by {@link MCPClient.listToolDefinitions}.
|
|
524
|
+
*/
|
|
525
|
+
export type SerializableMCPToolCatalog = Record<string, Record<string, SerializableMCPToolDefinition>>;
|
|
480
526
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -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,EACV,yBAAyB,EACzB,oCAAoC,EACpC,kBAAkB,EAClB,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACpB,MAAM,8BAA8B,CAAC;AAGtC,YAAY,EAAE,SAAS,EAAE,MAAM,8B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M,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC;;;;;;OAMG;IACH,MAAM,EAAE;QACN,gDAAgD;QAChD,IAAI,EAAE,MAAM,CAAC;QACb,gEAAgE;QAChE,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,sEAAsE;QACtE,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
|
@@ -244,6 +244,57 @@ const res = await agent.stream(prompt, {
|
|
|
244
244
|
})
|
|
245
245
|
```
|
|
246
246
|
|
|
247
|
+
### `listToolDefinitions()`
|
|
248
|
+
|
|
249
|
+
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).
|
|
250
|
+
|
|
251
|
+
Unlike `listTools()`, the result contains no functions or references to a live client, so it can be passed through `JSON.stringify` and cached in Redis, a database, or a build artifact. Each definition holds the data from the MCP `tools/list` response (name, description, input schema, output schema, annotations, and `_meta`), plus the server name, version, and instructions captured at discovery time.
|
|
252
|
+
|
|
253
|
+
```typescript
|
|
254
|
+
const definitions = await mcp.listToolDefinitions()
|
|
255
|
+
|
|
256
|
+
await cache.set('mcp-tools', JSON.stringify(definitions))
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### `listToolDefinitionsWithErrors()`
|
|
260
|
+
|
|
261
|
+
Like `listToolDefinitions()`, but also returns per-server errors for servers that failed to connect. Use this when caching a catalog, so you don't persist a partial manifest that omits a server that was down at discovery time.
|
|
262
|
+
|
|
263
|
+
```typescript
|
|
264
|
+
const { definitions, errors } = await mcp.listToolDefinitionsWithErrors()
|
|
265
|
+
|
|
266
|
+
if (Object.keys(errors).length === 0) {
|
|
267
|
+
await cache.set('mcp-tools', JSON.stringify(definitions))
|
|
268
|
+
}
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### `toolFromDefinition()`
|
|
272
|
+
|
|
273
|
+
Rebuilds a single executable tool from a cached definition. No connection is opened here. The client connects lazily, the first time the tool is executed.
|
|
274
|
+
|
|
275
|
+
The returned tool behaves exactly like one from `listTools()`, with the same strict-mode metadata, approval policy, structured content handling, tool error handling, and reconnect behavior.
|
|
276
|
+
|
|
277
|
+
```typescript
|
|
278
|
+
const definitions = JSON.parse(await cache.get('mcp-tools'))
|
|
279
|
+
|
|
280
|
+
const tool = await mcp.toolFromDefinition({
|
|
281
|
+
serverName: 'weather',
|
|
282
|
+
definition: definitions.weather.getForecast,
|
|
283
|
+
})
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### `toolsFromDefinitions()`
|
|
287
|
+
|
|
288
|
+
Rebuilds an entire cached catalog into a namespaced tool map, without connecting. This is the cached counterpart to `listTools()`. It produces the same `serverName_toolName` keys, so you can reconstruct an agent's tool map on a cold start, and connections only open for the servers whose tools are actually called.
|
|
289
|
+
|
|
290
|
+
Servers present in the catalog but no longer configured on the client are skipped, so a stale cached manifest degrades gracefully.
|
|
291
|
+
|
|
292
|
+
```typescript
|
|
293
|
+
const definitions = JSON.parse(await cache.get('mcp-tools'))
|
|
294
|
+
|
|
295
|
+
new Agent({ id: 'agent', tools: await mcp.toolsFromDefinitions({ definitions }) })
|
|
296
|
+
```
|
|
297
|
+
|
|
247
298
|
### `getServerInstructions()`
|
|
248
299
|
|
|
249
300
|
Returns the instructions currently known for each configured MCP server. Servers that haven't connected yet, or don't advertise instructions, return `undefined`.
|