@mastra/mcp 1.0.0-beta.2 → 1.0.0-beta.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/CHANGELOG.md +106 -0
- package/dist/__fixtures__/tools.d.ts +1 -1
- package/dist/__fixtures__/tools.d.ts.map +1 -1
- package/dist/client/{elicitationActions.d.ts → actions/elicitation.d.ts} +2 -2
- package/dist/client/actions/elicitation.d.ts.map +1 -0
- package/dist/client/actions/progress.d.ts +23 -0
- package/dist/client/actions/progress.d.ts.map +1 -0
- package/dist/client/{promptActions.d.ts → actions/prompt.d.ts} +2 -2
- package/dist/client/actions/prompt.d.ts.map +1 -0
- package/dist/client/{resourceActions.d.ts → actions/resource.d.ts} +2 -2
- package/dist/client/actions/resource.d.ts.map +1 -0
- package/dist/client/client.d.ts +78 -138
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/configuration.d.ts +23 -1
- package/dist/client/configuration.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/types.d.ts +188 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/index.cjs +333 -91
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +314 -73
- package/dist/index.js.map +1 -1
- package/dist/server/server.d.ts +19 -4
- package/dist/server/server.d.ts.map +1 -1
- package/package.json +9 -7
- package/dist/client/elicitationActions.d.ts.map +0 -1
- package/dist/client/promptActions.d.ts.map +0 -1
- package/dist/client/resourceActions.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,111 @@
|
|
|
1
1
|
# @mastra/mcp
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix MCPClient automatic reconnection when session becomes invalid ([#10660](https://github.com/mastra-ai/mastra/pull/10660))
|
|
8
|
+
|
|
9
|
+
When an MCP server restarts, the session ID becomes invalid causing "Bad Request: No valid session ID provided" errors. The MCPClient now automatically detects session-related errors, reconnects to the server, and retries the tool call.
|
|
10
|
+
|
|
11
|
+
This fix addresses issue #7675 where MCPClient would fail to reconnect after an MCP server went offline and came back online.
|
|
12
|
+
|
|
13
|
+
- Populate RequestContext from options.extra for workflows and agents ([#10655](https://github.com/mastra-ai/mastra/pull/10655))
|
|
14
|
+
|
|
15
|
+
Workflows and agents exposed as MCP tools now receive all keys from `options.extra` directly on the RequestContext. This allows workflows and agents to access authentication information (authInfo, sessionId, requestId, etc.) via `requestContext.get('key')` when exposed via MCPServer.
|
|
16
|
+
|
|
17
|
+
- Fix timeout parameter position in listTools call ([#10609](https://github.com/mastra-ai/mastra/pull/10609))
|
|
18
|
+
|
|
19
|
+
The MCP SDK's `listTools` signature is `listTools(params?, options?)`. Timeout was incorrectly passed as params (1st arg) instead of options (2nd arg), causing timeouts to not be applied to requests.
|
|
20
|
+
|
|
21
|
+
- Unified MastraServer API with MCP transport routes ([#10644](https://github.com/mastra-ai/mastra/pull/10644))
|
|
22
|
+
|
|
23
|
+
**Breaking Changes:**
|
|
24
|
+
- Renamed `HonoServerAdapter` to `MastraServer` in `@mastra/hono`
|
|
25
|
+
- Renamed `ExpressServerAdapter` to `MastraServer` in `@mastra/express`
|
|
26
|
+
- Configuration now passed to constructor instead of separate method calls
|
|
27
|
+
- Renamed base class from `ServerAdapter` to `MastraServerBase` in `@mastra/server`
|
|
28
|
+
|
|
29
|
+
**New Features:**
|
|
30
|
+
- Added MCP transport routes (HTTP and SSE) to server adapters
|
|
31
|
+
- MCP endpoints available at `/api/mcp/:serverId/mcp` (HTTP) and `/api/mcp/:serverId/sse` (SSE)
|
|
32
|
+
- Added `express.json()` middleware compatibility for MCP routes
|
|
33
|
+
- Moved authentication helpers from deployer to `@mastra/server/auth`
|
|
34
|
+
|
|
35
|
+
**Testing:**
|
|
36
|
+
- Added shared MCP route and transport test suites in `@internal/server-adapter-test-utils`
|
|
37
|
+
- Added comprehensive MCP endpoint tests for both Hono and Express adapters
|
|
38
|
+
- Added GitHub Actions workflow for server adapter CI testing
|
|
39
|
+
|
|
40
|
+
- Add MCP Roots capability support (fixes #8660) ([#10646](https://github.com/mastra-ai/mastra/pull/10646))
|
|
41
|
+
|
|
42
|
+
This adds support for the MCP Roots capability, allowing clients to expose filesystem roots to MCP servers like `@modelcontextprotocol/server-filesystem`.
|
|
43
|
+
|
|
44
|
+
**New Features:**
|
|
45
|
+
- Added `roots` option to server configuration for specifying allowed directories
|
|
46
|
+
- Client automatically advertises `roots` capability when roots are configured
|
|
47
|
+
- Client handles `roots/list` requests from servers per MCP spec
|
|
48
|
+
- Added `client.roots` getter to access configured roots
|
|
49
|
+
- Added `client.setRoots()` to dynamically update roots
|
|
50
|
+
- Added `client.sendRootsListChanged()` to notify servers of root changes
|
|
51
|
+
|
|
52
|
+
**Usage:**
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
const client = new MCPClient({
|
|
56
|
+
servers: {
|
|
57
|
+
filesystem: {
|
|
58
|
+
command: 'npx',
|
|
59
|
+
args: ['-y', '@modelcontextprotocol/server-filesystem', '/tmp'],
|
|
60
|
+
roots: [
|
|
61
|
+
{ uri: 'file:///tmp', name: 'Temp Directory' },
|
|
62
|
+
{ uri: 'file:///home/user/projects', name: 'Projects' },
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Before this fix, the filesystem server would log:
|
|
70
|
+
|
|
71
|
+
> "Client does not support MCP Roots, using allowed directories set from server args"
|
|
72
|
+
|
|
73
|
+
After this fix, the server properly receives roots from the client:
|
|
74
|
+
|
|
75
|
+
> "Updated allowed directories from MCP roots: 2 valid directories"
|
|
76
|
+
|
|
77
|
+
- Add MCP progress notification support and refactor client structure ([#10637](https://github.com/mastra-ai/mastra/pull/10637))
|
|
78
|
+
- Added progress notification support for MCP tool execution. Enable with `enableProgressTracking: true` in server config and use `client.progress.onUpdate(handler)` to receive progress updates during long-running tool operations.
|
|
79
|
+
- Added `ProgressClientActions` class for handling progress notifications
|
|
80
|
+
- Refactored client action classes into `actions/` directory (elicitation, prompt, resource, progress)
|
|
81
|
+
- Extracted all type definitions to a dedicated `types.ts` file for better code organization
|
|
82
|
+
|
|
83
|
+
- Updated dependencies [[`ac0d2f4`](https://github.com/mastra-ai/mastra/commit/ac0d2f4ff8831f72c1c66c2be809706d17f65789), [`1a0d3fc`](https://github.com/mastra-ai/mastra/commit/1a0d3fc811482c9c376cdf79ee615c23bae9b2d6), [`85a628b`](https://github.com/mastra-ai/mastra/commit/85a628b1224a8f64cd82ea7f033774bf22df7a7e), [`c237233`](https://github.com/mastra-ai/mastra/commit/c23723399ccedf7f5744b3f40997b79246bfbe64), [`15f9e21`](https://github.com/mastra-ai/mastra/commit/15f9e216177201ea6e3f6d0bfb063fcc0953444f), [`ff94dea`](https://github.com/mastra-ai/mastra/commit/ff94dea935f4e34545c63bcb6c29804732698809), [`5b2ff46`](https://github.com/mastra-ai/mastra/commit/5b2ff4651df70c146523a7fca773f8eb0a2272f8), [`db41688`](https://github.com/mastra-ai/mastra/commit/db4168806d007417e2e60b4f68656dca4e5f40c9), [`5ca599d`](https://github.com/mastra-ai/mastra/commit/5ca599d0bb59a1595f19f58473fcd67cc71cef58), [`bff1145`](https://github.com/mastra-ai/mastra/commit/bff114556b3cbadad9b2768488708f8ad0e91475), [`5c8ca24`](https://github.com/mastra-ai/mastra/commit/5c8ca247094e0cc2cdbd7137822fb47241f86e77), [`e191844`](https://github.com/mastra-ai/mastra/commit/e1918444ca3f80e82feef1dad506cd4ec6e2875f), [`22553f1`](https://github.com/mastra-ai/mastra/commit/22553f11c63ee5e966a9c034a349822249584691), [`7237163`](https://github.com/mastra-ai/mastra/commit/72371635dbf96a87df4b073cc48fc655afbdce3d), [`2500740`](https://github.com/mastra-ai/mastra/commit/2500740ea23da067d6e50ec71c625ab3ce275e64), [`873ecbb`](https://github.com/mastra-ai/mastra/commit/873ecbb517586aa17d2f1e99283755b3ebb2863f), [`4f9bbe5`](https://github.com/mastra-ai/mastra/commit/4f9bbe5968f42c86f4930b8193de3c3c17e5bd36), [`02e51fe`](https://github.com/mastra-ai/mastra/commit/02e51feddb3d4155cfbcc42624fd0d0970d032c0), [`8f3fa3a`](https://github.com/mastra-ai/mastra/commit/8f3fa3a652bb77da092f913ec51ae46e3a7e27dc), [`cd29ad2`](https://github.com/mastra-ai/mastra/commit/cd29ad23a255534e8191f249593849ed29160886), [`bdf4d8c`](https://github.com/mastra-ai/mastra/commit/bdf4d8cdc656d8a2c21d81834bfa3bfa70f56c16), [`854e3da`](https://github.com/mastra-ai/mastra/commit/854e3dad5daac17a91a20986399d3a51f54bf68b), [`ce18d38`](https://github.com/mastra-ai/mastra/commit/ce18d38678c65870350d123955014a8432075fd9), [`cccf9c8`](https://github.com/mastra-ai/mastra/commit/cccf9c8b2d2dfc1a5e63919395b83d78c89682a0), [`61a5705`](https://github.com/mastra-ai/mastra/commit/61a570551278b6743e64243b3ce7d73de915ca8a), [`db70a48`](https://github.com/mastra-ai/mastra/commit/db70a48aeeeeb8e5f92007e8ede52c364ce15287), [`f0fdc14`](https://github.com/mastra-ai/mastra/commit/f0fdc14ee233d619266b3d2bbdeea7d25cfc6d13), [`db18bc9`](https://github.com/mastra-ai/mastra/commit/db18bc9c3825e2c1a0ad9a183cc9935f6691bfa1), [`9b37b56`](https://github.com/mastra-ai/mastra/commit/9b37b565e1f2a76c24f728945cc740c2b09be9da), [`41a23c3`](https://github.com/mastra-ai/mastra/commit/41a23c32f9877d71810f37e24930515df2ff7a0f), [`5d171ad`](https://github.com/mastra-ai/mastra/commit/5d171ad9ef340387276b77c2bb3e83e83332d729), [`f03ae60`](https://github.com/mastra-ai/mastra/commit/f03ae60500fe350c9d828621006cdafe1975fdd8), [`d1e74a0`](https://github.com/mastra-ai/mastra/commit/d1e74a0a293866dece31022047f5dbab65a304d0), [`39e7869`](https://github.com/mastra-ai/mastra/commit/39e7869bc7d0ee391077ce291474d8a84eedccff), [`5761926`](https://github.com/mastra-ai/mastra/commit/57619260c4a2cdd598763abbacd90de594c6bc76), [`c900fdd`](https://github.com/mastra-ai/mastra/commit/c900fdd504c41348efdffb205cfe80d48c38fa33), [`604a79f`](https://github.com/mastra-ai/mastra/commit/604a79fecf276e26a54a3fe01bb94e65315d2e0e), [`887f0b4`](https://github.com/mastra-ai/mastra/commit/887f0b4746cdbd7cb7d6b17ac9f82aeb58037ea5), [`2562143`](https://github.com/mastra-ai/mastra/commit/256214336b4faa78646c9c1776612393790d8784), [`ef11a61`](https://github.com/mastra-ai/mastra/commit/ef11a61920fa0ed08a5b7ceedd192875af119749)]:
|
|
84
|
+
- @mastra/core@1.0.0-beta.6
|
|
85
|
+
|
|
86
|
+
## 1.0.0-beta.3
|
|
87
|
+
|
|
88
|
+
### Patch Changes
|
|
89
|
+
|
|
90
|
+
- Fix MCPClient resource leak causing MaxListenersExceededWarning ([#10501](https://github.com/mastra-ai/mastra/pull/10501))
|
|
91
|
+
|
|
92
|
+
Fixes an issue where `InternalMastraMCPClient` registered event listeners to the `process` object for graceful shutdown but failed to remove them upon disconnection. This caused a memory leak after multiple connect/disconnect cycles, triggering the warning:
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGTERM listeners added to [process].
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
The fix stores references to the exit hook unsubscribe function and SIGTERM handler, then properly cleans them up in `disconnect()`.
|
|
99
|
+
|
|
100
|
+
Additionally, users can now disable session management by passing `sessionIdGenerator: undefined` in `startHTTP()` options. This enables stateless MCP server deployments, which is useful for serverless environments.
|
|
101
|
+
|
|
102
|
+
Fixes #10499, #8526
|
|
103
|
+
|
|
104
|
+
- Fix MCP client to return structuredContent directly when tools define an outputSchema, ensuring output validation works correctly instead of failing with "expected X, received undefined" errors. ([#10442](https://github.com/mastra-ai/mastra/pull/10442))
|
|
105
|
+
|
|
106
|
+
- Updated dependencies [[`21a15de`](https://github.com/mastra-ai/mastra/commit/21a15de369fe82aac26bb642ed7be73505475e8b), [`feb7ee4`](https://github.com/mastra-ai/mastra/commit/feb7ee4d09a75edb46c6669a3beaceec78811747), [`b0e2ea5`](https://github.com/mastra-ai/mastra/commit/b0e2ea5b52c40fae438b9e2f7baee6f0f89c5442), [`c456e01`](https://github.com/mastra-ai/mastra/commit/c456e0149e3c176afcefdbd9bb1d2c5917723725), [`ab035c2`](https://github.com/mastra-ai/mastra/commit/ab035c2ef6d8cc7bb25f06f1a38508bd9e6f126b), [`1a46a56`](https://github.com/mastra-ai/mastra/commit/1a46a566f45a3fcbadc1cf36bf86d351f264bfa3), [`3cf540b`](https://github.com/mastra-ai/mastra/commit/3cf540b9fbfea8f4fc8d3a2319a4e6c0b0cbfd52), [`1c6ce51`](https://github.com/mastra-ai/mastra/commit/1c6ce51f875915ab57fd36873623013699a2a65d), [`898a972`](https://github.com/mastra-ai/mastra/commit/898a9727d286c2510d6b702dfd367e6aaf5c6b0f), [`a97003a`](https://github.com/mastra-ai/mastra/commit/a97003aa1cf2f4022a41912324a1e77263b326b8), [`ccc141e`](https://github.com/mastra-ai/mastra/commit/ccc141ed27da0abc3a3fc28e9e5128152e8e37f4), [`fe3b897`](https://github.com/mastra-ai/mastra/commit/fe3b897c2ccbcd2b10e81b099438c7337feddf89), [`00123ba`](https://github.com/mastra-ai/mastra/commit/00123ba96dc9e5cd0b110420ebdba56d8f237b25), [`29c4309`](https://github.com/mastra-ai/mastra/commit/29c4309f818b24304c041bcb4a8f19b5f13f6b62), [`16785ce`](https://github.com/mastra-ai/mastra/commit/16785ced928f6f22638f4488cf8a125d99211799), [`de8239b`](https://github.com/mastra-ai/mastra/commit/de8239bdcb1d8c0cfa06da21f1569912a66bbc8a), [`b5e6cd7`](https://github.com/mastra-ai/mastra/commit/b5e6cd77fc8c8e64e0494c1d06cee3d84e795d1e), [`3759cb0`](https://github.com/mastra-ai/mastra/commit/3759cb064935b5f74c65ac2f52a1145f7352899d), [`651e772`](https://github.com/mastra-ai/mastra/commit/651e772eb1475fb13e126d3fcc01751297a88214), [`b61b93f`](https://github.com/mastra-ai/mastra/commit/b61b93f9e058b11dd2eec169853175d31dbdd567), [`bae33d9`](https://github.com/mastra-ai/mastra/commit/bae33d91a63fbb64d1e80519e1fc1acaed1e9013), [`c0b731f`](https://github.com/mastra-ai/mastra/commit/c0b731fb27d712dc8582e846df5c0332a6a0c5ba), [`43ca8f2`](https://github.com/mastra-ai/mastra/commit/43ca8f2c7334851cc7b4d3d2f037d8784bfbdd5f), [`2ca67cc`](https://github.com/mastra-ai/mastra/commit/2ca67cc3bb1f6a617353fdcab197d9efebe60d6f), [`9e67002`](https://github.com/mastra-ai/mastra/commit/9e67002b52c9be19936c420a489dbee9c5fd6a78), [`35edc49`](https://github.com/mastra-ai/mastra/commit/35edc49ac0556db609189641d6341e76771b81fc)]:
|
|
107
|
+
- @mastra/core@1.0.0-beta.5
|
|
108
|
+
|
|
3
109
|
## 1.0.0-beta.2
|
|
4
110
|
|
|
5
111
|
### Patch Changes
|
|
@@ -5,5 +5,5 @@ export declare const weatherTool: import("@mastra/core/tools").Tool<z.ZodObject<
|
|
|
5
5
|
location: string;
|
|
6
6
|
}, {
|
|
7
7
|
location: string;
|
|
8
|
-
}>, undefined, any, any, import("@mastra/core/tools").ToolExecutionContext<any, any
|
|
8
|
+
}>, undefined, any, any, import("@mastra/core/tools").ToolExecutionContext<any, any>, "get-weather">;
|
|
9
9
|
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/__fixtures__/tools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAqBxB,eAAO,MAAM,WAAW;;;;;;
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/__fixtures__/tools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAqBxB,eAAO,MAAM,WAAW;;;;;;oGAUtB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IMastraLogger } from '@mastra/core/logger';
|
|
2
2
|
import type { ElicitRequest, ElicitResult } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
-
import type { InternalMastraMCPClient } from '
|
|
3
|
+
import type { InternalMastraMCPClient } from '../client.js';
|
|
4
4
|
interface ElicitationClientActionsConfig {
|
|
5
5
|
client: InternalMastraMCPClient;
|
|
6
6
|
logger: IMastraLogger;
|
|
@@ -60,4 +60,4 @@ export declare class ElicitationClientActions {
|
|
|
60
60
|
onRequest(handler: (request: ElicitRequest['params']) => Promise<ElicitResult>): void;
|
|
61
61
|
}
|
|
62
62
|
export {};
|
|
63
|
-
//# sourceMappingURL=
|
|
63
|
+
//# sourceMappingURL=elicitation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elicitation.d.ts","sourceRoot":"","sources":["../../../src/client/actions/elicitation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AACtF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAEzD,UAAU,8BAA8B;IACtC,MAAM,EAAE,uBAAuB,CAAC;IAChC,MAAM,EAAE,aAAa,CAAC;CACvB;AAED;;;;;;GAMG;AACH,qBAAa,wBAAwB;IACnC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0B;IACjD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;IAEvC;;OAEG;gBACS,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,8BAA8B;IAK9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqCG;IACI,SAAS,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC,QAAQ,CAAC,KAAK,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI;CAG7F"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { IMastraLogger } from '@mastra/core/logger';
|
|
2
|
+
import type { ProgressNotificationSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
import type { z } from 'zod';
|
|
4
|
+
import type { InternalMastraMCPClient } from '../client.js';
|
|
5
|
+
interface ProgressClientActionsConfig {
|
|
6
|
+
client: InternalMastraMCPClient;
|
|
7
|
+
logger: IMastraLogger;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Client-side progress actions for handling progress notifications from MCP servers.
|
|
11
|
+
*/
|
|
12
|
+
export declare class ProgressClientActions {
|
|
13
|
+
private readonly client;
|
|
14
|
+
private readonly logger;
|
|
15
|
+
constructor({ client, logger }: ProgressClientActionsConfig);
|
|
16
|
+
/**
|
|
17
|
+
* Set a notification handler for progress updates.
|
|
18
|
+
* @param handler The callback function to handle progress notifications.
|
|
19
|
+
*/
|
|
20
|
+
onUpdate(handler: (params: z.infer<typeof ProgressNotificationSchema>['params']) => void): void;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=progress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../../../src/client/actions/progress.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AACrF,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAEzD,UAAU,2BAA2B;IACjC,MAAM,EAAE,uBAAuB,CAAC;IAChC,MAAM,EAAE,aAAa,CAAC;CACzB;AAED;;GAEG;AACH,qBAAa,qBAAqB;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0B;IACjD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;gBAE3B,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,2BAA2B;IAK3D;;;OAGG;IACI,QAAQ,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC,QAAQ,CAAC,KAAK,IAAI,GAAG,IAAI;CAGzG"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IMastraLogger } from '@mastra/core/logger';
|
|
2
2
|
import type { GetPromptResult, Prompt } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
-
import type { InternalMastraMCPClient } from '
|
|
3
|
+
import type { InternalMastraMCPClient } from '../client.js';
|
|
4
4
|
interface PromptClientActionsConfig {
|
|
5
5
|
client: InternalMastraMCPClient;
|
|
6
6
|
logger: IMastraLogger;
|
|
@@ -87,4 +87,4 @@ export declare class PromptClientActions {
|
|
|
87
87
|
onListChanged(handler: () => void): Promise<void>;
|
|
88
88
|
}
|
|
89
89
|
export {};
|
|
90
|
-
//# sourceMappingURL=
|
|
90
|
+
//# sourceMappingURL=prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../src/client/actions/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAClF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAEzD,UAAU,yBAAyB;IAC/B,MAAM,EAAE,uBAAuB,CAAC;IAChC,MAAM,EAAE,aAAa,CAAC;CACzB;AAED;;;;;GAKG;AACH,qBAAa,mBAAmB;IAC5B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0B;IACjD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;IAEvC;;OAEG;gBACS,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,yBAAyB;IAKzD;;;;;;;;;;;;;;;OAeG;IACU,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAyBtC;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACU,GAAG,CAAC,EACb,IAAI,EACJ,IAAI,EACJ,OAAO,GACV,EAAE;QACC,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,eAAe,CAAC;IAI5B;;;;;;;;;;;;;;;OAeG;IACU,aAAa,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAGjE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IMastraLogger } from '@mastra/core/logger';
|
|
2
2
|
import type { Resource, ResourceTemplate } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
-
import type { InternalMastraMCPClient } from '
|
|
3
|
+
import type { InternalMastraMCPClient } from '../client.js';
|
|
4
4
|
interface ResourceClientActionsConfig {
|
|
5
5
|
client: InternalMastraMCPClient;
|
|
6
6
|
logger: IMastraLogger;
|
|
@@ -179,4 +179,4 @@ export declare class ResourceClientActions {
|
|
|
179
179
|
onListChanged(handler: () => void): Promise<void>;
|
|
180
180
|
}
|
|
181
181
|
export {};
|
|
182
|
-
//# sourceMappingURL=
|
|
182
|
+
//# sourceMappingURL=resource.d.ts.map
|
|
@@ -0,0 +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;AAEzD,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACrF,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;gBACS,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,2BAA2B;IAK3D;;;;;;;;;;;;;;;OAeG;IACU,IAAI,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;IAyBxC;;;;;;;;;;;;;;;;OAgBG;IACU,SAAS,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;IA0BrD;;;;;;;;;;;;OAYG;IACU,IAAI,CAAC,GAAG,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAI7B;;;;;;;;;;;;;;OAcG;IACU,SAAS,CAAC,GAAG,EAAE,MAAM;IAIlC;;;;;;;;;;;;;OAaG;IACU,WAAW,CAAC,GAAG,EAAE,MAAM;IAIpC;;;;;;;;;;;;;;;;;OAiBG;IACU,SAAS,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjF;;;;;;;;;;;;;;;OAeG;IACU,aAAa,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAG/D"}
|
package/dist/client/client.d.ts
CHANGED
|
@@ -1,145 +1,14 @@
|
|
|
1
1
|
import { MastraBase } from '@mastra/core/base';
|
|
2
|
-
import type { RequestContext } from '@mastra/core/di';
|
|
3
2
|
import type { Tool } from '@mastra/core/tools';
|
|
4
|
-
import type {
|
|
5
|
-
import type { StreamableHTTPClientTransportOptions } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
6
|
-
import type { ClientCapabilities, ElicitRequest, ElicitResult, GetPromptResult, ListPromptsResult, LoggingLevel } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
import type { GetPromptResult, ListPromptsResult } from '@modelcontextprotocol/sdk/types.js';
|
|
7
4
|
import { ResourceUpdatedNotificationSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
8
5
|
import { z } from 'zod';
|
|
9
|
-
import { ElicitationClientActions } from './
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
*/
|
|
16
|
-
export interface LogMessage {
|
|
17
|
-
/** Logging level (debug, info, warning, error, etc.) */
|
|
18
|
-
level: LoggingLevel;
|
|
19
|
-
/** Log message content */
|
|
20
|
-
message: string;
|
|
21
|
-
/** Timestamp when the log was created */
|
|
22
|
-
timestamp: Date;
|
|
23
|
-
/** Name of the MCP server that generated the log */
|
|
24
|
-
serverName: string;
|
|
25
|
-
/** Optional additional details */
|
|
26
|
-
details?: Record<string, any>;
|
|
27
|
-
requestContext?: RequestContext | null;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Handler function for processing log messages from MCP servers.
|
|
31
|
-
*/
|
|
32
|
-
export type LogHandler = (logMessage: LogMessage) => void;
|
|
33
|
-
/**
|
|
34
|
-
* Handler function for processing elicitation requests from MCP servers.
|
|
35
|
-
*
|
|
36
|
-
* @param request - The elicitation request parameters including message and schema
|
|
37
|
-
* @returns Promise resolving to the user's response (accept/decline/cancel with optional content)
|
|
38
|
-
*/
|
|
39
|
-
export type ElicitationHandler = (request: ElicitRequest['params']) => Promise<ElicitResult>;
|
|
40
|
-
/**
|
|
41
|
-
* Base options common to all MCP server definitions.
|
|
42
|
-
*/
|
|
43
|
-
type BaseServerOptions = {
|
|
44
|
-
/** Optional handler for server log messages */
|
|
45
|
-
logger?: LogHandler;
|
|
46
|
-
/** Optional timeout in milliseconds for server operations */
|
|
47
|
-
timeout?: number;
|
|
48
|
-
/** Optional client capabilities to advertise to the server */
|
|
49
|
-
capabilities?: ClientCapabilities;
|
|
50
|
-
/** Whether to enable server log forwarding (default: true) */
|
|
51
|
-
enableServerLogs?: boolean;
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* Configuration for MCP servers using stdio (subprocess) transport.
|
|
55
|
-
*
|
|
56
|
-
* Used when the MCP server is spawned as a subprocess that communicates via stdin/stdout.
|
|
57
|
-
*/
|
|
58
|
-
type StdioServerDefinition = BaseServerOptions & {
|
|
59
|
-
/** Command to execute (e.g., 'node', 'python', 'npx') */
|
|
60
|
-
command: string;
|
|
61
|
-
/** Optional arguments to pass to the command */
|
|
62
|
-
args?: string[];
|
|
63
|
-
/** Optional environment variables for the subprocess */
|
|
64
|
-
env?: Record<string, string>;
|
|
65
|
-
url?: never;
|
|
66
|
-
requestInit?: never;
|
|
67
|
-
eventSourceInit?: never;
|
|
68
|
-
authProvider?: never;
|
|
69
|
-
reconnectionOptions?: never;
|
|
70
|
-
sessionId?: never;
|
|
71
|
-
connectTimeout?: never;
|
|
72
|
-
};
|
|
73
|
-
/**
|
|
74
|
-
* Configuration for MCP servers using HTTP-based transport (Streamable HTTP or SSE fallback).
|
|
75
|
-
*
|
|
76
|
-
* Used when connecting to remote MCP servers over HTTP. The client will attempt Streamable HTTP
|
|
77
|
-
* transport first and fall back to SSE if that fails.
|
|
78
|
-
*/
|
|
79
|
-
type HttpServerDefinition = BaseServerOptions & {
|
|
80
|
-
/** URL of the MCP server endpoint */
|
|
81
|
-
url: URL;
|
|
82
|
-
command?: never;
|
|
83
|
-
args?: never;
|
|
84
|
-
env?: never;
|
|
85
|
-
/** Optional request configuration for HTTP requests */
|
|
86
|
-
requestInit?: StreamableHTTPClientTransportOptions['requestInit'];
|
|
87
|
-
/** Optional configuration for SSE fallback (required when using custom headers with SSE) */
|
|
88
|
-
eventSourceInit?: SSEClientTransportOptions['eventSourceInit'];
|
|
89
|
-
/** Optional authentication provider for HTTP requests */
|
|
90
|
-
authProvider?: StreamableHTTPClientTransportOptions['authProvider'];
|
|
91
|
-
/** Optional reconnection configuration for Streamable HTTP */
|
|
92
|
-
reconnectionOptions?: StreamableHTTPClientTransportOptions['reconnectionOptions'];
|
|
93
|
-
/** Optional session ID for Streamable HTTP */
|
|
94
|
-
sessionId?: StreamableHTTPClientTransportOptions['sessionId'];
|
|
95
|
-
/** Optional timeout in milliseconds for the connection phase (default: 3000ms).
|
|
96
|
-
* This timeout allows the system to switch MCP streaming protocols during the setup phase.
|
|
97
|
-
* The default is set to 3s because the long default timeout would be extremely slow for SSE backwards compat (60s).
|
|
98
|
-
*/
|
|
99
|
-
connectTimeout?: number;
|
|
100
|
-
};
|
|
101
|
-
/**
|
|
102
|
-
* Configuration for connecting to an MCP server.
|
|
103
|
-
*
|
|
104
|
-
* Either stdio-based (subprocess) or HTTP-based (remote server). The transport type is
|
|
105
|
-
* automatically detected based on whether `command` or `url` is provided.
|
|
106
|
-
*
|
|
107
|
-
* @example
|
|
108
|
-
* ```typescript
|
|
109
|
-
* // Stdio server
|
|
110
|
-
* const stdioServer: MastraMCPServerDefinition = {
|
|
111
|
-
* command: 'npx',
|
|
112
|
-
* args: ['tsx', 'server.ts'],
|
|
113
|
-
* env: { API_KEY: 'secret' }
|
|
114
|
-
* };
|
|
115
|
-
*
|
|
116
|
-
* // HTTP server
|
|
117
|
-
* const httpServer: MastraMCPServerDefinition = {
|
|
118
|
-
* url: new URL('http://localhost:8080/mcp'),
|
|
119
|
-
* requestInit: {
|
|
120
|
-
* headers: { Authorization: 'Bearer token' }
|
|
121
|
-
* }
|
|
122
|
-
* };
|
|
123
|
-
* ```
|
|
124
|
-
*/
|
|
125
|
-
export type MastraMCPServerDefinition = StdioServerDefinition | HttpServerDefinition;
|
|
126
|
-
/**
|
|
127
|
-
* Options for creating an internal MCP client instance.
|
|
128
|
-
*
|
|
129
|
-
* @internal
|
|
130
|
-
*/
|
|
131
|
-
export type InternalMastraMCPClientOptions = {
|
|
132
|
-
/** Name identifier for this client */
|
|
133
|
-
name: string;
|
|
134
|
-
/** Server connection configuration */
|
|
135
|
-
server: MastraMCPServerDefinition;
|
|
136
|
-
/** Optional client capabilities */
|
|
137
|
-
capabilities?: ClientCapabilities;
|
|
138
|
-
/** Optional client version */
|
|
139
|
-
version?: string;
|
|
140
|
-
/** Optional timeout in milliseconds */
|
|
141
|
-
timeout?: number;
|
|
142
|
-
};
|
|
6
|
+
import { ElicitationClientActions } from './actions/elicitation.js';
|
|
7
|
+
import { ProgressClientActions } from './actions/progress.js';
|
|
8
|
+
import { PromptClientActions } from './actions/prompt.js';
|
|
9
|
+
import { ResourceClientActions } from './actions/resource.js';
|
|
10
|
+
import type { ElicitationHandler, ProgressHandler, InternalMastraMCPClientOptions, Root } from './types.js';
|
|
11
|
+
export type { LoggingLevel, LogMessage, LogHandler, ElicitationHandler, ProgressHandler, MastraMCPServerDefinition, InternalMastraMCPClientOptions, Root, } from './types.js';
|
|
143
12
|
/**
|
|
144
13
|
* Internal MCP client implementation for connecting to a single MCP server.
|
|
145
14
|
*
|
|
@@ -154,15 +23,21 @@ export declare class InternalMastraMCPClient extends MastraBase {
|
|
|
154
23
|
private readonly timeout;
|
|
155
24
|
private logHandler?;
|
|
156
25
|
private enableServerLogs?;
|
|
26
|
+
private enableProgressTracking?;
|
|
157
27
|
private serverConfig;
|
|
158
28
|
private transport?;
|
|
159
29
|
private currentOperationContext;
|
|
30
|
+
private exitHookUnsubscribe?;
|
|
31
|
+
private sigTermHandler?;
|
|
32
|
+
private _roots;
|
|
160
33
|
/** Provides access to resource operations (list, read, subscribe, etc.) */
|
|
161
34
|
readonly resources: ResourceClientActions;
|
|
162
35
|
/** Provides access to prompt operations (list, get, notifications) */
|
|
163
36
|
readonly prompts: PromptClientActions;
|
|
164
37
|
/** Provides access to elicitation operations (request handling) */
|
|
165
38
|
readonly elicitation: ElicitationClientActions;
|
|
39
|
+
/** Provides access to progress operations (notifications) */
|
|
40
|
+
readonly progress: ProgressClientActions;
|
|
166
41
|
/**
|
|
167
42
|
* @internal
|
|
168
43
|
*/
|
|
@@ -175,6 +50,44 @@ export declare class InternalMastraMCPClient extends MastraBase {
|
|
|
175
50
|
*/
|
|
176
51
|
private log;
|
|
177
52
|
private setupLogging;
|
|
53
|
+
/**
|
|
54
|
+
* Set up handler for roots/list requests from the server.
|
|
55
|
+
*
|
|
56
|
+
* Per MCP spec (https://modelcontextprotocol.io/specification/2025-11-25/client/roots):
|
|
57
|
+
* When a server sends a roots/list request, the client responds with the configured roots.
|
|
58
|
+
*/
|
|
59
|
+
private setupRootsHandler;
|
|
60
|
+
/**
|
|
61
|
+
* Get the currently configured roots.
|
|
62
|
+
*
|
|
63
|
+
* @returns Array of configured filesystem roots
|
|
64
|
+
*/
|
|
65
|
+
get roots(): Root[];
|
|
66
|
+
/**
|
|
67
|
+
* Update the list of filesystem roots and notify the server.
|
|
68
|
+
*
|
|
69
|
+
* Per MCP spec, when roots change, the client sends a `notifications/roots/list_changed`
|
|
70
|
+
* notification to inform the server that it should re-fetch the roots list.
|
|
71
|
+
*
|
|
72
|
+
* @param roots - New list of filesystem roots
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* await client.setRoots([
|
|
77
|
+
* { uri: 'file:///home/user/projects', name: 'Projects' },
|
|
78
|
+
* { uri: 'file:///tmp', name: 'Temp' }
|
|
79
|
+
* ]);
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
setRoots(roots: Root[]): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Send a roots/list_changed notification to the server.
|
|
85
|
+
*
|
|
86
|
+
* Per MCP spec, clients that support `listChanged` MUST send this notification
|
|
87
|
+
* when the list of roots changes. The server will then call roots/list to get
|
|
88
|
+
* the updated list.
|
|
89
|
+
*/
|
|
90
|
+
sendRootsListChanged(): Promise<void>;
|
|
178
91
|
private connectStdio;
|
|
179
92
|
private connectHttp;
|
|
180
93
|
private isConnected;
|
|
@@ -201,6 +114,32 @@ export declare class InternalMastraMCPClient extends MastraBase {
|
|
|
201
114
|
*/
|
|
202
115
|
get sessionId(): string | undefined;
|
|
203
116
|
disconnect(): Promise<void>;
|
|
117
|
+
/**
|
|
118
|
+
* Checks if an error indicates a session invalidation that requires reconnection.
|
|
119
|
+
*
|
|
120
|
+
* Common session-related errors include:
|
|
121
|
+
* - "No valid session ID provided" (HTTP 400)
|
|
122
|
+
* - "Server not initialized" (HTTP 400)
|
|
123
|
+
* - Connection refused errors
|
|
124
|
+
*
|
|
125
|
+
* @param error - The error to check
|
|
126
|
+
* @returns true if the error indicates a session problem requiring reconnection
|
|
127
|
+
*
|
|
128
|
+
* @internal
|
|
129
|
+
*/
|
|
130
|
+
private isSessionError;
|
|
131
|
+
/**
|
|
132
|
+
* Forces a reconnection to the MCP server by disconnecting and reconnecting.
|
|
133
|
+
*
|
|
134
|
+
* This is useful when the session becomes invalid (e.g., after server restart)
|
|
135
|
+
* and the client needs to establish a fresh connection.
|
|
136
|
+
*
|
|
137
|
+
* @returns Promise resolving when reconnection is complete
|
|
138
|
+
* @throws {Error} If reconnection fails
|
|
139
|
+
*
|
|
140
|
+
* @internal
|
|
141
|
+
*/
|
|
142
|
+
forceReconnect(): Promise<void>;
|
|
204
143
|
listResources(): Promise<z.objectOutputType<{
|
|
205
144
|
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
|
206
145
|
} & {
|
|
@@ -413,6 +352,7 @@ export declare class InternalMastraMCPClient extends MastraBase {
|
|
|
413
352
|
setResourceUpdatedNotificationHandler(handler: (params: z.infer<typeof ResourceUpdatedNotificationSchema>['params']) => void): void;
|
|
414
353
|
setResourceListChangedNotificationHandler(handler: () => void): void;
|
|
415
354
|
setElicitationRequestHandler(handler: ElicitationHandler): void;
|
|
355
|
+
setProgressNotificationHandler(handler: ProgressHandler): void;
|
|
416
356
|
private convertInputSchema;
|
|
417
357
|
private convertOutputSchema;
|
|
418
358
|
tools(): Promise<Record<string, Tool<any, any, any, any>>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAQ/C,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EAElB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAKL,iCAAiC,EAQlC,MAAM,oCAAoC,CAAC;AAG5C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAEV,kBAAkB,EAClB,eAAe,EAEf,8BAA8B,EAC9B,IAAI,EACL,MAAM,SAAS,CAAC;AAGjB,YAAY,EACV,YAAY,EACZ,UAAU,EACV,UAAU,EACV,kBAAkB,EAClB,eAAe,EACf,yBAAyB,EACzB,8BAA8B,EAC9B,IAAI,GACL,MAAM,SAAS,CAAC;AA2BjB;;;;;;;GAOG;AACH,qBAAa,uBAAwB,SAAQ,UAAU;IACrD,IAAI,EAA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,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;CA+FjE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MastraBase } from '@mastra/core/base';
|
|
2
2
|
import type { Tool } from '@mastra/core/tools';
|
|
3
|
-
import type { ElicitRequest, ElicitResult, Prompt, Resource, ResourceTemplate } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
import type { ElicitRequest, ElicitResult, ProgressNotification, Prompt, Resource, ResourceTemplate } from '@modelcontextprotocol/sdk/types.js';
|
|
4
4
|
import type { MastraMCPServerDefinition } from './client.js';
|
|
5
5
|
/**
|
|
6
6
|
* Configuration options for creating an MCPClient instance.
|
|
@@ -82,6 +82,28 @@ export declare class MCPClient extends MastraBase {
|
|
|
82
82
|
* ```
|
|
83
83
|
*/
|
|
84
84
|
constructor(args: MCPClientOptions);
|
|
85
|
+
/**
|
|
86
|
+
* Provides access to progress-related operations for tracking long-running operations.
|
|
87
|
+
*
|
|
88
|
+
* Progress tracking allows MCP servers to send updates about the status of ongoing operations,
|
|
89
|
+
* providing real-time feedback to users about task completion and current state.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* // Set up handler for progress updates from a server
|
|
94
|
+
* await mcp.progress.onUpdate('serverName', (params) => {
|
|
95
|
+
* console.log(`Progress: ${params.progress}%`);
|
|
96
|
+
* console.log(`Status: ${params.message}`);
|
|
97
|
+
*
|
|
98
|
+
* if (params.total) {
|
|
99
|
+
* console.log(`Completed ${params.progress} of ${params.total} items`);
|
|
100
|
+
* }
|
|
101
|
+
* });
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
get progress(): {
|
|
105
|
+
onUpdate: (serverName: string, handler: (params: ProgressNotification["params"]) => void) => Promise<void>;
|
|
106
|
+
};
|
|
85
107
|
/**
|
|
86
108
|
* Provides access to elicitation-related operations for interactive user input collection.
|
|
87
109
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../src/client/configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,gBAAgB,EACjB,MAAM,oCAAoC,CAAC;AAI5C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAI1D;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,wHAAwH;IACxH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,mFAAmF;IACnF,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC;IACnD,iFAAiF;IACjF,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qBAAa,SAAU,SAAQ,UAAU;IACvC,OAAO,CAAC,aAAa,CAAiD;IACtE,OAAO,CAAC,EAAE,CAAS;IACnB,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,cAAc,CAA8C;IACpE,OAAO,CAAC,iBAAiB,CAA8B;IAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;gBACS,IAAI,EAAE,gBAAgB;
|
|
1
|
+
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../src/client/configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,oBAAoB,EACpB,MAAM,EACN,QAAQ,EACR,gBAAgB,EACjB,MAAM,oCAAo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AE,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IAwB9F;;;;;;;;;;;;;;OAcG;IACH,IAAI,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQvC;YAEa,kBAAkB;YAyDlB,2BAA2B;YAQ3B,eAAe;CAe9B"}
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export type { LoggingLevel, LogMessage, LogHandler, MastraMCPServerDefinition, ElicitationHandler } from './
|
|
1
|
+
export type { LoggingLevel, LogMessage, LogHandler, MastraMCPServerDefinition, ElicitationHandler, ProgressHandler, InternalMastraMCPClientOptions, } from './types.js';
|
|
2
|
+
export * from './client.js';
|
|
2
3
|
export * from './configuration.js';
|
|
3
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACR,YAAY,EACZ,UAAU,EACV,UAAU,EACV,yBAAyB,EACzB,kBAAkB,EAClB,eAAe,EACf,8BAA8B,GACjC,MAAM,SAAS,CAAC;AACjB,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC"}
|