@mastra/mcp 0.10.5-alpha.1 → 0.10.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/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +38 -0
- package/dist/_tsup-dts-rollup.d.cts +84 -51
- package/dist/_tsup-dts-rollup.d.ts +84 -51
- package/dist/index.cjs +403 -398
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +404 -399
- package/integration-tests/node_modules/.bin/mastra +21 -0
- package/package.json +3 -3
- package/src/client/client.test.ts +310 -1
- package/src/client/client.ts +21 -2
- package/src/client/configuration.ts +22 -2
- package/src/client/elicitationActions.ts +26 -0
- package/src/client/index.ts +1 -1
- package/src/server/server.test.ts +349 -0
- package/src/server/server.ts +424 -457
- package/src/server/types.ts +25 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/mcp@0.10.5-alpha.
|
|
2
|
+
> @mastra/mcp@0.10.5-alpha.2 build /home/runner/work/mastra/mastra/packages/mcp
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
7
|
[34mCLI[39m tsup v8.5.0
|
|
8
8
|
[34mTSC[39m Build start
|
|
9
|
-
[32mTSC[39m ⚡️ Build success in
|
|
9
|
+
[32mTSC[39m ⚡️ Build success in 21277ms
|
|
10
10
|
[34mDTS[39m Build start
|
|
11
11
|
[34mCLI[39m Target: es2022
|
|
12
12
|
Analysis will use the bundled TypeScript version 5.8.3
|
|
13
13
|
[36mWriting package typings: /home/runner/work/mastra/mastra/packages/mcp/dist/_tsup-dts-rollup.d.ts[39m
|
|
14
14
|
Analysis will use the bundled TypeScript version 5.8.3
|
|
15
15
|
[36mWriting package typings: /home/runner/work/mastra/mastra/packages/mcp/dist/_tsup-dts-rollup.d.cts[39m
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 30216ms
|
|
17
17
|
[34mCLI[39m Cleaning output folder
|
|
18
18
|
[34mESM[39m Build start
|
|
19
19
|
[34mCJS[39m Build start
|
|
20
|
-
[32mESM[39m [1mdist/index.js [22m[
|
|
21
|
-
[32mESM[39m ⚡️ Build success in
|
|
22
|
-
[32mCJS[39m [1mdist/index.cjs [22m[
|
|
23
|
-
[32mCJS[39m ⚡️ Build success in
|
|
20
|
+
[32mESM[39m [1mdist/index.js [22m[32m88.67 KB[39m
|
|
21
|
+
[32mESM[39m ⚡️ Build success in 2174ms
|
|
22
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m89.35 KB[39m
|
|
23
|
+
[32mCJS[39m ⚡️ Build success in 2174ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# @mastra/mcp
|
|
2
2
|
|
|
3
|
+
## 0.10.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ee93d96: dependencies updates:
|
|
8
|
+
- Updated dependency [`@modelcontextprotocol/sdk@^1.12.3` ↗︎](https://www.npmjs.com/package/@modelcontextprotocol/sdk/v/1.12.3) (from `^1.12.1`, in `dependencies`)
|
|
9
|
+
- c00039d: dependencies updates:
|
|
10
|
+
- Updated dependency [`@modelcontextprotocol/sdk@^1.13.0` ↗︎](https://www.npmjs.com/package/@modelcontextprotocol/sdk/v/1.13.0) (from `^1.12.3`, in `dependencies`)
|
|
11
|
+
- 4d21bf2: throw mastra errors for MCP
|
|
12
|
+
- 07d6d88: Bump MCP SDK version and add tool output schema support to MCPServer and MCPClient
|
|
13
|
+
- dc93062: Add elicitation support to MCPServer and MCPClient. Also fixes connectivity issues between multiple MCPClient instances and an MCPServer.
|
|
14
|
+
- Updated dependencies [15e9d26]
|
|
15
|
+
- Updated dependencies [d1baedb]
|
|
16
|
+
- Updated dependencies [d8f2d19]
|
|
17
|
+
- Updated dependencies [4d21bf2]
|
|
18
|
+
- Updated dependencies [07d6d88]
|
|
19
|
+
- Updated dependencies [9d52b17]
|
|
20
|
+
- Updated dependencies [2097952]
|
|
21
|
+
- Updated dependencies [792c4c0]
|
|
22
|
+
- Updated dependencies [5d74aab]
|
|
23
|
+
- Updated dependencies [a8b194f]
|
|
24
|
+
- Updated dependencies [4fb0cc2]
|
|
25
|
+
- Updated dependencies [d2a7a31]
|
|
26
|
+
- Updated dependencies [502fe05]
|
|
27
|
+
- Updated dependencies [144eb0b]
|
|
28
|
+
- Updated dependencies [8ba1b51]
|
|
29
|
+
- Updated dependencies [4efcfa0]
|
|
30
|
+
- Updated dependencies [0e17048]
|
|
31
|
+
- @mastra/core@0.10.7
|
|
32
|
+
|
|
33
|
+
## 0.10.5-alpha.2
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- dc93062: Add elicitation support to MCPServer and MCPClient. Also fixes connectivity issues between multiple MCPClient instances and an MCPServer.
|
|
38
|
+
- Updated dependencies [a8b194f]
|
|
39
|
+
- @mastra/core@0.10.7-alpha.4
|
|
40
|
+
|
|
3
41
|
## 0.10.5-alpha.1
|
|
4
42
|
|
|
5
43
|
### Patch Changes
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import type { Agent } from '@mastra/core/agent';
|
|
2
2
|
import type { ClientCapabilities } from '@modelcontextprotocol/sdk/types.js';
|
|
3
3
|
import type { ConvertedTool } from '@mastra/core/mcp';
|
|
4
|
+
import type { ElicitRequest } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
+
import type { ElicitResult } from '@modelcontextprotocol/sdk/types.js';
|
|
4
6
|
import type { GetPromptResult } from '@modelcontextprotocol/sdk/types.js';
|
|
5
7
|
import type * as http from 'node:http';
|
|
6
8
|
import type { IMastraLogger } from '@mastra/core/logger';
|
|
9
|
+
import type { InternalCoreTool } from '@mastra/core';
|
|
7
10
|
import type { ListPromptsResult } from '@modelcontextprotocol/sdk/types.js';
|
|
8
11
|
import { LoggingLevel } from '@modelcontextprotocol/sdk/types.js';
|
|
9
12
|
import { MastraBase } from '@mastra/core/base';
|
|
@@ -52,6 +55,34 @@ declare type BaseServerOptions = {
|
|
|
52
55
|
enableServerLogs?: boolean;
|
|
53
56
|
};
|
|
54
57
|
|
|
58
|
+
declare type ElicitationActions = {
|
|
59
|
+
sendRequest: (request: ElicitRequest['params']) => Promise<ElicitResult>;
|
|
60
|
+
};
|
|
61
|
+
export { ElicitationActions }
|
|
62
|
+
export { ElicitationActions as ElicitationActions_alias_1 }
|
|
63
|
+
export { ElicitationActions as ElicitationActions_alias_2 }
|
|
64
|
+
|
|
65
|
+
export declare class ElicitationClientActions {
|
|
66
|
+
private readonly client;
|
|
67
|
+
private readonly logger;
|
|
68
|
+
constructor({ client, logger }: ElicitationClientActionsConfig);
|
|
69
|
+
/**
|
|
70
|
+
* Set a handler for elicitation requests.
|
|
71
|
+
* @param handler The callback function to handle the elicitation request.
|
|
72
|
+
*/
|
|
73
|
+
onRequest(handler: (request: ElicitRequest['params']) => Promise<ElicitResult>): void;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
declare interface ElicitationClientActionsConfig {
|
|
77
|
+
client: InternalMastraMCPClient;
|
|
78
|
+
logger: IMastraLogger;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
declare type ElicitationHandler = (request: ElicitRequest['params']) => Promise<ElicitResult>;
|
|
82
|
+
export { ElicitationHandler }
|
|
83
|
+
export { ElicitationHandler as ElicitationHandler_alias_1 }
|
|
84
|
+
export { ElicitationHandler as ElicitationHandler_alias_2 }
|
|
85
|
+
|
|
55
86
|
declare type HttpServerDefinition = BaseServerOptions & {
|
|
56
87
|
url: URL;
|
|
57
88
|
command?: never;
|
|
@@ -74,6 +105,7 @@ export declare class InternalMastraMCPClient extends MastraBase {
|
|
|
74
105
|
private currentOperationContext;
|
|
75
106
|
readonly resources: ResourceClientActions;
|
|
76
107
|
readonly prompts: PromptClientActions;
|
|
108
|
+
readonly elicitation: ElicitationClientActions;
|
|
77
109
|
constructor({ name, version, server, capabilities, timeout, }: InternalMastraMCPClientOptions);
|
|
78
110
|
/**
|
|
79
111
|
* Log a message at the specified level
|
|
@@ -220,6 +252,7 @@ export declare class InternalMastraMCPClient extends MastraBase {
|
|
|
220
252
|
setPromptListChangedNotificationHandler(handler: () => void): void;
|
|
221
253
|
setResourceUpdatedNotificationHandler(handler: (params: z.infer<typeof ResourceUpdatedNotificationSchema>['params']) => void): void;
|
|
222
254
|
setResourceListChangedNotificationHandler(handler: () => void): void;
|
|
255
|
+
setElicitationRequestHandler(handler: ElicitationHandler): void;
|
|
223
256
|
private convertInputSchema;
|
|
224
257
|
private convertOutputSchema;
|
|
225
258
|
tools(): Promise<Record<string, any>>;
|
|
@@ -276,6 +309,9 @@ declare class MCPClient extends MastraBase {
|
|
|
276
309
|
private mcpClientsById;
|
|
277
310
|
private disconnectPromise;
|
|
278
311
|
constructor(args: MCPClientOptions);
|
|
312
|
+
get elicitation(): {
|
|
313
|
+
onRequest: (serverName: string, handler: (request: ElicitRequest["params"]) => Promise<ElicitResult>) => Promise<void>;
|
|
314
|
+
};
|
|
279
315
|
get resources(): {
|
|
280
316
|
list: () => Promise<Record<string, Resource[]>>;
|
|
281
317
|
templates: () => Promise<Record<string, ResourceTemplate[]>>;
|
|
@@ -338,7 +374,6 @@ declare class MCPClient extends MastraBase {
|
|
|
338
374
|
[x: string]: unknown;
|
|
339
375
|
messages: {
|
|
340
376
|
[x: string]: unknown;
|
|
341
|
-
role: "user" | "assistant";
|
|
342
377
|
content: {
|
|
343
378
|
[x: string]: unknown;
|
|
344
379
|
type: "text";
|
|
@@ -364,14 +399,14 @@ declare class MCPClient extends MastraBase {
|
|
|
364
399
|
} | undefined;
|
|
365
400
|
} | {
|
|
366
401
|
[x: string]: unknown;
|
|
367
|
-
name: string;
|
|
368
402
|
type: "resource_link";
|
|
403
|
+
name: string;
|
|
369
404
|
uri: string;
|
|
370
|
-
title?: string | undefined;
|
|
371
|
-
description?: string | undefined;
|
|
372
405
|
_meta?: {
|
|
373
406
|
[x: string]: unknown;
|
|
374
407
|
} | undefined;
|
|
408
|
+
title?: string | undefined;
|
|
409
|
+
description?: string | undefined;
|
|
375
410
|
mimeType?: string | undefined;
|
|
376
411
|
} | {
|
|
377
412
|
[x: string]: unknown;
|
|
@@ -397,11 +432,12 @@ declare class MCPClient extends MastraBase {
|
|
|
397
432
|
[x: string]: unknown;
|
|
398
433
|
} | undefined;
|
|
399
434
|
};
|
|
435
|
+
role: "user" | "assistant";
|
|
400
436
|
}[];
|
|
401
|
-
description?: string | undefined;
|
|
402
437
|
_meta?: {
|
|
403
438
|
[x: string]: unknown;
|
|
404
439
|
} | undefined;
|
|
440
|
+
description?: string | undefined;
|
|
405
441
|
}>;
|
|
406
442
|
onListChanged: (serverName: string, handler: () => void) => Promise<void>;
|
|
407
443
|
};
|
|
@@ -417,11 +453,11 @@ declare class MCPClient extends MastraBase {
|
|
|
417
453
|
[x: string]: unknown;
|
|
418
454
|
name: string;
|
|
419
455
|
uri: string;
|
|
420
|
-
title?: string | undefined;
|
|
421
|
-
description?: string | undefined;
|
|
422
456
|
_meta?: {
|
|
423
457
|
[x: string]: unknown;
|
|
424
458
|
} | undefined;
|
|
459
|
+
title?: string | undefined;
|
|
460
|
+
description?: string | undefined;
|
|
425
461
|
mimeType?: string | undefined;
|
|
426
462
|
}[]>>;
|
|
427
463
|
/**
|
|
@@ -474,15 +510,7 @@ declare class MCPServer extends MCPServerBase {
|
|
|
474
510
|
private sseTransport?;
|
|
475
511
|
private sseHonoTransports;
|
|
476
512
|
private streamableHTTPTransports;
|
|
477
|
-
private
|
|
478
|
-
private callToolHandlerIsRegistered;
|
|
479
|
-
private listResourcesHandlerIsRegistered;
|
|
480
|
-
private readResourceHandlerIsRegistered;
|
|
481
|
-
private listResourceTemplatesHandlerIsRegistered;
|
|
482
|
-
private subscribeResourceHandlerIsRegistered;
|
|
483
|
-
private unsubscribeResourceHandlerIsRegistered;
|
|
484
|
-
private listPromptsHandlerIsRegistered;
|
|
485
|
-
private getPromptHandlerIsRegistered;
|
|
513
|
+
private httpServerInstances;
|
|
486
514
|
private definedResources?;
|
|
487
515
|
private definedResourceTemplates?;
|
|
488
516
|
private resourceOptions?;
|
|
@@ -491,6 +519,7 @@ declare class MCPServer extends MCPServerBase {
|
|
|
491
519
|
private subscriptions;
|
|
492
520
|
readonly resources: ServerResourceActions;
|
|
493
521
|
readonly prompts: ServerPromptActions;
|
|
522
|
+
readonly elicitation: ElicitationActions;
|
|
494
523
|
/**
|
|
495
524
|
* Get the current stdio transport.
|
|
496
525
|
*/
|
|
@@ -515,53 +544,44 @@ declare class MCPServer extends MCPServerBase {
|
|
|
515
544
|
resources?: MCPServerResources;
|
|
516
545
|
prompts?: MCPServerPrompts;
|
|
517
546
|
});
|
|
518
|
-
private convertAgentsToTools;
|
|
519
|
-
private convertWorkflowsToTools;
|
|
520
|
-
/**
|
|
521
|
-
* Convert and validate all provided tools, logging registration status.
|
|
522
|
-
* Also converts agents and workflows into tools.
|
|
523
|
-
* @param tools Tool definitions
|
|
524
|
-
* @param agentsConfig Agent definitions to be converted to tools, expected from MCPServerConfig
|
|
525
|
-
* @param workflowsConfig Workflow definitions to be converted to tools, expected from MCPServerConfig
|
|
526
|
-
* @returns Converted tools registry
|
|
527
|
-
*/
|
|
528
|
-
convertTools(tools: ToolsInput, agentsConfig?: Record<string, Agent>, workflowsConfig?: Record<string, Workflow>): Record<string, ConvertedTool>;
|
|
529
|
-
/**
|
|
530
|
-
* Register the ListTools handler for listing all available tools.
|
|
531
|
-
*/
|
|
532
|
-
private registerListToolsHandler;
|
|
533
|
-
/**
|
|
534
|
-
* Register the CallTool handler for executing a tool by name.
|
|
535
|
-
*/
|
|
536
|
-
private registerCallToolHandler;
|
|
537
547
|
/**
|
|
538
|
-
*
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
*
|
|
548
|
+
* Handle an elicitation request by sending it to the connected client.
|
|
549
|
+
* This method sends an elicitation/create request to the client and waits for the response.
|
|
550
|
+
*
|
|
551
|
+
* @param request - The elicitation request containing message and schema
|
|
552
|
+
* @param serverInstance - Optional server instance to use; defaults to main server for backward compatibility
|
|
553
|
+
* @returns Promise that resolves to the client's response
|
|
543
554
|
*/
|
|
544
|
-
private
|
|
555
|
+
private handleElicitationRequest;
|
|
545
556
|
/**
|
|
546
|
-
*
|
|
557
|
+
* Creates a new Server instance configured with all handlers for HTTP sessions.
|
|
558
|
+
* Each HTTP client connection gets its own Server instance to avoid routing conflicts.
|
|
547
559
|
*/
|
|
548
|
-
private
|
|
560
|
+
private createServerInstance;
|
|
549
561
|
/**
|
|
550
|
-
*
|
|
562
|
+
* Registers all MCP handlers on a given server instance.
|
|
563
|
+
* This allows us to create multiple server instances with identical functionality.
|
|
551
564
|
*/
|
|
552
|
-
private
|
|
565
|
+
private registerHandlersOnServer;
|
|
553
566
|
/**
|
|
554
|
-
*
|
|
567
|
+
* Registers resource-related handlers on a server instance.
|
|
555
568
|
*/
|
|
556
|
-
private
|
|
569
|
+
private registerResourceHandlersOnServer;
|
|
557
570
|
/**
|
|
558
|
-
*
|
|
571
|
+
* Registers prompt-related handlers on a server instance.
|
|
559
572
|
*/
|
|
560
|
-
private
|
|
573
|
+
private registerPromptHandlersOnServer;
|
|
574
|
+
private convertAgentsToTools;
|
|
575
|
+
private convertWorkflowsToTools;
|
|
561
576
|
/**
|
|
562
|
-
*
|
|
577
|
+
* Convert and validate all provided tools, logging registration status.
|
|
578
|
+
* Also converts agents and workflows into tools.
|
|
579
|
+
* @param tools Tool definitions
|
|
580
|
+
* @param agentsConfig Agent definitions to be converted to tools, expected from MCPServerConfig
|
|
581
|
+
* @param workflowsConfig Workflow definitions to be converted to tools, expected from MCPServerConfig
|
|
582
|
+
* @returns Converted tools registry
|
|
563
583
|
*/
|
|
564
|
-
|
|
584
|
+
convertTools(tools: ToolsInput, agentsConfig?: Record<string, Agent>, workflowsConfig?: Record<string, Workflow>): Record<string, ConvertedTool>;
|
|
565
585
|
/**
|
|
566
586
|
* Start the MCP server using stdio transport (for Windsurf integration).
|
|
567
587
|
*/
|
|
@@ -713,6 +733,19 @@ export { MCPServerResources }
|
|
|
713
733
|
export { MCPServerResources as MCPServerResources_alias_1 }
|
|
714
734
|
export { MCPServerResources as MCPServerResources_alias_2 }
|
|
715
735
|
|
|
736
|
+
declare type MCPTool = {
|
|
737
|
+
id?: InternalCoreTool['id'];
|
|
738
|
+
description?: InternalCoreTool['description'];
|
|
739
|
+
parameters: InternalCoreTool['parameters'];
|
|
740
|
+
outputSchema?: InternalCoreTool['outputSchema'];
|
|
741
|
+
execute: (params: any, options: Parameters<NonNullable<InternalCoreTool['execute']>>[1] & {
|
|
742
|
+
elicitation: ElicitationActions;
|
|
743
|
+
}) => Promise<any>;
|
|
744
|
+
};
|
|
745
|
+
export { MCPTool }
|
|
746
|
+
export { MCPTool as MCPTool_alias_1 }
|
|
747
|
+
export { MCPTool as MCPTool_alias_2 }
|
|
748
|
+
|
|
716
749
|
/**
|
|
717
750
|
* Client-side prompt actions for listing, getting, and subscribing to prompt changes.
|
|
718
751
|
*/
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import type { Agent } from '@mastra/core/agent';
|
|
2
2
|
import type { ClientCapabilities } from '@modelcontextprotocol/sdk/types.js';
|
|
3
3
|
import type { ConvertedTool } from '@mastra/core/mcp';
|
|
4
|
+
import type { ElicitRequest } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
+
import type { ElicitResult } from '@modelcontextprotocol/sdk/types.js';
|
|
4
6
|
import type { GetPromptResult } from '@modelcontextprotocol/sdk/types.js';
|
|
5
7
|
import type * as http from 'node:http';
|
|
6
8
|
import type { IMastraLogger } from '@mastra/core/logger';
|
|
9
|
+
import type { InternalCoreTool } from '@mastra/core';
|
|
7
10
|
import type { ListPromptsResult } from '@modelcontextprotocol/sdk/types.js';
|
|
8
11
|
import { LoggingLevel } from '@modelcontextprotocol/sdk/types.js';
|
|
9
12
|
import { MastraBase } from '@mastra/core/base';
|
|
@@ -52,6 +55,34 @@ declare type BaseServerOptions = {
|
|
|
52
55
|
enableServerLogs?: boolean;
|
|
53
56
|
};
|
|
54
57
|
|
|
58
|
+
declare type ElicitationActions = {
|
|
59
|
+
sendRequest: (request: ElicitRequest['params']) => Promise<ElicitResult>;
|
|
60
|
+
};
|
|
61
|
+
export { ElicitationActions }
|
|
62
|
+
export { ElicitationActions as ElicitationActions_alias_1 }
|
|
63
|
+
export { ElicitationActions as ElicitationActions_alias_2 }
|
|
64
|
+
|
|
65
|
+
export declare class ElicitationClientActions {
|
|
66
|
+
private readonly client;
|
|
67
|
+
private readonly logger;
|
|
68
|
+
constructor({ client, logger }: ElicitationClientActionsConfig);
|
|
69
|
+
/**
|
|
70
|
+
* Set a handler for elicitation requests.
|
|
71
|
+
* @param handler The callback function to handle the elicitation request.
|
|
72
|
+
*/
|
|
73
|
+
onRequest(handler: (request: ElicitRequest['params']) => Promise<ElicitResult>): void;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
declare interface ElicitationClientActionsConfig {
|
|
77
|
+
client: InternalMastraMCPClient;
|
|
78
|
+
logger: IMastraLogger;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
declare type ElicitationHandler = (request: ElicitRequest['params']) => Promise<ElicitResult>;
|
|
82
|
+
export { ElicitationHandler }
|
|
83
|
+
export { ElicitationHandler as ElicitationHandler_alias_1 }
|
|
84
|
+
export { ElicitationHandler as ElicitationHandler_alias_2 }
|
|
85
|
+
|
|
55
86
|
declare type HttpServerDefinition = BaseServerOptions & {
|
|
56
87
|
url: URL;
|
|
57
88
|
command?: never;
|
|
@@ -74,6 +105,7 @@ export declare class InternalMastraMCPClient extends MastraBase {
|
|
|
74
105
|
private currentOperationContext;
|
|
75
106
|
readonly resources: ResourceClientActions;
|
|
76
107
|
readonly prompts: PromptClientActions;
|
|
108
|
+
readonly elicitation: ElicitationClientActions;
|
|
77
109
|
constructor({ name, version, server, capabilities, timeout, }: InternalMastraMCPClientOptions);
|
|
78
110
|
/**
|
|
79
111
|
* Log a message at the specified level
|
|
@@ -220,6 +252,7 @@ export declare class InternalMastraMCPClient extends MastraBase {
|
|
|
220
252
|
setPromptListChangedNotificationHandler(handler: () => void): void;
|
|
221
253
|
setResourceUpdatedNotificationHandler(handler: (params: z.infer<typeof ResourceUpdatedNotificationSchema>['params']) => void): void;
|
|
222
254
|
setResourceListChangedNotificationHandler(handler: () => void): void;
|
|
255
|
+
setElicitationRequestHandler(handler: ElicitationHandler): void;
|
|
223
256
|
private convertInputSchema;
|
|
224
257
|
private convertOutputSchema;
|
|
225
258
|
tools(): Promise<Record<string, any>>;
|
|
@@ -276,6 +309,9 @@ declare class MCPClient extends MastraBase {
|
|
|
276
309
|
private mcpClientsById;
|
|
277
310
|
private disconnectPromise;
|
|
278
311
|
constructor(args: MCPClientOptions);
|
|
312
|
+
get elicitation(): {
|
|
313
|
+
onRequest: (serverName: string, handler: (request: ElicitRequest["params"]) => Promise<ElicitResult>) => Promise<void>;
|
|
314
|
+
};
|
|
279
315
|
get resources(): {
|
|
280
316
|
list: () => Promise<Record<string, Resource[]>>;
|
|
281
317
|
templates: () => Promise<Record<string, ResourceTemplate[]>>;
|
|
@@ -338,7 +374,6 @@ declare class MCPClient extends MastraBase {
|
|
|
338
374
|
[x: string]: unknown;
|
|
339
375
|
messages: {
|
|
340
376
|
[x: string]: unknown;
|
|
341
|
-
role: "user" | "assistant";
|
|
342
377
|
content: {
|
|
343
378
|
[x: string]: unknown;
|
|
344
379
|
type: "text";
|
|
@@ -364,14 +399,14 @@ declare class MCPClient extends MastraBase {
|
|
|
364
399
|
} | undefined;
|
|
365
400
|
} | {
|
|
366
401
|
[x: string]: unknown;
|
|
367
|
-
name: string;
|
|
368
402
|
type: "resource_link";
|
|
403
|
+
name: string;
|
|
369
404
|
uri: string;
|
|
370
|
-
title?: string | undefined;
|
|
371
|
-
description?: string | undefined;
|
|
372
405
|
_meta?: {
|
|
373
406
|
[x: string]: unknown;
|
|
374
407
|
} | undefined;
|
|
408
|
+
title?: string | undefined;
|
|
409
|
+
description?: string | undefined;
|
|
375
410
|
mimeType?: string | undefined;
|
|
376
411
|
} | {
|
|
377
412
|
[x: string]: unknown;
|
|
@@ -397,11 +432,12 @@ declare class MCPClient extends MastraBase {
|
|
|
397
432
|
[x: string]: unknown;
|
|
398
433
|
} | undefined;
|
|
399
434
|
};
|
|
435
|
+
role: "user" | "assistant";
|
|
400
436
|
}[];
|
|
401
|
-
description?: string | undefined;
|
|
402
437
|
_meta?: {
|
|
403
438
|
[x: string]: unknown;
|
|
404
439
|
} | undefined;
|
|
440
|
+
description?: string | undefined;
|
|
405
441
|
}>;
|
|
406
442
|
onListChanged: (serverName: string, handler: () => void) => Promise<void>;
|
|
407
443
|
};
|
|
@@ -417,11 +453,11 @@ declare class MCPClient extends MastraBase {
|
|
|
417
453
|
[x: string]: unknown;
|
|
418
454
|
name: string;
|
|
419
455
|
uri: string;
|
|
420
|
-
title?: string | undefined;
|
|
421
|
-
description?: string | undefined;
|
|
422
456
|
_meta?: {
|
|
423
457
|
[x: string]: unknown;
|
|
424
458
|
} | undefined;
|
|
459
|
+
title?: string | undefined;
|
|
460
|
+
description?: string | undefined;
|
|
425
461
|
mimeType?: string | undefined;
|
|
426
462
|
}[]>>;
|
|
427
463
|
/**
|
|
@@ -474,15 +510,7 @@ declare class MCPServer extends MCPServerBase {
|
|
|
474
510
|
private sseTransport?;
|
|
475
511
|
private sseHonoTransports;
|
|
476
512
|
private streamableHTTPTransports;
|
|
477
|
-
private
|
|
478
|
-
private callToolHandlerIsRegistered;
|
|
479
|
-
private listResourcesHandlerIsRegistered;
|
|
480
|
-
private readResourceHandlerIsRegistered;
|
|
481
|
-
private listResourceTemplatesHandlerIsRegistered;
|
|
482
|
-
private subscribeResourceHandlerIsRegistered;
|
|
483
|
-
private unsubscribeResourceHandlerIsRegistered;
|
|
484
|
-
private listPromptsHandlerIsRegistered;
|
|
485
|
-
private getPromptHandlerIsRegistered;
|
|
513
|
+
private httpServerInstances;
|
|
486
514
|
private definedResources?;
|
|
487
515
|
private definedResourceTemplates?;
|
|
488
516
|
private resourceOptions?;
|
|
@@ -491,6 +519,7 @@ declare class MCPServer extends MCPServerBase {
|
|
|
491
519
|
private subscriptions;
|
|
492
520
|
readonly resources: ServerResourceActions;
|
|
493
521
|
readonly prompts: ServerPromptActions;
|
|
522
|
+
readonly elicitation: ElicitationActions;
|
|
494
523
|
/**
|
|
495
524
|
* Get the current stdio transport.
|
|
496
525
|
*/
|
|
@@ -515,53 +544,44 @@ declare class MCPServer extends MCPServerBase {
|
|
|
515
544
|
resources?: MCPServerResources;
|
|
516
545
|
prompts?: MCPServerPrompts;
|
|
517
546
|
});
|
|
518
|
-
private convertAgentsToTools;
|
|
519
|
-
private convertWorkflowsToTools;
|
|
520
|
-
/**
|
|
521
|
-
* Convert and validate all provided tools, logging registration status.
|
|
522
|
-
* Also converts agents and workflows into tools.
|
|
523
|
-
* @param tools Tool definitions
|
|
524
|
-
* @param agentsConfig Agent definitions to be converted to tools, expected from MCPServerConfig
|
|
525
|
-
* @param workflowsConfig Workflow definitions to be converted to tools, expected from MCPServerConfig
|
|
526
|
-
* @returns Converted tools registry
|
|
527
|
-
*/
|
|
528
|
-
convertTools(tools: ToolsInput, agentsConfig?: Record<string, Agent>, workflowsConfig?: Record<string, Workflow>): Record<string, ConvertedTool>;
|
|
529
|
-
/**
|
|
530
|
-
* Register the ListTools handler for listing all available tools.
|
|
531
|
-
*/
|
|
532
|
-
private registerListToolsHandler;
|
|
533
|
-
/**
|
|
534
|
-
* Register the CallTool handler for executing a tool by name.
|
|
535
|
-
*/
|
|
536
|
-
private registerCallToolHandler;
|
|
537
547
|
/**
|
|
538
|
-
*
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
*
|
|
548
|
+
* Handle an elicitation request by sending it to the connected client.
|
|
549
|
+
* This method sends an elicitation/create request to the client and waits for the response.
|
|
550
|
+
*
|
|
551
|
+
* @param request - The elicitation request containing message and schema
|
|
552
|
+
* @param serverInstance - Optional server instance to use; defaults to main server for backward compatibility
|
|
553
|
+
* @returns Promise that resolves to the client's response
|
|
543
554
|
*/
|
|
544
|
-
private
|
|
555
|
+
private handleElicitationRequest;
|
|
545
556
|
/**
|
|
546
|
-
*
|
|
557
|
+
* Creates a new Server instance configured with all handlers for HTTP sessions.
|
|
558
|
+
* Each HTTP client connection gets its own Server instance to avoid routing conflicts.
|
|
547
559
|
*/
|
|
548
|
-
private
|
|
560
|
+
private createServerInstance;
|
|
549
561
|
/**
|
|
550
|
-
*
|
|
562
|
+
* Registers all MCP handlers on a given server instance.
|
|
563
|
+
* This allows us to create multiple server instances with identical functionality.
|
|
551
564
|
*/
|
|
552
|
-
private
|
|
565
|
+
private registerHandlersOnServer;
|
|
553
566
|
/**
|
|
554
|
-
*
|
|
567
|
+
* Registers resource-related handlers on a server instance.
|
|
555
568
|
*/
|
|
556
|
-
private
|
|
569
|
+
private registerResourceHandlersOnServer;
|
|
557
570
|
/**
|
|
558
|
-
*
|
|
571
|
+
* Registers prompt-related handlers on a server instance.
|
|
559
572
|
*/
|
|
560
|
-
private
|
|
573
|
+
private registerPromptHandlersOnServer;
|
|
574
|
+
private convertAgentsToTools;
|
|
575
|
+
private convertWorkflowsToTools;
|
|
561
576
|
/**
|
|
562
|
-
*
|
|
577
|
+
* Convert and validate all provided tools, logging registration status.
|
|
578
|
+
* Also converts agents and workflows into tools.
|
|
579
|
+
* @param tools Tool definitions
|
|
580
|
+
* @param agentsConfig Agent definitions to be converted to tools, expected from MCPServerConfig
|
|
581
|
+
* @param workflowsConfig Workflow definitions to be converted to tools, expected from MCPServerConfig
|
|
582
|
+
* @returns Converted tools registry
|
|
563
583
|
*/
|
|
564
|
-
|
|
584
|
+
convertTools(tools: ToolsInput, agentsConfig?: Record<string, Agent>, workflowsConfig?: Record<string, Workflow>): Record<string, ConvertedTool>;
|
|
565
585
|
/**
|
|
566
586
|
* Start the MCP server using stdio transport (for Windsurf integration).
|
|
567
587
|
*/
|
|
@@ -713,6 +733,19 @@ export { MCPServerResources }
|
|
|
713
733
|
export { MCPServerResources as MCPServerResources_alias_1 }
|
|
714
734
|
export { MCPServerResources as MCPServerResources_alias_2 }
|
|
715
735
|
|
|
736
|
+
declare type MCPTool = {
|
|
737
|
+
id?: InternalCoreTool['id'];
|
|
738
|
+
description?: InternalCoreTool['description'];
|
|
739
|
+
parameters: InternalCoreTool['parameters'];
|
|
740
|
+
outputSchema?: InternalCoreTool['outputSchema'];
|
|
741
|
+
execute: (params: any, options: Parameters<NonNullable<InternalCoreTool['execute']>>[1] & {
|
|
742
|
+
elicitation: ElicitationActions;
|
|
743
|
+
}) => Promise<any>;
|
|
744
|
+
};
|
|
745
|
+
export { MCPTool }
|
|
746
|
+
export { MCPTool as MCPTool_alias_1 }
|
|
747
|
+
export { MCPTool as MCPTool_alias_2 }
|
|
748
|
+
|
|
716
749
|
/**
|
|
717
750
|
* Client-side prompt actions for listing, getting, and subscribing to prompt changes.
|
|
718
751
|
*/
|