@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.js
CHANGED
|
@@ -639,8 +639,8 @@ var InternalMastraMCPClient = class extends MastraBase {
|
|
|
639
639
|
* @internal
|
|
640
640
|
*/
|
|
641
641
|
async connect() {
|
|
642
|
-
if (
|
|
643
|
-
return
|
|
642
|
+
if (this.isConnected) {
|
|
643
|
+
return this.isConnected;
|
|
644
644
|
}
|
|
645
645
|
this.isConnected = new Promise(async (resolve, reject) => {
|
|
646
646
|
try {
|
|
@@ -726,16 +726,16 @@ var InternalMastraMCPClient = class extends MastraBase {
|
|
|
726
726
|
}
|
|
727
727
|
/**
|
|
728
728
|
* Checks if an error indicates a session invalidation that requires reconnection.
|
|
729
|
-
*
|
|
729
|
+
*
|
|
730
730
|
* Common session-related errors include:
|
|
731
731
|
* - "No valid session ID provided" (HTTP 400)
|
|
732
732
|
* - "Server not initialized" (HTTP 400)
|
|
733
733
|
* - "Not connected" (protocol state error)
|
|
734
734
|
* - Connection refused errors
|
|
735
|
-
*
|
|
735
|
+
*
|
|
736
736
|
* @param error - The error to check
|
|
737
737
|
* @returns true if the error indicates a session problem requiring reconnection
|
|
738
|
-
*
|
|
738
|
+
*
|
|
739
739
|
* @internal
|
|
740
740
|
*/
|
|
741
741
|
isSessionError(error) {
|
|
@@ -747,13 +747,13 @@ var InternalMastraMCPClient = class extends MastraBase {
|
|
|
747
747
|
}
|
|
748
748
|
/**
|
|
749
749
|
* Forces a reconnection to the MCP server by disconnecting and reconnecting.
|
|
750
|
-
*
|
|
750
|
+
*
|
|
751
751
|
* This is useful when the session becomes invalid (e.g., after server restart)
|
|
752
752
|
* and the client needs to establish a fresh connection.
|
|
753
|
-
*
|
|
753
|
+
*
|
|
754
754
|
* @returns Promise resolving when reconnection is complete
|
|
755
755
|
* @throws {Error} If reconnection fails
|
|
756
|
-
*
|
|
756
|
+
*
|
|
757
757
|
* @internal
|
|
758
758
|
*/
|
|
759
759
|
async forceReconnect() {
|
|
@@ -968,6 +968,16 @@ var InternalMastraMCPClient = class extends MastraBase {
|
|
|
968
968
|
if (res.structuredContent !== void 0) {
|
|
969
969
|
return res.structuredContent;
|
|
970
970
|
}
|
|
971
|
+
if (tool.outputSchema && !res.isError) {
|
|
972
|
+
const content = res.content;
|
|
973
|
+
if (content && content.length === 1 && content[0].type === "text" && content[0].text !== void 0) {
|
|
974
|
+
try {
|
|
975
|
+
return JSON.parse(content[0].text);
|
|
976
|
+
} catch {
|
|
977
|
+
return content[0].text;
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
}
|
|
971
981
|
return res;
|
|
972
982
|
};
|
|
973
983
|
try {
|
|
@@ -1999,7 +2009,7 @@ function createSimpleTokenProvider(accessToken, options) {
|
|
|
1999
2009
|
});
|
|
2000
2010
|
}
|
|
2001
2011
|
|
|
2002
|
-
// ../../node_modules/.pnpm/hono@4.11.
|
|
2012
|
+
// ../../node_modules/.pnpm/hono@4.11.9/node_modules/hono/dist/utils/stream.js
|
|
2003
2013
|
var StreamingApi = class {
|
|
2004
2014
|
writer;
|
|
2005
2015
|
encoder;
|
|
@@ -2076,7 +2086,7 @@ var StreamingApi = class {
|
|
|
2076
2086
|
}
|
|
2077
2087
|
};
|
|
2078
2088
|
|
|
2079
|
-
// ../../node_modules/.pnpm/hono@4.11.
|
|
2089
|
+
// ../../node_modules/.pnpm/hono@4.11.9/node_modules/hono/dist/helper/streaming/utils.js
|
|
2080
2090
|
var isOldBunVersion = () => {
|
|
2081
2091
|
const version = typeof Bun !== "undefined" ? Bun.version : void 0;
|
|
2082
2092
|
if (version === void 0) {
|
|
@@ -2087,7 +2097,7 @@ var isOldBunVersion = () => {
|
|
|
2087
2097
|
return result;
|
|
2088
2098
|
};
|
|
2089
2099
|
|
|
2090
|
-
// ../../node_modules/.pnpm/hono@4.11.
|
|
2100
|
+
// ../../node_modules/.pnpm/hono@4.11.9/node_modules/hono/dist/utils/html.js
|
|
2091
2101
|
var HtmlEscapedCallbackPhase = {
|
|
2092
2102
|
Stringify: 1};
|
|
2093
2103
|
var resolveCallback = async (str, phase, preserveCallbacks, context, buffer) => {
|
|
@@ -2118,7 +2128,7 @@ var resolveCallback = async (str, phase, preserveCallbacks, context, buffer) =>
|
|
|
2118
2128
|
}
|
|
2119
2129
|
};
|
|
2120
2130
|
|
|
2121
|
-
// ../../node_modules/.pnpm/hono@4.11.
|
|
2131
|
+
// ../../node_modules/.pnpm/hono@4.11.9/node_modules/hono/dist/helper/streaming/sse.js
|
|
2122
2132
|
var SSEStreamingApi = class extends StreamingApi {
|
|
2123
2133
|
constructor(writable, readable) {
|
|
2124
2134
|
super(writable, readable);
|
|
@@ -2829,6 +2839,12 @@ Provided arguments: ${JSON.stringify(request.params.arguments, null, 2)}`
|
|
|
2829
2839
|
};
|
|
2830
2840
|
}
|
|
2831
2841
|
this.logger.error(`Tool execution failed: ${request.params.name}`, { error });
|
|
2842
|
+
if (error instanceof MastraError) {
|
|
2843
|
+
return {
|
|
2844
|
+
content: [{ type: "text", text: JSON.stringify(error.toJSON()) }],
|
|
2845
|
+
isError: true
|
|
2846
|
+
};
|
|
2847
|
+
}
|
|
2832
2848
|
return {
|
|
2833
2849
|
content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : String(error)}` }],
|
|
2834
2850
|
isError: true
|