@mastra/mcp 0.13.3 → 0.13.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 +18 -0
- package/dist/client/client.d.ts +110 -2
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/configuration.d.ts +399 -4
- package/dist/client/configuration.d.ts.map +1 -1
- package/dist/client/elicitationActions.d.ts +46 -2
- package/dist/client/elicitationActions.d.ts.map +1 -1
- package/dist/client/promptActions.d.ts +61 -10
- package/dist/client/promptActions.d.ts.map +1 -1
- package/dist/client/resourceActions.d.ts +105 -15
- package/dist/client/resourceActions.d.ts.map +1 -1
- package/dist/index.cjs +951 -78
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +951 -78
- package/dist/index.js.map +1 -1
- package/dist/server/promptActions.d.ts +21 -2
- package/dist/server/promptActions.d.ts.map +1 -1
- package/dist/server/resourceActions.d.ts +35 -4
- package/dist/server/resourceActions.d.ts.map +1 -1
- package/dist/server/server.d.ts +381 -42
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/types.d.ts +89 -0
- package/dist/server/types.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/server/types.d.ts
CHANGED
|
@@ -2,45 +2,128 @@ import type { InternalCoreTool } from '@mastra/core/tools';
|
|
|
2
2
|
import type { RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';
|
|
3
3
|
import type { ElicitRequest, ElicitResult, Prompt, PromptMessage, Resource, ResourceTemplate } from '@modelcontextprotocol/sdk/types.js';
|
|
4
4
|
import type { z } from 'zod';
|
|
5
|
+
/**
|
|
6
|
+
* Callback function to retrieve content for a specific resource.
|
|
7
|
+
*
|
|
8
|
+
* @param params - Parameters for resource content retrieval
|
|
9
|
+
* @param params.uri - URI of the resource to retrieve
|
|
10
|
+
* @param params.extra - Additional request handler context
|
|
11
|
+
* @returns Promise resolving to resource content (single or array)
|
|
12
|
+
*/
|
|
5
13
|
export type MCPServerResourceContentCallback = ({ uri, extra, }: {
|
|
6
14
|
uri: string;
|
|
7
15
|
extra: MCPRequestHandlerExtra;
|
|
8
16
|
}) => Promise<MCPServerResourceContent | MCPServerResourceContent[]>;
|
|
17
|
+
/**
|
|
18
|
+
* Content for an MCP resource, either text or binary (base64-encoded).
|
|
19
|
+
*/
|
|
9
20
|
export type MCPServerResourceContent = {
|
|
10
21
|
text?: string;
|
|
11
22
|
} | {
|
|
12
23
|
blob?: string;
|
|
13
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* Configuration for MCP server resource handling.
|
|
27
|
+
*
|
|
28
|
+
* Defines callbacks for listing resources, retrieving content, and optionally listing templates.
|
|
29
|
+
*/
|
|
14
30
|
export type MCPServerResources = {
|
|
31
|
+
/** Function to list all available resources */
|
|
15
32
|
listResources: ({ extra }: {
|
|
16
33
|
extra: MCPRequestHandlerExtra;
|
|
17
34
|
}) => Promise<Resource[]>;
|
|
35
|
+
/** Function to get content for a specific resource */
|
|
18
36
|
getResourceContent: MCPServerResourceContentCallback;
|
|
37
|
+
/** Optional function to list resource templates */
|
|
19
38
|
resourceTemplates?: ({ extra }: {
|
|
20
39
|
extra: MCPRequestHandlerExtra;
|
|
21
40
|
}) => Promise<ResourceTemplate[]>;
|
|
22
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* Callback function to retrieve messages for a specific prompt.
|
|
44
|
+
*
|
|
45
|
+
* @param params - Parameters for prompt message retrieval
|
|
46
|
+
* @param params.name - Name of the prompt
|
|
47
|
+
* @param params.version - Optional version of the prompt
|
|
48
|
+
* @param params.args - Optional arguments for the prompt
|
|
49
|
+
* @param params.extra - Additional request handler context
|
|
50
|
+
* @returns Promise resolving to array of prompt messages
|
|
51
|
+
*/
|
|
23
52
|
export type MCPServerPromptMessagesCallback = ({ name, version, args, extra, }: {
|
|
24
53
|
name: string;
|
|
25
54
|
version?: string;
|
|
26
55
|
args?: any;
|
|
27
56
|
extra: MCPRequestHandlerExtra;
|
|
28
57
|
}) => Promise<PromptMessage[]>;
|
|
58
|
+
/**
|
|
59
|
+
* Configuration for MCP server prompt handling.
|
|
60
|
+
*
|
|
61
|
+
* Defines callbacks for listing prompts and retrieving prompt messages.
|
|
62
|
+
*/
|
|
29
63
|
export type MCPServerPrompts = {
|
|
64
|
+
/** Function to list all available prompts */
|
|
30
65
|
listPrompts: ({ extra }: {
|
|
31
66
|
extra: MCPRequestHandlerExtra;
|
|
32
67
|
}) => Promise<Prompt[]>;
|
|
68
|
+
/** Optional function to get messages for a specific prompt */
|
|
33
69
|
getPromptMessages?: MCPServerPromptMessagesCallback;
|
|
34
70
|
};
|
|
71
|
+
/**
|
|
72
|
+
* Actions for handling elicitation requests (interactive user input collection).
|
|
73
|
+
*/
|
|
35
74
|
export type ElicitationActions = {
|
|
75
|
+
/** Function to send an elicitation request to the client */
|
|
36
76
|
sendRequest: (request: ElicitRequest['params']) => Promise<ElicitResult>;
|
|
37
77
|
};
|
|
78
|
+
/**
|
|
79
|
+
* Extra context passed to MCP request handlers.
|
|
80
|
+
*/
|
|
38
81
|
export type MCPRequestHandlerExtra = RequestHandlerExtra<any, any>;
|
|
82
|
+
/**
|
|
83
|
+
* Tool definition for MCP servers with support for elicitation.
|
|
84
|
+
*
|
|
85
|
+
* Extends standard Mastra tools with MCP-specific capabilities including interactive
|
|
86
|
+
* user input collection via elicitation and request context access.
|
|
87
|
+
*
|
|
88
|
+
* @template TSchemaIn - Input schema type (Zod schema or undefined)
|
|
89
|
+
* @template TSchemaOut - Output schema type (Zod schema or undefined)
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* const myTool: MCPTool<z.ZodObject<{ name: z.ZodString }>> = {
|
|
94
|
+
* id: 'greet',
|
|
95
|
+
* description: 'Greets a person',
|
|
96
|
+
* parameters: z.object({ name: z.string() }),
|
|
97
|
+
* execute: async ({ context }, { elicitation, extra }) => {
|
|
98
|
+
* // Can request additional user input during execution
|
|
99
|
+
* const userInfo = await elicitation.sendRequest({
|
|
100
|
+
* message: 'Please provide your email',
|
|
101
|
+
* requestedSchema: { type: 'object', properties: { email: { type: 'string' } } }
|
|
102
|
+
* });
|
|
103
|
+
* return `Hello ${context.name}!`;
|
|
104
|
+
* }
|
|
105
|
+
* };
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
39
108
|
export type MCPTool<TSchemaIn extends z.ZodSchema | undefined = undefined, TSchemaOut extends z.ZodSchema | undefined = undefined> = {
|
|
109
|
+
/** Optional unique identifier for the tool */
|
|
40
110
|
id?: InternalCoreTool['id'];
|
|
111
|
+
/** Optional description of what the tool does */
|
|
41
112
|
description?: InternalCoreTool['description'];
|
|
113
|
+
/** Input parameters schema (inferred from TSchemaIn if provided) */
|
|
42
114
|
parameters: TSchemaIn extends z.ZodSchema ? z.infer<TSchemaIn> : any;
|
|
115
|
+
/** Optional output schema for structured responses (inferred from TSchemaOut if provided) */
|
|
43
116
|
outputSchema?: TSchemaOut extends z.ZodSchema ? z.infer<TSchemaOut> : any;
|
|
117
|
+
/**
|
|
118
|
+
* Function that executes the tool's logic.
|
|
119
|
+
*
|
|
120
|
+
* @param params - Tool input parameters
|
|
121
|
+
* @param params.context - Validated input matching the parameters schema
|
|
122
|
+
* @param options - Execution options
|
|
123
|
+
* @param options.elicitation - Actions for requesting user input during execution
|
|
124
|
+
* @param options.extra - MCP request handler context with session information
|
|
125
|
+
* @returns Promise resolving to the tool's result
|
|
126
|
+
*/
|
|
44
127
|
execute: (params: {
|
|
45
128
|
context: TSchemaIn extends z.ZodSchema ? z.infer<TSchemaIn> : any;
|
|
46
129
|
}, options: Parameters<NonNullable<InternalCoreTool['execute']>>[1] & {
|
|
@@ -48,5 +131,11 @@ export type MCPTool<TSchemaIn extends z.ZodSchema | undefined = undefined, TSche
|
|
|
48
131
|
extra: MCPRequestHandlerExtra;
|
|
49
132
|
}) => Promise<any>;
|
|
50
133
|
};
|
|
134
|
+
/**
|
|
135
|
+
* Re-exported MCP SDK types for resource handling.
|
|
136
|
+
*
|
|
137
|
+
* - `Resource`: Represents a data resource exposed by the server
|
|
138
|
+
* - `ResourceTemplate`: URI template for dynamic resource generation
|
|
139
|
+
*/
|
|
51
140
|
export type { Resource, ResourceTemplate };
|
|
52
141
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/server/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,MAAM,EACN,aAAa,EACb,QAAQ,EACR,gBAAgB,EACjB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,MAAM,MAAM,gCAAgC,GAAG,CAAC,EAC9C,GAAG,EACH,KAAK,GACN,EAAE;IACD,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,sBAAsB,CAAC;CAC/B,KAAK,OAAO,CAAC,wBAAwB,GAAG,wBAAwB,EAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/server/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,MAAM,EACN,aAAa,EACb,QAAQ,EACR,gBAAgB,EACjB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B;;;;;;;GAOG;AACH,MAAM,MAAM,gCAAgC,GAAG,CAAC,EAC9C,GAAG,EACH,KAAK,GACN,EAAE;IACD,GAAG,EA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CAAC;AAEF;;;;;GAKG;AACH,YAAY,EAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"zod-from-json-schema-v3": "npm:zod-from-json-schema@^0.0.5"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@mastra/core": ">=0.
|
|
39
|
+
"@mastra/core": ">=0.20.1-0 <0.21.0-0",
|
|
40
40
|
"zod": "^3.25.0 || ^4.0.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
@@ -56,9 +56,9 @@
|
|
|
56
56
|
"vitest": "^3.2.4",
|
|
57
57
|
"zod": "^3.25.76",
|
|
58
58
|
"zod-to-json-schema": "^3.24.6",
|
|
59
|
-
"@internal/
|
|
60
|
-
"@internal/
|
|
61
|
-
"@mastra/core": "0.20.
|
|
59
|
+
"@internal/lint": "0.0.47",
|
|
60
|
+
"@internal/types-builder": "0.0.22",
|
|
61
|
+
"@mastra/core": "0.20.1"
|
|
62
62
|
},
|
|
63
63
|
"homepage": "https://mastra.ai",
|
|
64
64
|
"repository": {
|