@mastra/mcp 1.0.1 → 1.0.2
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 +22 -0
- package/dist/client/client.d.ts.map +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-mcp-overview.md +81 -78
- package/dist/docs/references/docs-mcp-publishing-mcp-server.md +15 -15
- package/dist/docs/references/reference-tools-mcp-client.md +223 -231
- package/dist/docs/references/reference-tools-mcp-server.md +280 -284
- package/dist/index.cjs +34 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +28 -12
- package/dist/index.js.map +1 -1
- package/dist/server/server.d.ts.map +1 -1
- package/package.json +8 -8
package/dist/index.cjs
CHANGED
|
@@ -646,8 +646,8 @@ var InternalMastraMCPClient = class extends base.MastraBase {
|
|
|
646
646
|
* @internal
|
|
647
647
|
*/
|
|
648
648
|
async connect() {
|
|
649
|
-
if (
|
|
650
|
-
return
|
|
649
|
+
if (this.isConnected) {
|
|
650
|
+
return this.isConnected;
|
|
651
651
|
}
|
|
652
652
|
this.isConnected = new Promise(async (resolve, reject) => {
|
|
653
653
|
try {
|
|
@@ -733,16 +733,16 @@ var InternalMastraMCPClient = class extends base.MastraBase {
|
|
|
733
733
|
}
|
|
734
734
|
/**
|
|
735
735
|
* Checks if an error indicates a session invalidation that requires reconnection.
|
|
736
|
-
*
|
|
736
|
+
*
|
|
737
737
|
* Common session-related errors include:
|
|
738
738
|
* - "No valid session ID provided" (HTTP 400)
|
|
739
739
|
* - "Server not initialized" (HTTP 400)
|
|
740
740
|
* - "Not connected" (protocol state error)
|
|
741
741
|
* - Connection refused errors
|
|
742
|
-
*
|
|
742
|
+
*
|
|
743
743
|
* @param error - The error to check
|
|
744
744
|
* @returns true if the error indicates a session problem requiring reconnection
|
|
745
|
-
*
|
|
745
|
+
*
|
|
746
746
|
* @internal
|
|
747
747
|
*/
|
|
748
748
|
isSessionError(error) {
|
|
@@ -754,13 +754,13 @@ var InternalMastraMCPClient = class extends base.MastraBase {
|
|
|
754
754
|
}
|
|
755
755
|
/**
|
|
756
756
|
* Forces a reconnection to the MCP server by disconnecting and reconnecting.
|
|
757
|
-
*
|
|
757
|
+
*
|
|
758
758
|
* This is useful when the session becomes invalid (e.g., after server restart)
|
|
759
759
|
* and the client needs to establish a fresh connection.
|
|
760
|
-
*
|
|
760
|
+
*
|
|
761
761
|
* @returns Promise resolving when reconnection is complete
|
|
762
762
|
* @throws {Error} If reconnection fails
|
|
763
|
-
*
|
|
763
|
+
*
|
|
764
764
|
* @internal
|
|
765
765
|
*/
|
|
766
766
|
async forceReconnect() {
|
|
@@ -975,6 +975,16 @@ var InternalMastraMCPClient = class extends base.MastraBase {
|
|
|
975
975
|
if (res.structuredContent !== void 0) {
|
|
976
976
|
return res.structuredContent;
|
|
977
977
|
}
|
|
978
|
+
if (tool.outputSchema && !res.isError) {
|
|
979
|
+
const content = res.content;
|
|
980
|
+
if (content && content.length === 1 && content[0].type === "text" && content[0].text !== void 0) {
|
|
981
|
+
try {
|
|
982
|
+
return JSON.parse(content[0].text);
|
|
983
|
+
} catch {
|
|
984
|
+
return content[0].text;
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
}
|
|
978
988
|
return res;
|
|
979
989
|
};
|
|
980
990
|
try {
|
|
@@ -2006,7 +2016,7 @@ function createSimpleTokenProvider(accessToken, options) {
|
|
|
2006
2016
|
});
|
|
2007
2017
|
}
|
|
2008
2018
|
|
|
2009
|
-
// ../../node_modules/.pnpm/hono@4.11.
|
|
2019
|
+
// ../../node_modules/.pnpm/hono@4.11.9/node_modules/hono/dist/utils/stream.js
|
|
2010
2020
|
var StreamingApi = class {
|
|
2011
2021
|
writer;
|
|
2012
2022
|
encoder;
|
|
@@ -2083,7 +2093,7 @@ var StreamingApi = class {
|
|
|
2083
2093
|
}
|
|
2084
2094
|
};
|
|
2085
2095
|
|
|
2086
|
-
// ../../node_modules/.pnpm/hono@4.11.
|
|
2096
|
+
// ../../node_modules/.pnpm/hono@4.11.9/node_modules/hono/dist/helper/streaming/utils.js
|
|
2087
2097
|
var isOldBunVersion = () => {
|
|
2088
2098
|
const version = typeof Bun !== "undefined" ? Bun.version : void 0;
|
|
2089
2099
|
if (version === void 0) {
|
|
@@ -2094,7 +2104,7 @@ var isOldBunVersion = () => {
|
|
|
2094
2104
|
return result;
|
|
2095
2105
|
};
|
|
2096
2106
|
|
|
2097
|
-
// ../../node_modules/.pnpm/hono@4.11.
|
|
2107
|
+
// ../../node_modules/.pnpm/hono@4.11.9/node_modules/hono/dist/utils/html.js
|
|
2098
2108
|
var HtmlEscapedCallbackPhase = {
|
|
2099
2109
|
Stringify: 1};
|
|
2100
2110
|
var resolveCallback = async (str, phase, preserveCallbacks, context, buffer) => {
|
|
@@ -2125,7 +2135,7 @@ var resolveCallback = async (str, phase, preserveCallbacks, context, buffer) =>
|
|
|
2125
2135
|
}
|
|
2126
2136
|
};
|
|
2127
2137
|
|
|
2128
|
-
// ../../node_modules/.pnpm/hono@4.11.
|
|
2138
|
+
// ../../node_modules/.pnpm/hono@4.11.9/node_modules/hono/dist/helper/streaming/sse.js
|
|
2129
2139
|
var SSEStreamingApi = class extends StreamingApi {
|
|
2130
2140
|
constructor(writable, readable) {
|
|
2131
2141
|
super(writable, readable);
|
|
@@ -2817,27 +2827,33 @@ Provided arguments: ${JSON.stringify(request.params.arguments, null, 2)}`
|
|
|
2817
2827
|
];
|
|
2818
2828
|
}
|
|
2819
2829
|
return response;
|
|
2820
|
-
} catch (error) {
|
|
2830
|
+
} catch (error$1) {
|
|
2821
2831
|
const duration = Date.now() - startTime;
|
|
2822
|
-
if (error instanceof zod.z.ZodError) {
|
|
2832
|
+
if (error$1 instanceof zod.z.ZodError) {
|
|
2823
2833
|
this.logger.warn("Invalid tool arguments", {
|
|
2824
2834
|
tool: request.params.name,
|
|
2825
|
-
errors: error.errors,
|
|
2835
|
+
errors: error$1.errors,
|
|
2826
2836
|
duration: `${duration}ms`
|
|
2827
2837
|
});
|
|
2828
2838
|
return {
|
|
2829
2839
|
content: [
|
|
2830
2840
|
{
|
|
2831
2841
|
type: "text",
|
|
2832
|
-
text: `Invalid arguments: ${error.errors.map((e) => `${e.path.join(".")}: ${e.message}`).join(", ")}`
|
|
2842
|
+
text: `Invalid arguments: ${error$1.errors.map((e) => `${e.path.join(".")}: ${e.message}`).join(", ")}`
|
|
2833
2843
|
}
|
|
2834
2844
|
],
|
|
2835
2845
|
isError: true
|
|
2836
2846
|
};
|
|
2837
2847
|
}
|
|
2838
|
-
this.logger.error(`Tool execution failed: ${request.params.name}`, { error });
|
|
2848
|
+
this.logger.error(`Tool execution failed: ${request.params.name}`, { error: error$1 });
|
|
2849
|
+
if (error$1 instanceof error.MastraError) {
|
|
2850
|
+
return {
|
|
2851
|
+
content: [{ type: "text", text: JSON.stringify(error$1.toJSON()) }],
|
|
2852
|
+
isError: true
|
|
2853
|
+
};
|
|
2854
|
+
}
|
|
2839
2855
|
return {
|
|
2840
|
-
content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : String(error)}` }],
|
|
2856
|
+
content: [{ type: "text", text: `Error: ${error$1 instanceof Error ? error$1.message : String(error$1)}` }],
|
|
2841
2857
|
isError: true
|
|
2842
2858
|
};
|
|
2843
2859
|
}
|