@mastra/mcp 1.0.0-beta.3 → 1.0.0-beta.5
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 +124 -0
- package/README.md +61 -4
- 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 +76 -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 +237 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/index.cjs +316 -86
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +298 -69
- package/dist/index.js.map +1 -1
- package/dist/server/server.d.ts +19 -3
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/types.d.ts +11 -4
- package/dist/server/types.d.ts.map +1 -1
- package/package.json +3 -3
- 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,129 @@
|
|
|
1
1
|
# @mastra/mcp
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.5
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Add support for RequestOptions in elicitation requests to allow custom timeouts and request cancellation. ([#10849](https://github.com/mastra-ai/mastra/pull/10849))
|
|
8
|
+
|
|
9
|
+
You can now pass RequestOptions when sending elicitation requests:
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
// Within a tool's execute function
|
|
13
|
+
const result = await options.mcp.elicitation.sendRequest(
|
|
14
|
+
{
|
|
15
|
+
message: 'Please provide your email',
|
|
16
|
+
requestedSchema: {
|
|
17
|
+
type: 'object',
|
|
18
|
+
properties: { email: { type: 'string' } },
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
{ timeout: 120000 }, // Custom 2-minute timeout
|
|
22
|
+
);
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The RequestOptions parameter supports:
|
|
26
|
+
- `timeout`: Custom timeout in milliseconds (default: 60000ms)
|
|
27
|
+
- `signal`: AbortSignal for request cancellation
|
|
28
|
+
|
|
29
|
+
Fixes #10834
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- Fix HTTP SSE fallback to only trigger for 400/404/405 per MCP spec ([#10803](https://github.com/mastra-ai/mastra/pull/10803))
|
|
34
|
+
|
|
35
|
+
With @modelcontextprotocol/sdk 1.24.0+, SSE fallback now only occurs for HTTP status codes 400, 404, and 405. Other errors (like 401 Unauthorized) are re-thrown for proper handling.
|
|
36
|
+
|
|
37
|
+
Older SDK versions maintain the existing behavior (always fallback to SSE).
|
|
38
|
+
|
|
39
|
+
- Add injectable fetch into mcp client integration. Follows from modelcontextprotocol/sdk implementation of Streamable HTTP and SSE transports. ([#10780](https://github.com/mastra-ai/mastra/pull/10780))
|
|
40
|
+
|
|
41
|
+
- Updated dependencies [[`3076c67`](https://github.com/mastra-ai/mastra/commit/3076c6778b18988ae7d5c4c5c466366974b2d63f), [`85d7ee1`](https://github.com/mastra-ai/mastra/commit/85d7ee18ff4e14d625a8a30ec6656bb49804989b), [`c6c1092`](https://github.com/mastra-ai/mastra/commit/c6c1092f8fbf76109303f69e000e96fd1960c4ce), [`81dc110`](https://github.com/mastra-ai/mastra/commit/81dc11008d147cf5bdc8996ead1aa61dbdebb6fc), [`7aedb74`](https://github.com/mastra-ai/mastra/commit/7aedb74883adf66af38e270e4068fd42e7a37036), [`8f02d80`](https://github.com/mastra-ai/mastra/commit/8f02d800777397e4b45d7f1ad041988a8b0c6630), [`d7aad50`](https://github.com/mastra-ai/mastra/commit/d7aad501ce61646b76b4b511e558ac4eea9884d0), [`ce0a73a`](https://github.com/mastra-ai/mastra/commit/ce0a73abeaa75b10ca38f9e40a255a645d50ebfb), [`a02e542`](https://github.com/mastra-ai/mastra/commit/a02e542d23179bad250b044b17ff023caa61739f), [`a372c64`](https://github.com/mastra-ai/mastra/commit/a372c640ad1fd12e8f0613cebdc682fc156b4d95), [`8846867`](https://github.com/mastra-ai/mastra/commit/8846867ffa9a3746767618e314bebac08eb77d87), [`42a42cf`](https://github.com/mastra-ai/mastra/commit/42a42cf3132b9786feecbb8c13c583dce5b0e198), [`ae08bf0`](https://github.com/mastra-ai/mastra/commit/ae08bf0ebc6a4e4da992b711c4a389c32ba84cf4), [`21735a7`](https://github.com/mastra-ai/mastra/commit/21735a7ef306963554a69a89b44f06c3bcd85141), [`1d877b8`](https://github.com/mastra-ai/mastra/commit/1d877b8d7b536a251c1a7a18db7ddcf4f68d6f8b)]:
|
|
42
|
+
- @mastra/core@1.0.0-beta.7
|
|
43
|
+
|
|
44
|
+
## 1.0.0-beta.4
|
|
45
|
+
|
|
46
|
+
### Patch Changes
|
|
47
|
+
|
|
48
|
+
- Fix MCPClient automatic reconnection when session becomes invalid ([#10660](https://github.com/mastra-ai/mastra/pull/10660))
|
|
49
|
+
|
|
50
|
+
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.
|
|
51
|
+
|
|
52
|
+
This fix addresses issue #7675 where MCPClient would fail to reconnect after an MCP server went offline and came back online.
|
|
53
|
+
|
|
54
|
+
- Populate RequestContext from options.extra for workflows and agents ([#10655](https://github.com/mastra-ai/mastra/pull/10655))
|
|
55
|
+
|
|
56
|
+
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.
|
|
57
|
+
|
|
58
|
+
- Fix timeout parameter position in listTools call ([#10609](https://github.com/mastra-ai/mastra/pull/10609))
|
|
59
|
+
|
|
60
|
+
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.
|
|
61
|
+
|
|
62
|
+
- Unified MastraServer API with MCP transport routes ([#10644](https://github.com/mastra-ai/mastra/pull/10644))
|
|
63
|
+
|
|
64
|
+
**Breaking Changes:**
|
|
65
|
+
- Renamed `HonoServerAdapter` to `MastraServer` in `@mastra/hono`
|
|
66
|
+
- Renamed `ExpressServerAdapter` to `MastraServer` in `@mastra/express`
|
|
67
|
+
- Configuration now passed to constructor instead of separate method calls
|
|
68
|
+
- Renamed base class from `ServerAdapter` to `MastraServerBase` in `@mastra/server`
|
|
69
|
+
|
|
70
|
+
**New Features:**
|
|
71
|
+
- Added MCP transport routes (HTTP and SSE) to server adapters
|
|
72
|
+
- MCP endpoints available at `/api/mcp/:serverId/mcp` (HTTP) and `/api/mcp/:serverId/sse` (SSE)
|
|
73
|
+
- Added `express.json()` middleware compatibility for MCP routes
|
|
74
|
+
- Moved authentication helpers from deployer to `@mastra/server/auth`
|
|
75
|
+
|
|
76
|
+
**Testing:**
|
|
77
|
+
- Added shared MCP route and transport test suites in `@internal/server-adapter-test-utils`
|
|
78
|
+
- Added comprehensive MCP endpoint tests for both Hono and Express adapters
|
|
79
|
+
- Added GitHub Actions workflow for server adapter CI testing
|
|
80
|
+
|
|
81
|
+
- Add MCP Roots capability support (fixes #8660) ([#10646](https://github.com/mastra-ai/mastra/pull/10646))
|
|
82
|
+
|
|
83
|
+
This adds support for the MCP Roots capability, allowing clients to expose filesystem roots to MCP servers like `@modelcontextprotocol/server-filesystem`.
|
|
84
|
+
|
|
85
|
+
**New Features:**
|
|
86
|
+
- Added `roots` option to server configuration for specifying allowed directories
|
|
87
|
+
- Client automatically advertises `roots` capability when roots are configured
|
|
88
|
+
- Client handles `roots/list` requests from servers per MCP spec
|
|
89
|
+
- Added `client.roots` getter to access configured roots
|
|
90
|
+
- Added `client.setRoots()` to dynamically update roots
|
|
91
|
+
- Added `client.sendRootsListChanged()` to notify servers of root changes
|
|
92
|
+
|
|
93
|
+
**Usage:**
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
const client = new MCPClient({
|
|
97
|
+
servers: {
|
|
98
|
+
filesystem: {
|
|
99
|
+
command: 'npx',
|
|
100
|
+
args: ['-y', '@modelcontextprotocol/server-filesystem', '/tmp'],
|
|
101
|
+
roots: [
|
|
102
|
+
{ uri: 'file:///tmp', name: 'Temp Directory' },
|
|
103
|
+
{ uri: 'file:///home/user/projects', name: 'Projects' },
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Before this fix, the filesystem server would log:
|
|
111
|
+
|
|
112
|
+
> "Client does not support MCP Roots, using allowed directories set from server args"
|
|
113
|
+
|
|
114
|
+
After this fix, the server properly receives roots from the client:
|
|
115
|
+
|
|
116
|
+
> "Updated allowed directories from MCP roots: 2 valid directories"
|
|
117
|
+
|
|
118
|
+
- Add MCP progress notification support and refactor client structure ([#10637](https://github.com/mastra-ai/mastra/pull/10637))
|
|
119
|
+
- 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.
|
|
120
|
+
- Added `ProgressClientActions` class for handling progress notifications
|
|
121
|
+
- Refactored client action classes into `actions/` directory (elicitation, prompt, resource, progress)
|
|
122
|
+
- Extracted all type definitions to a dedicated `types.ts` file for better code organization
|
|
123
|
+
|
|
124
|
+
- 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)]:
|
|
125
|
+
- @mastra/core@1.0.0-beta.6
|
|
126
|
+
|
|
3
127
|
## 1.0.0-beta.3
|
|
4
128
|
|
|
5
129
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -413,9 +413,65 @@ const httpClient = new MCPClient({
|
|
|
413
413
|
|
|
414
414
|
The `authProvider` is automatically passed to both Streamable HTTP and SSE transports.
|
|
415
415
|
|
|
416
|
+
### Custom Fetch for Dynamic Authentication
|
|
417
|
+
|
|
418
|
+
For HTTP servers, you can provide a custom `fetch` function to handle dynamic authentication, request interception, or other custom behavior. This is particularly useful when you need to refresh tokens on each request or customize request behavior.
|
|
419
|
+
|
|
420
|
+
When `fetch` is provided, `requestInit`, `eventSourceInit`, and `authProvider` become optional, as you can handle these concerns within your custom fetch function.
|
|
421
|
+
|
|
422
|
+
```typescript
|
|
423
|
+
const mcpClient = new MCPClient({
|
|
424
|
+
servers: {
|
|
425
|
+
apiServer: {
|
|
426
|
+
url: new URL('https://api.example.com/mcp'),
|
|
427
|
+
fetch: async (url, init) => {
|
|
428
|
+
// Refresh token on each request
|
|
429
|
+
const token = await getAuthToken(); // Your token refresh logic
|
|
430
|
+
|
|
431
|
+
return fetch(url, {
|
|
432
|
+
...init,
|
|
433
|
+
headers: {
|
|
434
|
+
...init?.headers,
|
|
435
|
+
Authorization: `Bearer ${token}`,
|
|
436
|
+
},
|
|
437
|
+
});
|
|
438
|
+
},
|
|
439
|
+
},
|
|
440
|
+
},
|
|
441
|
+
});
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
The custom `fetch` function is automatically used for both Streamable HTTP and SSE transports, making it a simpler alternative to configuring `requestInit` and `eventSourceInit` separately.
|
|
445
|
+
|
|
416
446
|
### SSE Authentication and Headers (Legacy Fallback)
|
|
417
447
|
|
|
418
|
-
When the client falls back to using the legacy SSE (Server-Sent Events) transport and you need to include authentication or custom headers, you
|
|
448
|
+
When the client falls back to using the legacy SSE (Server-Sent Events) transport and you need to include authentication or custom headers, you have two options:
|
|
449
|
+
|
|
450
|
+
**Option 1: Using custom `fetch` (Recommended)**
|
|
451
|
+
|
|
452
|
+
The simplest approach is to provide a custom `fetch` function, which will automatically be used for both POST requests and SSE connections:
|
|
453
|
+
|
|
454
|
+
```typescript
|
|
455
|
+
const sseClient = new MCPClient({
|
|
456
|
+
servers: {
|
|
457
|
+
authenticatedSseClient: {
|
|
458
|
+
url: new URL('https://your-mcp-server.com/sse'),
|
|
459
|
+
fetch: async (url, init) => {
|
|
460
|
+
const headers = new Headers(init?.headers || {});
|
|
461
|
+
headers.set('Authorization', 'Bearer your-token');
|
|
462
|
+
return fetch(url, {
|
|
463
|
+
...init,
|
|
464
|
+
headers,
|
|
465
|
+
});
|
|
466
|
+
},
|
|
467
|
+
},
|
|
468
|
+
},
|
|
469
|
+
});
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
**Option 2: Using `requestInit` and `eventSourceInit`**
|
|
473
|
+
|
|
474
|
+
Alternatively, you can use both `requestInit` and `eventSourceInit`. The standard `requestInit` headers won't work alone because SSE connections using the browser's `EventSource` API don't support custom headers directly.
|
|
419
475
|
|
|
420
476
|
The `eventSourceInit` configuration allows you to customize the underlying fetch request used for the SSE connection, ensuring your authentication headers are properly included.
|
|
421
477
|
|
|
@@ -489,9 +545,10 @@ Here are the available options within `MastraMCPServerDefinition`:
|
|
|
489
545
|
- **`args`**: (Optional, string[]) For Stdio servers: Arguments to pass to the command.
|
|
490
546
|
- **`env`**: (Optional, Record<string, string>) For Stdio servers: Environment variables to set for the command.
|
|
491
547
|
- **`url`**: (Optional, URL) For HTTP servers (Streamable HTTP or SSE): The URL of the server.
|
|
492
|
-
- **`
|
|
493
|
-
- **`
|
|
494
|
-
- **`
|
|
548
|
+
- **`fetch`**: (Optional, FetchLike) For HTTP servers: Custom fetch implementation used for all network requests. When provided, this function will be used for all HTTP requests, allowing you to add dynamic authentication headers (e.g., refreshing bearer tokens), customize request behavior per-request, or intercept and modify requests/responses. When `fetch` is provided, `requestInit`, `eventSourceInit`, and `authProvider` become optional, as you can handle these concerns within your custom fetch function.
|
|
549
|
+
- **`requestInit`**: (Optional, RequestInit) For HTTP servers: Request configuration for the fetch API. Used for the initial Streamable HTTP connection attempt and subsequent POST requests. Also used for the initial SSE connection attempt. Optional when `fetch` is provided.
|
|
550
|
+
- **`eventSourceInit`**: (Optional, EventSourceInit) **Only** for the legacy SSE fallback: Custom fetch configuration for SSE connections. Required when using custom headers with SSE. Optional when `fetch` is provided.
|
|
551
|
+
- **`authProvider`**: (Optional, OAuthClientProvider) For HTTP servers: OAuth authentication provider for automatic token refresh. Automatically passed to both Streamable HTTP and SSE transports. Optional when `fetch` is provided.
|
|
495
552
|
- **`logger`**: (Optional, LogHandler) Optional additional handler for logging.
|
|
496
553
|
- **`timeout`**: (Optional, number) Server-specific timeout in milliseconds, overriding the global client/configuration timeout.
|
|
497
554
|
- **`capabilities`**: (Optional, ClientCapabilities) Server-specific capabilities configuration.
|
|
@@ -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,17 +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;
|
|
160
30
|
private exitHookUnsubscribe?;
|
|
161
31
|
private sigTermHandler?;
|
|
32
|
+
private _roots;
|
|
162
33
|
/** Provides access to resource operations (list, read, subscribe, etc.) */
|
|
163
34
|
readonly resources: ResourceClientActions;
|
|
164
35
|
/** Provides access to prompt operations (list, get, notifications) */
|
|
165
36
|
readonly prompts: PromptClientActions;
|
|
166
37
|
/** Provides access to elicitation operations (request handling) */
|
|
167
38
|
readonly elicitation: ElicitationClientActions;
|
|
39
|
+
/** Provides access to progress operations (notifications) */
|
|
40
|
+
readonly progress: ProgressClientActions;
|
|
168
41
|
/**
|
|
169
42
|
* @internal
|
|
170
43
|
*/
|
|
@@ -177,6 +50,44 @@ export declare class InternalMastraMCPClient extends MastraBase {
|
|
|
177
50
|
*/
|
|
178
51
|
private log;
|
|
179
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>;
|
|
180
91
|
private connectStdio;
|
|
181
92
|
private connectHttp;
|
|
182
93
|
private isConnected;
|
|
@@ -203,6 +114,32 @@ export declare class InternalMastraMCPClient extends MastraBase {
|
|
|
203
114
|
*/
|
|
204
115
|
get sessionId(): string | undefined;
|
|
205
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>;
|
|
206
143
|
listResources(): Promise<z.objectOutputType<{
|
|
207
144
|
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
|
208
145
|
} & {
|
|
@@ -415,6 +352,7 @@ export declare class InternalMastraMCPClient extends MastraBase {
|
|
|
415
352
|
setResourceUpdatedNotificationHandler(handler: (params: z.infer<typeof ResourceUpdatedNotificationSchema>['params']) => void): void;
|
|
416
353
|
setResourceListChangedNotificationHandler(handler: () => void): void;
|
|
417
354
|
setElicitationRequestHandler(handler: ElicitationHandler): void;
|
|
355
|
+
setProgressNotificationHandler(handler: ProgressHandler): void;
|
|
418
356
|
private convertInputSchema;
|
|
419
357
|
private convertOutputSchema;
|
|
420
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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,SAAS,CAAC,EACd,IAAI,EACJ,IAAI,EACJ,OAAO,GACR,EAAE;QACD,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,eAAe,CAAC;IAS5B;;;OAGG;IACH,uCAAuC,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,IAAI;IAOlE,qCAAqC,CACnC,OAAO,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAC,QAAQ,CAAC,KAAK,IAAI,GACrF,IAAI;IAOP,yCAAyC,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,IAAI;IAOpE,4BAA4B,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI;IAQ/D,8BAA8B,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;YAOhD,kBAAkB;YA0ClB,mBAAmB;IA2C3B,KAAK,IAAI,OAAO,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,iFAA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