@mastra/mcp 1.17.1 → 1.17.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 +9 -0
- package/dist/client/client.d.ts +24 -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 +43 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +41 -8
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -21210,20 +21210,53 @@ function extractModelTextFromToolContent(content) {
|
|
|
21210
21210
|
/**
|
|
21211
21211
|
* Non-enumerable metadata attached to structured tool execute results so
|
|
21212
21212
|
* `toModelOutput` can read MCP `content` without changing the execute return shape.
|
|
21213
|
+
*
|
|
21214
|
+
* When a tool has an `outputSchema` and the server returns `structuredContent`,
|
|
21215
|
+
* `execute()` returns that structured value directly. The rest of the
|
|
21216
|
+
* CallToolResult envelope is preserved on non-enumerable symbols:
|
|
21217
|
+
* - {@link MCP_CALL_TOOL_CONTENT} holds the MCP `content` blocks (model-facing text).
|
|
21218
|
+
* - {@link MCP_CALL_TOOL_META} holds the result-level `_meta` (e.g. `ui.resourceUri`
|
|
21219
|
+
* used by MCP Apps hosts), with `ui.serverId` stamped by the client.
|
|
21220
|
+
*
|
|
21221
|
+
* Read them with {@link getMcpCallToolContent} and {@link getMcpCallToolMeta}.
|
|
21222
|
+
* Note: scalar or `null` structured results cannot carry properties, so these
|
|
21223
|
+
* channels are only available when `structuredContent` is an object or array.
|
|
21213
21224
|
*/
|
|
21214
21225
|
const MCP_CALL_TOOL_CONTENT = Symbol.for("mastra.mcp.callToolContent");
|
|
21215
|
-
|
|
21216
|
-
|
|
21217
|
-
|
|
21218
|
-
|
|
21219
|
-
|
|
21220
|
-
|
|
21226
|
+
/** Non-enumerable result-level `_meta` attached to structured tool execute results. */
|
|
21227
|
+
const MCP_CALL_TOOL_META = Symbol.for("mastra.mcp.callToolMeta");
|
|
21228
|
+
function attachMcpCallToolContent(structuredContent, content, _meta) {
|
|
21229
|
+
if (structuredContent !== null && typeof structuredContent === "object") {
|
|
21230
|
+
Object.defineProperty(structuredContent, MCP_CALL_TOOL_CONTENT, {
|
|
21231
|
+
value: content,
|
|
21232
|
+
enumerable: false,
|
|
21233
|
+
configurable: true
|
|
21234
|
+
});
|
|
21235
|
+
if (_meta !== void 0) Object.defineProperty(structuredContent, MCP_CALL_TOOL_META, {
|
|
21236
|
+
value: _meta,
|
|
21237
|
+
enumerable: false,
|
|
21238
|
+
configurable: true
|
|
21239
|
+
});
|
|
21240
|
+
}
|
|
21221
21241
|
return structuredContent;
|
|
21222
21242
|
}
|
|
21243
|
+
/**
|
|
21244
|
+
* Read the MCP `content` blocks preserved on a structured tool execute result.
|
|
21245
|
+
* Returns `undefined` for scalar results or results without a hidden content channel.
|
|
21246
|
+
*/
|
|
21223
21247
|
function getMcpCallToolContent(output) {
|
|
21224
21248
|
if (output === null || typeof output !== "object") return void 0;
|
|
21225
21249
|
return output[MCP_CALL_TOOL_CONTENT];
|
|
21226
21250
|
}
|
|
21251
|
+
/**
|
|
21252
|
+
* Read the result-level `_meta` preserved on a structured tool execute result
|
|
21253
|
+
* (e.g. `_meta.ui.resourceUri` for MCP Apps detection). Returns `undefined` for
|
|
21254
|
+
* scalar results or results whose CallToolResult had no `_meta`.
|
|
21255
|
+
*/
|
|
21256
|
+
function getMcpCallToolMeta(output) {
|
|
21257
|
+
if (output === null || typeof output !== "object") return void 0;
|
|
21258
|
+
return output[MCP_CALL_TOOL_META];
|
|
21259
|
+
}
|
|
21227
21260
|
function createStructuredToolToModelOutput() {
|
|
21228
21261
|
return (output) => {
|
|
21229
21262
|
const modelText = extractModelTextFromToolContent(getMcpCallToolContent(output));
|
|
@@ -22130,7 +22163,7 @@ var InternalMastraMCPClient = class extends MastraBase {
|
|
|
22130
22163
|
});
|
|
22131
22164
|
}
|
|
22132
22165
|
this.log("debug", `Tool executed successfully: ${tool.name}`);
|
|
22133
|
-
if (res.structuredContent !== void 0) return attachMcpCallToolContent(res.structuredContent, res.content);
|
|
22166
|
+
if (res.structuredContent !== void 0) return attachMcpCallToolContent(res.structuredContent, res.content, res._meta ? this.stampServerIdInMeta(res._meta) : void 0);
|
|
22134
22167
|
return res;
|
|
22135
22168
|
};
|
|
22136
22169
|
const failedTransport = this.transport;
|
|
@@ -27127,6 +27160,6 @@ function createIntrospectionValidator(introspectionEndpoint, clientCredentials)
|
|
|
27127
27160
|
};
|
|
27128
27161
|
}
|
|
27129
27162
|
//#endregion
|
|
27130
|
-
export { InMemoryOAuthStorage, InternalMastraMCPClient, MCPClient, MCPClientServerProxy, MCPOAuthClientProvider, MCPServer, MCP_CALL_TOOL_CONTENT, UnauthorizedError, auth, buildDiscoveryUrls, createIntrospectionValidator, createOAuthCallbackServer, createOAuthMiddleware, createSimpleTokenProvider, createStaticTokenValidator, discoverAuthorizationServerMetadata, discoverOAuthMetadata, discoverOAuthProtectedResourceMetadata, exchangeAuthorization, extractBearerToken, extractResourceMetadataUrl, generateProtectedResourceMetadata, generateWWWAuthenticateHeader, getCallbackUrlCandidates, parseErrorResponse, refreshAuthorization, registerClient, selectResourceURL, startAuthorization };
|
|
27163
|
+
export { InMemoryOAuthStorage, InternalMastraMCPClient, MCPClient, MCPClientServerProxy, MCPOAuthClientProvider, MCPServer, MCP_CALL_TOOL_CONTENT, MCP_CALL_TOOL_META, UnauthorizedError, auth, buildDiscoveryUrls, createIntrospectionValidator, createOAuthCallbackServer, createOAuthMiddleware, createSimpleTokenProvider, createStaticTokenValidator, discoverAuthorizationServerMetadata, discoverOAuthMetadata, discoverOAuthProtectedResourceMetadata, exchangeAuthorization, extractBearerToken, extractResourceMetadataUrl, generateProtectedResourceMetadata, generateWWWAuthenticateHeader, getCallbackUrlCandidates, getMcpCallToolContent, getMcpCallToolMeta, parseErrorResponse, refreshAuthorization, registerClient, selectResourceURL, startAuthorization };
|
|
27131
27164
|
|
|
27132
27165
|
//# sourceMappingURL=index.js.map
|