@mastra/mcp 1.5.0 → 1.5.1-alpha.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 +18 -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/index.cjs +35 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +35 -31
- package/dist/index.js.map +1 -1
- package/dist/server/server.d.ts +2 -0
- package/dist/server/server.d.ts.map +1 -1
- package/dist/shared/mastra-tool-meta.d.ts +3 -0
- package/dist/shared/mastra-tool-meta.d.ts.map +1 -0
- package/package.json +4 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @mastra/mcp
|
|
2
2
|
|
|
3
|
+
## 1.5.1-alpha.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed MCP tools with recursive JSON Schema refs so they stay serializable when loaded. ([#15400](https://github.com/mastra-ai/mastra/pull/15400))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`3d83d06`](https://github.com/mastra-ai/mastra/commit/3d83d06f776f00fb5f4163dddd32a030c5c20844), [`7e0e63e`](https://github.com/mastra-ai/mastra/commit/7e0e63e2e485e84442351f4c7a79a424c83539dc), [`9467ea8`](https://github.com/mastra-ai/mastra/commit/9467ea87695749a53dfc041576410ebf9ee7bb67), [`7338d94`](https://github.com/mastra-ai/mastra/commit/7338d949380cf68b095342e8e42610dc51d557c1)]:
|
|
10
|
+
- @mastra/core@1.26.0-alpha.2
|
|
11
|
+
|
|
12
|
+
## 1.5.1-alpha.0
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Fixed MCP tool strict mode propagation. MCP servers now expose Mastra tool strictness in MCP metadata, and the MCP client restores that flag when rebuilding tools so strict OpenAI tool calling works for MCP-backed tools too. ([#15397](https://github.com/mastra-ai/mastra/pull/15397))
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [[`7020c06`](https://github.com/mastra-ai/mastra/commit/7020c0690b199d9da337f0e805f16948e557922e)]:
|
|
19
|
+
- @mastra/core@1.25.1-alpha.1
|
|
20
|
+
|
|
3
21
|
## 1.5.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAS/C,OAAO,KAAK,EACV,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,2BAA2B,EAE3B,kBAAkB,EACnB,MAAM,oCAAoC,CAAC;AAoB5C,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,KAAK,EAGV,kBAAkB,EAClB,eAAe,EAEf,8BAA8B,EAC9B,IAAI,EAEL,MAAM,SAAS,CAAC;AAGjB,YAAY,EACV,YAAY,EACZ,UAAU,EACV,UAAU,EACV,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,yBAAyB,EACzB,8BAA8B,EAC9B,IAAI,EACJ,mBAAmB,EACnB,qBAAqB,EACrB,0BAA0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AI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;CAgJjE"}
|
package/dist/docs/SKILL.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var async_hooks = require('async_hooks');
|
|
4
|
-
var $RefParser = require('@apidevtools/json-schema-ref-parser');
|
|
5
4
|
var base = require('@mastra/core/base');
|
|
6
|
-
var error = require('@mastra/core/error');
|
|
7
5
|
var tools = require('@mastra/core/tools');
|
|
8
6
|
var index_js = require('@modelcontextprotocol/sdk/client/index.js');
|
|
9
7
|
var sse_js = require('@modelcontextprotocol/sdk/client/sse.js');
|
|
@@ -12,6 +10,7 @@ var streamableHttp_js = require('@modelcontextprotocol/sdk/client/streamableHttp
|
|
|
12
10
|
var protocol_js = require('@modelcontextprotocol/sdk/shared/protocol.js');
|
|
13
11
|
var types_js = require('@modelcontextprotocol/sdk/types.js');
|
|
14
12
|
var exitHook = require('exit-hook');
|
|
13
|
+
var error = require('@mastra/core/error');
|
|
15
14
|
var equal = require('fast-deep-equal');
|
|
16
15
|
var uuid = require('uuid');
|
|
17
16
|
var crypto$1 = require('crypto');
|
|
@@ -27,11 +26,35 @@ var auth_js = require('@modelcontextprotocol/sdk/client/auth.js');
|
|
|
27
26
|
|
|
28
27
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
29
28
|
|
|
30
|
-
var $RefParser__default = /*#__PURE__*/_interopDefault($RefParser);
|
|
31
29
|
var equal__default = /*#__PURE__*/_interopDefault(equal);
|
|
32
30
|
|
|
33
31
|
// src/client/client.ts
|
|
34
32
|
|
|
33
|
+
// src/shared/mastra-tool-meta.ts
|
|
34
|
+
var MASTRA_META_KEY = "mastra";
|
|
35
|
+
var STRICT_META_KEY = "strict";
|
|
36
|
+
function withMastraToolStrictMeta(meta, strict) {
|
|
37
|
+
if (strict == null) {
|
|
38
|
+
return meta;
|
|
39
|
+
}
|
|
40
|
+
const mastraMeta = meta?.[MASTRA_META_KEY] && typeof meta[MASTRA_META_KEY] === "object" ? meta[MASTRA_META_KEY] : void 0;
|
|
41
|
+
return {
|
|
42
|
+
...meta ?? {},
|
|
43
|
+
[MASTRA_META_KEY]: {
|
|
44
|
+
...mastraMeta ?? {},
|
|
45
|
+
[STRICT_META_KEY]: strict
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function getMastraToolStrictMeta(meta) {
|
|
50
|
+
const mastraMeta = meta?.[MASTRA_META_KEY];
|
|
51
|
+
if (!mastraMeta || typeof mastraMeta !== "object") {
|
|
52
|
+
return void 0;
|
|
53
|
+
}
|
|
54
|
+
const strict = mastraMeta[STRICT_META_KEY];
|
|
55
|
+
return typeof strict === "boolean" ? strict : void 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
35
58
|
// src/client/actions/elicitation.ts
|
|
36
59
|
var ElicitationClientActions = class {
|
|
37
60
|
client;
|
|
@@ -875,31 +898,7 @@ var InternalMastraMCPClient = class extends base.MastraBase {
|
|
|
875
898
|
});
|
|
876
899
|
}
|
|
877
900
|
async convertInputSchema(inputSchema) {
|
|
878
|
-
|
|
879
|
-
await $RefParser__default.default.dereference(inputSchema);
|
|
880
|
-
return "jsonSchema" in inputSchema ? inputSchema.jsonSchema : inputSchema;
|
|
881
|
-
} catch (error$1) {
|
|
882
|
-
let errorDetails;
|
|
883
|
-
if (error$1 instanceof Error) {
|
|
884
|
-
errorDetails = error$1.stack;
|
|
885
|
-
} else {
|
|
886
|
-
try {
|
|
887
|
-
errorDetails = JSON.stringify(error$1);
|
|
888
|
-
} catch {
|
|
889
|
-
errorDetails = String(error$1);
|
|
890
|
-
}
|
|
891
|
-
}
|
|
892
|
-
this.log("error", "Failed to dereference JSON schema", {
|
|
893
|
-
error: errorDetails,
|
|
894
|
-
originalJsonSchema: inputSchema
|
|
895
|
-
});
|
|
896
|
-
throw new error.MastraError({
|
|
897
|
-
id: "MCP_TOOL_INPUT_SCHEMA_CONVERSION_FAILED",
|
|
898
|
-
domain: error.ErrorDomain.MCP,
|
|
899
|
-
category: error.ErrorCategory.USER,
|
|
900
|
-
details: { error: errorDetails ?? "Unknown error" }
|
|
901
|
-
});
|
|
902
|
-
}
|
|
901
|
+
return "jsonSchema" in inputSchema ? inputSchema.jsonSchema : inputSchema;
|
|
903
902
|
}
|
|
904
903
|
async tools() {
|
|
905
904
|
this.log("debug", `Requesting tools from MCP server`);
|
|
@@ -924,6 +923,7 @@ var InternalMastraMCPClient = class extends base.MastraBase {
|
|
|
924
923
|
id: `${this.name}_${tool.name}`,
|
|
925
924
|
description: tool.description || "",
|
|
926
925
|
inputSchema: await this.convertInputSchema(tool.inputSchema),
|
|
926
|
+
strict: getMastraToolStrictMeta(tool._meta),
|
|
927
927
|
// Don't pass outputSchema to createTool — the MCP SDK's Client.callTool()
|
|
928
928
|
// already validates structuredContent against the tool's outputSchema using AJV.
|
|
929
929
|
// Passing it here causes Zod to strip unrecognized keys from the CallToolResult
|
|
@@ -2781,8 +2781,9 @@ var MCPServer = class extends mcp.MCPServerBase {
|
|
|
2781
2781
|
if (tool.mcp?.annotations) {
|
|
2782
2782
|
toolSpec.annotations = tool.mcp.annotations;
|
|
2783
2783
|
}
|
|
2784
|
-
|
|
2785
|
-
|
|
2784
|
+
const toolMeta = withMastraToolStrictMeta(tool.mcp?._meta, tool.strict);
|
|
2785
|
+
if (toolMeta) {
|
|
2786
|
+
toolSpec._meta = toolMeta;
|
|
2786
2787
|
}
|
|
2787
2788
|
return toolSpec;
|
|
2788
2789
|
})
|
|
@@ -4060,7 +4061,8 @@ Provided arguments: ${JSON.stringify(request.params.arguments, null, 2)}`
|
|
|
4060
4061
|
description: tool.description,
|
|
4061
4062
|
inputSchema: this.convertSchema(tool.parameters),
|
|
4062
4063
|
outputSchema: this.convertSchema(tool.parameters),
|
|
4063
|
-
toolType: tool.mcp?.toolType
|
|
4064
|
+
toolType: tool.mcp?.toolType,
|
|
4065
|
+
_meta: withMastraToolStrictMeta(tool.mcp?._meta, tool.strict)
|
|
4064
4066
|
}))
|
|
4065
4067
|
};
|
|
4066
4068
|
}
|
|
@@ -4094,7 +4096,8 @@ Provided arguments: ${JSON.stringify(request.params.arguments, null, 2)}`
|
|
|
4094
4096
|
description: tool.description,
|
|
4095
4097
|
inputSchema: this.convertSchema(tool.parameters),
|
|
4096
4098
|
outputSchema: this.convertSchema(tool.outputSchema),
|
|
4097
|
-
toolType: tool.mcp?.toolType
|
|
4099
|
+
toolType: tool.mcp?.toolType,
|
|
4100
|
+
_meta: withMastraToolStrictMeta(tool.mcp?._meta, tool.strict)
|
|
4098
4101
|
};
|
|
4099
4102
|
}
|
|
4100
4103
|
/**
|