@mastra/mcp 2.2.0-alpha.1 → 2.2.0-alpha.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/dist/client/server-proxy.d.ts +2 -0
- package/dist/client/server-proxy.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/reference-tools-mcp-server.md +1 -1
- package/dist/index.cjs +27 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +27 -23
- 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/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-proxy.d.ts","sourceRoot":"","sources":["../../src/client/server-proxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,wBAAwB,EAAE,WAAW,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAI5G,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAExD,KAAK,QAAQ,GAAG;IACd,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,EAAE,WAAW,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC,CAAC;AAEF;;;;;;;GAOG;AACH,qBAAa,oBAAqB,SAAQ,aAAa;IACrD,SAAkB,UAAU,EAAG,CAAC,CAAU;IAC1C,OAAO,CAAC,YAAY,CAAyC;IAC7D,OAAO,C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
1396
|
```
|
|
1397
1397
|
|
|
1398
|
-
Link a tool to its app resource by setting `mcp._meta.ui.resourceUri` in `createTool()` to the matching `ui://` URI. The server normalizes this metadata for older hosts when listing tools. Visit [MCP Apps](https://mastra.ai/docs/connections/mcp) for the full app bridge API and usage patterns.
|
|
1398
|
+
Link a tool to its app resource by setting `mcp._meta.ui.resourceUri` in `createTool()` to the matching `ui://` URI. The server normalizes this metadata for older hosts when listing tools, and returns the same link on successful tool call results. Visit [MCP Apps](https://mastra.ai/docs/connections/mcp) for the full app bridge API and usage patterns.
|
|
1399
1399
|
|
|
1400
1400
|
## Related information
|
|
1401
1401
|
|
package/dist/index.cjs
CHANGED
|
@@ -24817,6 +24817,8 @@ var MCPClientServerProxy = class extends _mastra_core_mcp.MCPServerBase {
|
|
|
24817
24817
|
async readResource(uri) {
|
|
24818
24818
|
return { contents: (await (await this.getClient()).resources.read(uri)).contents.map((c) => ({
|
|
24819
24819
|
uri: c.uri ?? uri,
|
|
24820
|
+
...c.mimeType !== void 0 ? { mimeType: c.mimeType } : {},
|
|
24821
|
+
...c._meta !== void 0 ? { _meta: c._meta } : {},
|
|
24820
24822
|
..."text" in c && c.text !== void 0 ? { text: c.text } : {},
|
|
24821
24823
|
..."blob" in c && c.blob !== void 0 ? { blob: c.blob } : {}
|
|
24822
24824
|
})) };
|
|
@@ -26526,10 +26528,7 @@ var MCPServer = class extends _mastra_core_mcp.MCPServerBase {
|
|
|
26526
26528
|
return validation.value;
|
|
26527
26529
|
}
|
|
26528
26530
|
hasUiMetadata() {
|
|
26529
|
-
return Object.values(this.convertedTools).some((tool) =>
|
|
26530
|
-
const meta = tool.mcp?._meta;
|
|
26531
|
-
return Boolean(meta?.ui?.resourceUri);
|
|
26532
|
-
});
|
|
26531
|
+
return Object.values(this.convertedTools).some((tool) => Boolean(uiResourceUri(tool.mcp?._meta)));
|
|
26533
26532
|
}
|
|
26534
26533
|
capabilities() {
|
|
26535
26534
|
const capabilities = {
|
|
@@ -26810,12 +26809,18 @@ var MCPServer = class extends _mastra_core_mcp.MCPServerBase {
|
|
|
26810
26809
|
this.logger.warn(`Tool '${name}' rejected its input.`, { error: value.message });
|
|
26811
26810
|
return errorResult(value.message);
|
|
26812
26811
|
}
|
|
26812
|
+
const resourceUri = uiResourceUri(tool.mcp?._meta);
|
|
26813
|
+
const meta = resourceUri ? { _meta: {
|
|
26814
|
+
ui: { resourceUri },
|
|
26815
|
+
[_modelcontextprotocol_ext_apps.RESOURCE_URI_META_KEY]: resourceUri
|
|
26816
|
+
} } : {};
|
|
26813
26817
|
if (!tool.outputSchema) return {
|
|
26814
26818
|
isError: false,
|
|
26815
26819
|
content: [{
|
|
26816
26820
|
type: "text",
|
|
26817
26821
|
text: typeof value === "string" ? value : JSON.stringify(value)
|
|
26818
|
-
}]
|
|
26822
|
+
}],
|
|
26823
|
+
...meta
|
|
26819
26824
|
};
|
|
26820
26825
|
const structuredContent = value;
|
|
26821
26826
|
return {
|
|
@@ -26824,7 +26829,8 @@ var MCPServer = class extends _mastra_core_mcp.MCPServerBase {
|
|
|
26824
26829
|
content: [{
|
|
26825
26830
|
type: "text",
|
|
26826
26831
|
text: JSON.stringify(structuredContent)
|
|
26827
|
-
}]
|
|
26832
|
+
}],
|
|
26833
|
+
...meta
|
|
26828
26834
|
};
|
|
26829
26835
|
}
|
|
26830
26836
|
registerResourceHandlers(server) {
|
|
@@ -27169,17 +27175,15 @@ var MCPServer = class extends _mastra_core_mcp.MCPServerBase {
|
|
|
27169
27175
|
/** Reads an `ui://` app resource; application resources require a protocol request. */
|
|
27170
27176
|
async readResource(uri) {
|
|
27171
27177
|
const html = this.appResourceHtml.get(uri);
|
|
27172
|
-
|
|
27178
|
+
const resource = this.appResourceList.find((r) => r.uri === uri);
|
|
27179
|
+
if (html === void 0 || !resource) throw new _mastra_core_error.MastraError({
|
|
27173
27180
|
id: "MCP_SERVER_RESOURCE_NOT_FOUND",
|
|
27174
27181
|
domain: _mastra_core_error.ErrorDomain.MCP,
|
|
27175
27182
|
category: _mastra_core_error.ErrorCategory.USER,
|
|
27176
27183
|
text: `Resource '${uri}' not found; application resources are only readable through an MCP request`,
|
|
27177
27184
|
details: { uri }
|
|
27178
27185
|
});
|
|
27179
|
-
return { contents: [{
|
|
27180
|
-
uri,
|
|
27181
|
-
text: html
|
|
27182
|
-
}] };
|
|
27186
|
+
return { contents: [this.resourceContents(resource, { text: html })] };
|
|
27183
27187
|
}
|
|
27184
27188
|
/** Lists `ui://` app resources; application resources require a protocol request. */
|
|
27185
27189
|
async listResources() {
|
|
@@ -27199,23 +27203,23 @@ function errorResult(text) {
|
|
|
27199
27203
|
isError: true
|
|
27200
27204
|
};
|
|
27201
27205
|
}
|
|
27202
|
-
/**
|
|
27206
|
+
/** The tool's MCP App URI; the nested key wins over the flat one, as in ext-apps' `getToolUiResourceUri`. */
|
|
27207
|
+
function uiResourceUri(meta) {
|
|
27208
|
+
return (meta?.ui)?.resourceUri || meta?.[_modelcontextprotocol_ext_apps.RESOURCE_URI_META_KEY] || void 0;
|
|
27209
|
+
}
|
|
27210
|
+
/** Writes the tool's MCP App URI to both the nested and the flat key, so every host opens the same app. */
|
|
27203
27211
|
function normalizeUiMeta(meta) {
|
|
27204
|
-
|
|
27212
|
+
const resourceUri = uiResourceUri(meta);
|
|
27213
|
+
if (!meta || !resourceUri) return meta;
|
|
27205
27214
|
const ui = meta.ui;
|
|
27206
|
-
|
|
27207
|
-
if (ui?.resourceUri && !flat) return {
|
|
27208
|
-
...meta,
|
|
27209
|
-
[_modelcontextprotocol_ext_apps.RESOURCE_URI_META_KEY]: ui.resourceUri
|
|
27210
|
-
};
|
|
27211
|
-
if (flat && !ui?.resourceUri) return {
|
|
27215
|
+
return {
|
|
27212
27216
|
...meta,
|
|
27213
27217
|
ui: {
|
|
27214
|
-
...ui
|
|
27215
|
-
resourceUri
|
|
27216
|
-
}
|
|
27218
|
+
...ui,
|
|
27219
|
+
resourceUri
|
|
27220
|
+
},
|
|
27221
|
+
[_modelcontextprotocol_ext_apps.RESOURCE_URI_META_KEY]: resourceUri
|
|
27217
27222
|
};
|
|
27218
|
-
return meta;
|
|
27219
27223
|
}
|
|
27220
27224
|
//#endregion
|
|
27221
27225
|
//#region src/server/types.ts
|