@mastra/mcp 2.2.0-alpha.0 → 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.
@@ -56,6 +56,8 @@ export declare class MCPClientServerProxy extends MCPServerBase {
56
56
  uri: string;
57
57
  text?: string;
58
58
  blob?: string;
59
+ mimeType?: string;
60
+ _meta?: Record<string, unknown>;
59
61
  }>;
60
62
  }>;
61
63
  startStdio(): Promise<void>;
@@ -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,CAAC,YAAY,CAAwC;IAC5D,OAAO,CAAC,cAAc,CAAsC;IAE5D,YACE,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;Q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O,CAAC,IAAI,CAAC,CAEtC;IAEY,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAGlC;IAEM,aAAa,IAAI,UAAU,CAWjC;IAEM,eAAe,IAAI,gBAAgB,CAMzC;CACF"}
@@ -3,7 +3,7 @@ name: mastra-mcp
3
3
  description: Documentation for @mastra/mcp. Use when working with @mastra/mcp APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/mcp"
6
- version: "2.2.0-alpha.0"
6
+ version: "2.2.0-alpha.2"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.2.0-alpha.0",
2
+ "version": "2.2.0-alpha.2",
3
3
  "package": "@mastra/mcp",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -75,7 +75,13 @@ The constructor accepts an `MCPServerConfig` object with the following propertie
75
75
 
76
76
  **workflows** (`Record<string, Workflow>`): An object where keys are workflow identifiers and values are Mastra Workflow instances. Each workflow is converted into a tool named run\_\<workflowKey>. The workflow's inputSchema becomes the tool's input schema. The workflow \*\*must\*\* have a non-empty description string property, which is used for the tool's description. If a workflow's description is missing or empty, an error will be thrown. The tool executes the workflow by calling workflow\.createRun() followed by run.start({ inputData: \<tool\_input> }). If a tool name derived from an agent or workflow (e.g., ask\_myAgent or run\_myWorkflow) collides with an explicitly defined tool name or another derived name, the explicitly defined tool takes precedence, and a warning is logged. Agents/workflows leading to subsequent collisions are skipped.
77
77
 
78
- **description** (`string`): Optional description of what the MCP server does.
78
+ **description** (`string`): Optional description of what the MCP server does. Announced to MCP clients as part of the server's identity and returned in the registry server info.
79
+
80
+ **title** (`string`): Optional human-readable display title announced to MCP clients (e.g., 'Weather Server'). Clients fall back to name when it isn't set.
81
+
82
+ **websiteUrl** (`string`): Optional URL of the server's website, announced to MCP clients.
83
+
84
+ **icons** (`{ src: string; mimeType?: string; sizes?: string[]; theme?: 'light' | 'dark' }[]`): Optional icons clients can display for the server. src is an https: URL or a data: URI; sizes takes values like '48x48' or 'any'.
79
85
 
80
86
  **instructions** (`string`): Optional instructions describing how to use the server and its features.
81
87
 
@@ -1389,7 +1395,7 @@ const server = new MCPServer({
1389
1395
  })
1390
1396
  ```
1391
1397
 
1392
- 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.
1393
1399
 
1394
1400
  ## Related information
1395
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 = {
@@ -26547,7 +26546,11 @@ var MCPServer = class extends _mastra_core_mcp.MCPServerBase {
26547
26546
  createServerInstance() {
26548
26547
  const server = new _modelcontextprotocol_server.Server({
26549
26548
  name: this.name,
26550
- version: this.version
26549
+ version: this.version,
26550
+ title: this.title,
26551
+ description: this.description,
26552
+ websiteUrl: this.websiteUrl,
26553
+ icons: this.icons
26551
26554
  }, {
26552
26555
  capabilities: this.capabilities(),
26553
26556
  instructions: this.instructions,
@@ -26806,12 +26809,18 @@ var MCPServer = class extends _mastra_core_mcp.MCPServerBase {
26806
26809
  this.logger.warn(`Tool '${name}' rejected its input.`, { error: value.message });
26807
26810
  return errorResult(value.message);
26808
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
+ } } : {};
26809
26817
  if (!tool.outputSchema) return {
26810
26818
  isError: false,
26811
26819
  content: [{
26812
26820
  type: "text",
26813
26821
  text: typeof value === "string" ? value : JSON.stringify(value)
26814
- }]
26822
+ }],
26823
+ ...meta
26815
26824
  };
26816
26825
  const structuredContent = value;
26817
26826
  return {
@@ -26820,7 +26829,8 @@ var MCPServer = class extends _mastra_core_mcp.MCPServerBase {
26820
26829
  content: [{
26821
26830
  type: "text",
26822
26831
  text: JSON.stringify(structuredContent)
26823
- }]
26832
+ }],
26833
+ ...meta
26824
26834
  };
26825
26835
  }
26826
26836
  registerResourceHandlers(server) {
@@ -27165,17 +27175,15 @@ var MCPServer = class extends _mastra_core_mcp.MCPServerBase {
27165
27175
  /** Reads an `ui://` app resource; application resources require a protocol request. */
27166
27176
  async readResource(uri) {
27167
27177
  const html = this.appResourceHtml.get(uri);
27168
- if (html === void 0) throw new _mastra_core_error.MastraError({
27178
+ const resource = this.appResourceList.find((r) => r.uri === uri);
27179
+ if (html === void 0 || !resource) throw new _mastra_core_error.MastraError({
27169
27180
  id: "MCP_SERVER_RESOURCE_NOT_FOUND",
27170
27181
  domain: _mastra_core_error.ErrorDomain.MCP,
27171
27182
  category: _mastra_core_error.ErrorCategory.USER,
27172
27183
  text: `Resource '${uri}' not found; application resources are only readable through an MCP request`,
27173
27184
  details: { uri }
27174
27185
  });
27175
- return { contents: [{
27176
- uri,
27177
- text: html
27178
- }] };
27186
+ return { contents: [this.resourceContents(resource, { text: html })] };
27179
27187
  }
27180
27188
  /** Lists `ui://` app resources; application resources require a protocol request. */
27181
27189
  async listResources() {
@@ -27195,23 +27203,23 @@ function errorResult(text) {
27195
27203
  isError: true
27196
27204
  };
27197
27205
  }
27198
- /** Keeps `_meta.ui.resourceUri` and the flat MCP Apps key in sync for older hosts. */
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. */
27199
27211
  function normalizeUiMeta(meta) {
27200
- if (!meta) return void 0;
27212
+ const resourceUri = uiResourceUri(meta);
27213
+ if (!meta || !resourceUri) return meta;
27201
27214
  const ui = meta.ui;
27202
- const flat = meta[_modelcontextprotocol_ext_apps.RESOURCE_URI_META_KEY];
27203
- if (ui?.resourceUri && !flat) return {
27204
- ...meta,
27205
- [_modelcontextprotocol_ext_apps.RESOURCE_URI_META_KEY]: ui.resourceUri
27206
- };
27207
- if (flat && !ui?.resourceUri) return {
27215
+ return {
27208
27216
  ...meta,
27209
27217
  ui: {
27210
- ...ui ?? {},
27211
- resourceUri: flat
27212
- }
27218
+ ...ui,
27219
+ resourceUri
27220
+ },
27221
+ [_modelcontextprotocol_ext_apps.RESOURCE_URI_META_KEY]: resourceUri
27213
27222
  };
27214
- return meta;
27215
27223
  }
27216
27224
  //#endregion
27217
27225
  //#region src/server/types.ts