@mastra/mcp 1.2.1-alpha.0 → 1.2.2-alpha.0
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 +29 -0
- package/dist/client/actions/prompt.d.ts +2 -5
- package/dist/client/actions/prompt.d.ts.map +1 -1
- package/dist/client/actions/resource.d.ts +15 -5
- package/dist/client/actions/resource.d.ts.map +1 -1
- package/dist/client/client.d.ts +1 -3
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/configuration.d.ts +57 -29
- package/dist/client/configuration.d.ts.map +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +36 -58
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +36 -58
- package/dist/index.js.map +1 -1
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/types.d.ts +21 -1
- package/dist/server/types.d.ts.map +1 -1
- package/package.json +11 -11
package/dist/index.js
CHANGED
|
@@ -117,7 +117,7 @@ var PromptClientActions = class {
|
|
|
117
117
|
* ```typescript
|
|
118
118
|
* const prompts = await client.prompts.list();
|
|
119
119
|
* prompts.forEach(prompt => {
|
|
120
|
-
* console.log(`${prompt.name}
|
|
120
|
+
* console.log(`${prompt.name}: ${prompt.description}`);
|
|
121
121
|
* });
|
|
122
122
|
* ```
|
|
123
123
|
*/
|
|
@@ -125,7 +125,7 @@ var PromptClientActions = class {
|
|
|
125
125
|
try {
|
|
126
126
|
const response = await this.client.listPrompts();
|
|
127
127
|
if (response && response.prompts && Array.isArray(response.prompts)) {
|
|
128
|
-
return response.prompts.map((prompt) => ({ ...prompt
|
|
128
|
+
return response.prompts.map((prompt) => ({ ...prompt }));
|
|
129
129
|
} else {
|
|
130
130
|
this.logger.warn(`Prompts response from server ${this.client.name} did not have expected structure.`, {
|
|
131
131
|
response
|
|
@@ -153,7 +153,6 @@ var PromptClientActions = class {
|
|
|
153
153
|
* @param params - Parameters for the prompt request
|
|
154
154
|
* @param params.name - Name of the prompt to retrieve
|
|
155
155
|
* @param params.args - Optional arguments to populate the prompt template
|
|
156
|
-
* @param params.version - Optional specific version of the prompt to retrieve
|
|
157
156
|
* @returns Promise resolving to the prompt result with messages
|
|
158
157
|
* @throws {Error} If fetching the prompt fails or prompt not found
|
|
159
158
|
*
|
|
@@ -165,19 +164,14 @@ var PromptClientActions = class {
|
|
|
165
164
|
* language: 'typescript',
|
|
166
165
|
* code: 'const x = 1;'
|
|
167
166
|
* },
|
|
168
|
-
* version: '1.0'
|
|
169
167
|
* });
|
|
170
168
|
*
|
|
171
169
|
* // Use prompt messages in AI completion
|
|
172
170
|
* console.log(prompt.messages);
|
|
173
171
|
* ```
|
|
174
172
|
*/
|
|
175
|
-
async get({
|
|
176
|
-
name,
|
|
177
|
-
args,
|
|
178
|
-
version
|
|
179
|
-
}) {
|
|
180
|
-
return this.client.getPrompt({ name, args, version });
|
|
173
|
+
async get({ name, args }) {
|
|
174
|
+
return this.client.getPrompt({ name, args });
|
|
181
175
|
}
|
|
182
176
|
/**
|
|
183
177
|
* Sets a notification handler for when the list of available prompts changes.
|
|
@@ -809,16 +803,11 @@ var InternalMastraMCPClient = class extends MastraBase {
|
|
|
809
803
|
* Get a prompt and its dynamic messages from the server.
|
|
810
804
|
* @param name The prompt name
|
|
811
805
|
* @param args Arguments for the prompt
|
|
812
|
-
* @param version (optional) The prompt version to retrieve
|
|
813
806
|
*/
|
|
814
|
-
async getPrompt({
|
|
815
|
-
name,
|
|
816
|
-
args,
|
|
817
|
-
version
|
|
818
|
-
}) {
|
|
807
|
+
async getPrompt({ name, args }) {
|
|
819
808
|
this.log("debug", `Requesting prompt from MCP server: ${name}`);
|
|
820
809
|
return await this.client.request(
|
|
821
|
-
{ method: "prompts/get", params: { name, arguments: args
|
|
810
|
+
{ method: "prompts/get", params: { name, arguments: args } },
|
|
822
811
|
GetPromptResultSchema,
|
|
823
812
|
{ timeout: this.timeout }
|
|
824
813
|
);
|
|
@@ -1520,7 +1509,6 @@ To fix this you have three different options:
|
|
|
1520
1509
|
* @param params.serverName - Name of the server to retrieve from
|
|
1521
1510
|
* @param params.name - Name of the prompt to retrieve
|
|
1522
1511
|
* @param params.args - Optional arguments to populate the prompt template
|
|
1523
|
-
* @param params.version - Optional specific version of the prompt
|
|
1524
1512
|
* @returns Promise resolving to the prompt result with messages
|
|
1525
1513
|
* @throws {MastraError} If fetching the prompt fails
|
|
1526
1514
|
*
|
|
@@ -1530,20 +1518,14 @@ To fix this you have three different options:
|
|
|
1530
1518
|
* serverName: 'weatherServer',
|
|
1531
1519
|
* name: 'forecast',
|
|
1532
1520
|
* args: { city: 'London' },
|
|
1533
|
-
* version: '1.0'
|
|
1534
1521
|
* });
|
|
1535
1522
|
* console.log(prompt.messages);
|
|
1536
1523
|
* ```
|
|
1537
1524
|
*/
|
|
1538
|
-
get: async ({
|
|
1539
|
-
serverName,
|
|
1540
|
-
name,
|
|
1541
|
-
args,
|
|
1542
|
-
version
|
|
1543
|
-
}) => {
|
|
1525
|
+
get: async ({ serverName, name, args }) => {
|
|
1544
1526
|
try {
|
|
1545
1527
|
const internalClient = await this.getConnectedClientForServer(serverName);
|
|
1546
|
-
return internalClient.prompts.get({ name, args
|
|
1528
|
+
return internalClient.prompts.get({ name, args });
|
|
1547
1529
|
} catch (error) {
|
|
1548
1530
|
throw new MastraError(
|
|
1549
1531
|
{
|
|
@@ -1996,7 +1978,7 @@ function createSimpleTokenProvider(accessToken, options) {
|
|
|
1996
1978
|
});
|
|
1997
1979
|
}
|
|
1998
1980
|
|
|
1999
|
-
// ../../node_modules/.pnpm/hono@4.12.
|
|
1981
|
+
// ../../node_modules/.pnpm/hono@4.12.8/node_modules/hono/dist/utils/stream.js
|
|
2000
1982
|
var StreamingApi = class {
|
|
2001
1983
|
writer;
|
|
2002
1984
|
encoder;
|
|
@@ -2073,7 +2055,7 @@ var StreamingApi = class {
|
|
|
2073
2055
|
}
|
|
2074
2056
|
};
|
|
2075
2057
|
|
|
2076
|
-
// ../../node_modules/.pnpm/hono@4.12.
|
|
2058
|
+
// ../../node_modules/.pnpm/hono@4.12.8/node_modules/hono/dist/helper/streaming/utils.js
|
|
2077
2059
|
var isOldBunVersion = () => {
|
|
2078
2060
|
const version = typeof Bun !== "undefined" ? Bun.version : void 0;
|
|
2079
2061
|
if (version === void 0) {
|
|
@@ -2084,7 +2066,7 @@ var isOldBunVersion = () => {
|
|
|
2084
2066
|
return result;
|
|
2085
2067
|
};
|
|
2086
2068
|
|
|
2087
|
-
// ../../node_modules/.pnpm/hono@4.12.
|
|
2069
|
+
// ../../node_modules/.pnpm/hono@4.12.8/node_modules/hono/dist/utils/html.js
|
|
2088
2070
|
var HtmlEscapedCallbackPhase = {
|
|
2089
2071
|
Stringify: 1};
|
|
2090
2072
|
var resolveCallback = async (str, phase, preserveCallbacks, context, buffer) => {
|
|
@@ -2115,7 +2097,7 @@ var resolveCallback = async (str, phase, preserveCallbacks, context, buffer) =>
|
|
|
2115
2097
|
}
|
|
2116
2098
|
};
|
|
2117
2099
|
|
|
2118
|
-
// ../../node_modules/.pnpm/hono@4.12.
|
|
2100
|
+
// ../../node_modules/.pnpm/hono@4.12.8/node_modules/hono/dist/helper/streaming/sse.js
|
|
2119
2101
|
var SSEStreamingApi = class extends StreamingApi {
|
|
2120
2102
|
constructor(writable, readable) {
|
|
2121
2103
|
super(writable, readable);
|
|
@@ -2559,8 +2541,7 @@ var MCPServer = class extends MCPServerBase {
|
|
|
2559
2541
|
this.promptOptions = opts.prompts;
|
|
2560
2542
|
const capabilities = {
|
|
2561
2543
|
tools: {},
|
|
2562
|
-
logging: { enabled: true }
|
|
2563
|
-
elicitation: {}
|
|
2544
|
+
logging: { enabled: true }
|
|
2564
2545
|
};
|
|
2565
2546
|
if (opts.resources) {
|
|
2566
2547
|
capabilities.resources = { subscribe: true, listChanged: true };
|
|
@@ -2665,8 +2646,7 @@ var MCPServer = class extends MCPServerBase {
|
|
|
2665
2646
|
createServerInstance() {
|
|
2666
2647
|
const capabilities = {
|
|
2667
2648
|
tools: {},
|
|
2668
|
-
logging: { enabled: true }
|
|
2669
|
-
elicitation: {}
|
|
2649
|
+
logging: { enabled: true }
|
|
2670
2650
|
};
|
|
2671
2651
|
if (this.resourceOptions) {
|
|
2672
2652
|
capabilities.resources = { subscribe: true, listChanged: true };
|
|
@@ -2899,17 +2879,22 @@ Provided arguments: ${JSON.stringify(request.params.arguments, null, 2)}`
|
|
|
2899
2879
|
const resourcesOrResourceContent = await capturedResourceOptions.getResourceContent({ uri, extra });
|
|
2900
2880
|
const resourcesContent = Array.isArray(resourcesOrResourceContent) ? resourcesOrResourceContent : [resourcesOrResourceContent];
|
|
2901
2881
|
const contents = resourcesContent.map((resourceContent) => {
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2882
|
+
if ("text" in resourceContent && resourceContent.text !== void 0) {
|
|
2883
|
+
return {
|
|
2884
|
+
uri: resource.uri,
|
|
2885
|
+
mimeType: resource.mimeType,
|
|
2886
|
+
text: resourceContent.text
|
|
2887
|
+
};
|
|
2908
2888
|
}
|
|
2909
|
-
|
|
2910
|
-
|
|
2889
|
+
const blob = resourceContent.blob;
|
|
2890
|
+
if (blob === void 0) {
|
|
2891
|
+
throw new Error(`Resource '${uri}' returned content with neither text nor blob`);
|
|
2911
2892
|
}
|
|
2912
|
-
return
|
|
2893
|
+
return {
|
|
2894
|
+
uri: resource.uri,
|
|
2895
|
+
mimeType: resource.mimeType,
|
|
2896
|
+
blob
|
|
2897
|
+
};
|
|
2913
2898
|
});
|
|
2914
2899
|
const duration = Date.now() - startTime;
|
|
2915
2900
|
this.logger.info(`Resource '${uri}' read successfully in ${duration}ms.`);
|
|
@@ -2965,7 +2950,7 @@ Provided arguments: ${JSON.stringify(request.params.arguments, null, 2)}`
|
|
|
2965
2950
|
this.logger.debug("Handling ListPrompts request");
|
|
2966
2951
|
if (this.definedPrompts) {
|
|
2967
2952
|
return {
|
|
2968
|
-
prompts: this.definedPrompts
|
|
2953
|
+
prompts: this.definedPrompts
|
|
2969
2954
|
};
|
|
2970
2955
|
} else {
|
|
2971
2956
|
try {
|
|
@@ -2976,7 +2961,7 @@ Provided arguments: ${JSON.stringify(request.params.arguments, null, 2)}`
|
|
|
2976
2961
|
this.definedPrompts = prompts;
|
|
2977
2962
|
this.logger.debug(`Fetched and cached ${this.definedPrompts.length} prompts.`);
|
|
2978
2963
|
return {
|
|
2979
|
-
prompts: this.definedPrompts
|
|
2964
|
+
prompts: this.definedPrompts
|
|
2980
2965
|
};
|
|
2981
2966
|
} catch (error) {
|
|
2982
2967
|
this.logger.error("Error fetching prompts via listPrompts():", {
|
|
@@ -2992,19 +2977,14 @@ Provided arguments: ${JSON.stringify(request.params.arguments, null, 2)}`
|
|
|
2992
2977
|
GetPromptRequestSchema,
|
|
2993
2978
|
async (request, extra) => {
|
|
2994
2979
|
const startTime = Date.now();
|
|
2995
|
-
const { name,
|
|
2980
|
+
const { name, arguments: args } = request.params;
|
|
2996
2981
|
if (!this.definedPrompts) {
|
|
2997
2982
|
const prompts = await this.promptOptions?.listPrompts?.({ extra });
|
|
2998
2983
|
if (!prompts) throw new Error("Failed to load prompts");
|
|
2999
2984
|
this.definedPrompts = prompts;
|
|
3000
2985
|
}
|
|
3001
|
-
|
|
3002
|
-
if (
|
|
3003
|
-
prompt = this.definedPrompts?.find((p) => p.name === name && p.version === version);
|
|
3004
|
-
} else {
|
|
3005
|
-
prompt = this.definedPrompts?.find((p) => p.name === name);
|
|
3006
|
-
}
|
|
3007
|
-
if (!prompt) throw new Error(`Prompt "${name}"${version ? ` (version ${version})` : ""} not found`);
|
|
2986
|
+
const prompt = this.definedPrompts?.find((p) => p.name === name);
|
|
2987
|
+
if (!prompt) throw new Error(`Prompt "${name}" not found`);
|
|
3008
2988
|
if (prompt.arguments) {
|
|
3009
2989
|
for (const arg of prompt.arguments) {
|
|
3010
2990
|
if (arg.required && (args?.[arg.name] === void 0 || args?.[arg.name] === null)) {
|
|
@@ -3015,13 +2995,11 @@ Provided arguments: ${JSON.stringify(request.params.arguments, null, 2)}`
|
|
|
3015
2995
|
try {
|
|
3016
2996
|
let messages = [];
|
|
3017
2997
|
if (capturedPromptOptions.getPromptMessages) {
|
|
3018
|
-
messages = await capturedPromptOptions.getPromptMessages({ name, version, args, extra });
|
|
2998
|
+
messages = await capturedPromptOptions.getPromptMessages({ name, version: prompt.version, args, extra });
|
|
3019
2999
|
}
|
|
3020
3000
|
const duration = Date.now() - startTime;
|
|
3021
|
-
this.logger.info(
|
|
3022
|
-
|
|
3023
|
-
);
|
|
3024
|
-
return { prompt, messages };
|
|
3001
|
+
this.logger.info(`Prompt '${name}' retrieved successfully in ${duration}ms.`);
|
|
3002
|
+
return { description: prompt.description, messages };
|
|
3025
3003
|
} catch (error) {
|
|
3026
3004
|
const duration = Date.now() - startTime;
|
|
3027
3005
|
this.logger.error(`Failed to get content for prompt '${name}' in ${duration}ms`, { error });
|