@mastra/mcp 1.3.1-alpha.0 → 1.3.1
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 +24 -0
- package/dist/client/client.d.ts +0 -1
- 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/index.cjs +4 -39
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -39
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -896,34 +896,6 @@ var InternalMastraMCPClient = class extends MastraBase {
|
|
|
896
896
|
});
|
|
897
897
|
}
|
|
898
898
|
}
|
|
899
|
-
async convertOutputSchema(outputSchema) {
|
|
900
|
-
if (!outputSchema) return;
|
|
901
|
-
try {
|
|
902
|
-
await $RefParser.dereference(outputSchema);
|
|
903
|
-
return "jsonSchema" in outputSchema ? outputSchema.jsonSchema : outputSchema;
|
|
904
|
-
} catch (error) {
|
|
905
|
-
let errorDetails;
|
|
906
|
-
if (error instanceof Error) {
|
|
907
|
-
errorDetails = error.stack;
|
|
908
|
-
} else {
|
|
909
|
-
try {
|
|
910
|
-
errorDetails = JSON.stringify(error);
|
|
911
|
-
} catch {
|
|
912
|
-
errorDetails = String(error);
|
|
913
|
-
}
|
|
914
|
-
}
|
|
915
|
-
this.log("error", "Failed to dereference JSON schema", {
|
|
916
|
-
error: errorDetails,
|
|
917
|
-
originalJsonSchema: outputSchema
|
|
918
|
-
});
|
|
919
|
-
throw new MastraError({
|
|
920
|
-
id: "MCP_TOOL_OUTPUT_SCHEMA_CONVERSION_FAILED",
|
|
921
|
-
domain: ErrorDomain.MCP,
|
|
922
|
-
category: ErrorCategory.USER,
|
|
923
|
-
details: { error: errorDetails ?? "Unknown error" }
|
|
924
|
-
});
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
899
|
async tools() {
|
|
928
900
|
this.log("debug", `Requesting tools from MCP server`);
|
|
929
901
|
const { tools } = await this.client.listTools({}, { timeout: this.timeout });
|
|
@@ -935,7 +907,10 @@ var InternalMastraMCPClient = class extends MastraBase {
|
|
|
935
907
|
id: `${this.name}_${tool.name}`,
|
|
936
908
|
description: tool.description || "",
|
|
937
909
|
inputSchema: await this.convertInputSchema(tool.inputSchema),
|
|
938
|
-
outputSchema
|
|
910
|
+
// Don't pass outputSchema to createTool — the MCP SDK's Client.callTool()
|
|
911
|
+
// already validates structuredContent against the tool's outputSchema using AJV.
|
|
912
|
+
// Passing it here causes Zod to strip unrecognized keys from the CallToolResult
|
|
913
|
+
// envelope, returning {} for tools without structuredContent.
|
|
939
914
|
mcpMetadata: {
|
|
940
915
|
serverName: this.name,
|
|
941
916
|
serverVersion: this.client.getServerVersion()?.version
|
|
@@ -962,16 +937,6 @@ var InternalMastraMCPClient = class extends MastraBase {
|
|
|
962
937
|
if (res.structuredContent !== void 0) {
|
|
963
938
|
return res.structuredContent;
|
|
964
939
|
}
|
|
965
|
-
if (!res.isError) {
|
|
966
|
-
const content = res.content;
|
|
967
|
-
if (content && content.length === 1 && content[0].type === "text" && content[0].text !== void 0) {
|
|
968
|
-
try {
|
|
969
|
-
return JSON.parse(content[0].text);
|
|
970
|
-
} catch {
|
|
971
|
-
return content[0].text;
|
|
972
|
-
}
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
940
|
return res;
|
|
976
941
|
};
|
|
977
942
|
try {
|