@mastra/mcp 1.17.0-alpha.2 → 1.17.1-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 CHANGED
@@ -1,5 +1,113 @@
1
1
  # @mastra/mcp
2
2
 
3
+ ## 1.17.1-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Fixed MCP tool listing when a tool has no input schema. ([#21861](https://github.com/mastra-ai/mastra/pull/21861))
8
+
9
+ - Updated dependencies [[`88d14ca`](https://github.com/mastra-ai/mastra/commit/88d14cac008582a618fecc3d5c7fd3bdf4f6ddc3), [`84a5b69`](https://github.com/mastra-ai/mastra/commit/84a5b699f84d6bae0a34efe5a970d891090b9f41), [`84a5b69`](https://github.com/mastra-ai/mastra/commit/84a5b699f84d6bae0a34efe5a970d891090b9f41), [`84a5b69`](https://github.com/mastra-ai/mastra/commit/84a5b699f84d6bae0a34efe5a970d891090b9f41), [`038b7b4`](https://github.com/mastra-ai/mastra/commit/038b7b405cb4ac25ab3f3031334111b1f87ac112), [`4132d61`](https://github.com/mastra-ai/mastra/commit/4132d61f8367077120ee9e6420d3224dffd93c93)]:
10
+ - @mastra/core@1.60.1-alpha.0
11
+
12
+ ## 1.17.0
13
+
14
+ ### Minor Changes
15
+
16
+ - MCP tools served over HTTP now see the authenticated caller. When an MCP server runs behind a Mastra server with `server.auth` configured, the resolved user is bridged into `extra.authInfo` automatically, on both the streamable HTTP and SSE transports. Previously `extra.authInfo` was always undefined because the request handed to the MCP transport was rebuilt without the auth data. ([#21689](https://github.com/mastra-ai/mastra/pull/21689))
17
+
18
+ **Custom verification**
19
+
20
+ If your own middleware verifies the caller, build the auth info yourself with the new `server.mcpOptions.setRequestAuth` hook:
21
+
22
+ ```ts
23
+ export const mastra = new Mastra({
24
+ mcpServers: { myServer },
25
+ server: {
26
+ middleware: [verifyBearerToken],
27
+ mcpOptions: {
28
+ setRequestAuth: (req, requestContext) => {
29
+ const payload = requestContext.get('bearerPayload');
30
+ req.auth = { token: payload.token, clientId: payload.sub, scopes: payload.scope.split(' ') };
31
+ },
32
+ },
33
+ },
34
+ });
35
+ ```
36
+
37
+ Fixes #17291
38
+
39
+ - Added elicitation support on the `2026-07-28` protocol revision using the spec's multi round-trip mechanism, completing the opt-in `protocolVersion` support. ([#20931](https://github.com/mastra-ai/mastra/pull/20931))
40
+
41
+ **Server** — tools keep the same promise-shaped API on both eras:
42
+
43
+ ```typescript
44
+ execute: async (inputData, options) => {
45
+ const answer = await options.mcp.elicitation.sendRequest({
46
+ message: 'What is your favorite color?',
47
+ requestedSchema: { type: 'object', properties: { color: { type: 'string' } } },
48
+ });
49
+ // ...
50
+ };
51
+ ```
52
+
53
+ On a `2026-07-28` request, the tool call first returns an `input_required` result. After the client answers, the call retries with the answer attached. The tool function re-executes from the top on each retry, so keep side effects idempotent (or place them after the last elicitation) and keep the order of `sendRequest()` calls deterministic. Legacy connections keep the existing push-based `elicitation/create` flow unchanged.
54
+
55
+ **Client** — a handler registered with `elicitation.onRequest()` now fires on both eras: on `2026-07-28` connections, embedded elicitation requests are dispatched through the same handler and the originating tool call retries automatically. The warning that elicitation only works on legacy connections is removed.
56
+
57
+ - Added per-server time budgets and duration metrics to MCP discovery methods. ([#21560](https://github.com/mastra-ai/mastra/pull/21560))
58
+
59
+ ```typescript
60
+ const { tools, errors, durations } = await mcp.listToolsWithErrors({
61
+ perServerTimeoutMs: 3_000,
62
+ });
63
+ ```
64
+
65
+ - Added opt-in support for the stateless MCP protocol revision `2026-07-28` behind a `protocolVersion` flag on both `MCPServer` and the MCP client. Omitting the flag keeps today's behavior unchanged. ([#20929](https://github.com/mastra-ai/mastra/pull/20929))
66
+
67
+ **Server**
68
+
69
+ ```typescript
70
+ const server = new MCPServer({
71
+ name: 'My Server',
72
+ version: '1.0.0',
73
+ tools: { weatherTool },
74
+ protocolVersion: '2026-07-28',
75
+ cacheHints: {
76
+ 'tools/list': { ttlMs: 60_000, cacheScope: 'private' },
77
+ },
78
+ });
79
+ ```
80
+
81
+ With the flag set:
82
+
83
+ - One HTTP endpoint serves both protocol eras: `2026-07-28` clients are served natively (stateless), and legacy clients are served through an automatic stateless fallback.
84
+ - `startStdio()` serves both eras, selecting the era from the connection's opening exchange.
85
+ - Tool, prompt, and resource change notifications also reach `2026-07-28` clients through `subscriptions/listen`.
86
+ - Tool log messages honor the caller's per-request `logLevel` opt-in.
87
+ - Optional `cacheHints` advertise `ttlMs` / `cacheScope` on cacheable results such as `tools/list`.
88
+ - `startHTTP()` continues to enforce configured host and origin guards. Session and handler-lifetime transport options fail with a clear error instead of being ignored.
89
+
90
+ **Client**
91
+
92
+ ```typescript
93
+ const mcp = new MCPClient({
94
+ servers: {
95
+ weather: {
96
+ url: new URL('https://example.com/mcp'),
97
+ protocolVersion: 'auto', // probe, fall back to legacy
98
+ // or '2026-07-28' to pin the revision and fail loudly when unavailable
99
+ },
100
+ },
101
+ });
102
+ ```
103
+
104
+ Elicitation handlers currently only fire on legacy connections; support for the `2026-07-28` input-required mechanism ships separately.
105
+
106
+ ### Patch Changes
107
+
108
+ - Updated dependencies [[`587f6ef`](https://github.com/mastra-ai/mastra/commit/587f6efcfc25880b93760a8607d1cd381ec612fe), [`7e096f0`](https://github.com/mastra-ai/mastra/commit/7e096f02f0dddbf09b85d306458351245ed2f886), [`d7e6745`](https://github.com/mastra-ai/mastra/commit/d7e67456954863c55440ea9c49bc6ceb9949972d), [`6223446`](https://github.com/mastra-ai/mastra/commit/6223446ddce6166e96e0ba5e00d628b615dee8ca), [`15101bb`](https://github.com/mastra-ai/mastra/commit/15101bb53c0d934f31af6b8813b88191e382a5e5), [`4e7a421`](https://github.com/mastra-ai/mastra/commit/4e7a421dce8a48742f785d1e93ad2f43a572b282), [`c2c3deb`](https://github.com/mastra-ai/mastra/commit/c2c3debcf670c7082d0a5e553aa99818a864698c), [`d8308a2`](https://github.com/mastra-ai/mastra/commit/d8308a2be3c07e777393d1017a381dcae3890d30), [`b0a2a07`](https://github.com/mastra-ai/mastra/commit/b0a2a07800d42bd9823292e7db832374ed084c9c), [`74e5bd3`](https://github.com/mastra-ai/mastra/commit/74e5bd315b8b3a1e04cb6cf480bb0f5fc4951dc8), [`242e324`](https://github.com/mastra-ai/mastra/commit/242e3241e73cbd5c9bb86a31ebb49ca0256488d4), [`217e967`](https://github.com/mastra-ai/mastra/commit/217e9672d8b3160eb729d8e9f0044949e88da239), [`d774e89`](https://github.com/mastra-ai/mastra/commit/d774e8930c781df8c9effe3763e6b501c099b6cc), [`9c27a53`](https://github.com/mastra-ai/mastra/commit/9c27a53cd9d3de4f3f025bc387d94ce371c33f95), [`8f0a332`](https://github.com/mastra-ai/mastra/commit/8f0a3321bf180368d76fe7b36aa1a8f60f00b6de), [`0b4f108`](https://github.com/mastra-ai/mastra/commit/0b4f1089aa8d92e67c2a8e99726822c5ee410784), [`9acb50f`](https://github.com/mastra-ai/mastra/commit/9acb50f71cec9c362f06820033f90ae6b1f8282f), [`46e9e3f`](https://github.com/mastra-ai/mastra/commit/46e9e3f73babe1bc70080a596cf2ac0b9da48519), [`3f9a190`](https://github.com/mastra-ai/mastra/commit/3f9a19057c027155867b9317294ee4ca7bd0581a), [`dff25a1`](https://github.com/mastra-ai/mastra/commit/dff25a1103fa72ee082a9b6f805ebeb5ce400753), [`6db7a5d`](https://github.com/mastra-ai/mastra/commit/6db7a5dd3dd2b6f7ef75dcd804fcffef5fa83963), [`217e967`](https://github.com/mastra-ai/mastra/commit/217e9672d8b3160eb729d8e9f0044949e88da239), [`583e235`](https://github.com/mastra-ai/mastra/commit/583e23519c13af16c1746f9c49722d011216611b), [`b098de9`](https://github.com/mastra-ai/mastra/commit/b098de9d7cb9f672e0883a5c716465a3a689693d), [`e8808e3`](https://github.com/mastra-ai/mastra/commit/e8808e3d8eb585a2565be53e56a7e0e1477352a4), [`a77f8d4`](https://github.com/mastra-ai/mastra/commit/a77f8d4740d2178a74c41e4bf678b4fcd8fa0bb2), [`7f78585`](https://github.com/mastra-ai/mastra/commit/7f785857e401570e2ffb316911f126ed363aa537), [`33374ba`](https://github.com/mastra-ai/mastra/commit/33374ba359e4fb13eaa918ae925fe167a3c55414), [`940bf5c`](https://github.com/mastra-ai/mastra/commit/940bf5ccf04f2c9ebd8a1390431733222a03b1cd), [`c549e2f`](https://github.com/mastra-ai/mastra/commit/c549e2f40edc1cac5d9e74e82f90da22b48df084), [`58c43d3`](https://github.com/mastra-ai/mastra/commit/58c43d3f7cb2eeaeb8ac733ae71dde822348e588), [`ef6e295`](https://github.com/mastra-ai/mastra/commit/ef6e295b59bc25a5b61b633a89c97bcfce9fb465), [`208e1b3`](https://github.com/mastra-ai/mastra/commit/208e1b39f30f4b386e494394e9d71d96f0f90241), [`c938d34`](https://github.com/mastra-ai/mastra/commit/c938d34739936c8ecbabd67ad6a4a4396f41c4c6), [`88ddc7c`](https://github.com/mastra-ai/mastra/commit/88ddc7ce01d40175f13a3228b789a906779680bd), [`f2a4afd`](https://github.com/mastra-ai/mastra/commit/f2a4afd7e37e809669001ed17724b341a5c1f45e), [`d438148`](https://github.com/mastra-ai/mastra/commit/d438148e222c1e2fb3c652725ce75680962ebec4), [`ba05fe0`](https://github.com/mastra-ai/mastra/commit/ba05fe0738f70cb686777546e968237d09269142), [`40d358e`](https://github.com/mastra-ai/mastra/commit/40d358e29d55543803e64b49241122f598ffabc7), [`d26a8d4`](https://github.com/mastra-ai/mastra/commit/d26a8d4281f28414715b333c85bedaf70d0b2890), [`e80cd7e`](https://github.com/mastra-ai/mastra/commit/e80cd7e7683e7d732e1cc6784bcac1d2640d2ce3), [`ccbbcd9`](https://github.com/mastra-ai/mastra/commit/ccbbcd974eedff4367a54ed0e24c9ee742ab2f61), [`1d9a0ea`](https://github.com/mastra-ai/mastra/commit/1d9a0ea4a9901baee6cd56737243bd6d1f631ac0), [`677cdc6`](https://github.com/mastra-ai/mastra/commit/677cdc6af564dec29a13464d12b7ab2a4efc22e9), [`c549e2f`](https://github.com/mastra-ai/mastra/commit/c549e2f40edc1cac5d9e74e82f90da22b48df084), [`a7dd322`](https://github.com/mastra-ai/mastra/commit/a7dd32247d95afc539f483ca37f4594af0387f59), [`3f5c6f7`](https://github.com/mastra-ai/mastra/commit/3f5c6f728ea35da344248de9aa070f12849f3aa0), [`a318490`](https://github.com/mastra-ai/mastra/commit/a318490e17da32f338d50929c770d901a9b3dd72), [`b860493`](https://github.com/mastra-ai/mastra/commit/b86049391100e665d579f700c8a2034c036defc3), [`d4be8c1`](https://github.com/mastra-ai/mastra/commit/d4be8c1739d22d621e3f78790e1dd5eb5ecc3589), [`a5d2eb1`](https://github.com/mastra-ai/mastra/commit/a5d2eb10347eade1ae2816d88f466c25186c54a5), [`3667679`](https://github.com/mastra-ai/mastra/commit/3667679db057edfb086846d13369fdda4902ad65), [`49696e8`](https://github.com/mastra-ai/mastra/commit/49696e8e42f870674a0a58f5abcd22cc54dd2864), [`2ef2f23`](https://github.com/mastra-ai/mastra/commit/2ef2f230a7aed342e7dc3b2000cd42e4c43e08a7), [`763e0c6`](https://github.com/mastra-ai/mastra/commit/763e0c61e04d76ad9a9efd301aa57525ca0cbea9), [`20504b2`](https://github.com/mastra-ai/mastra/commit/20504b2ecebd0e077acda3d457ab57480a98ed3e), [`77e6b1b`](https://github.com/mastra-ai/mastra/commit/77e6b1bc4c46ce94fe501023fb4393c812ec6be3), [`c5f964d`](https://github.com/mastra-ai/mastra/commit/c5f964d3f77064e978f8066ec506eed77ba5c63c), [`23e0be2`](https://github.com/mastra-ai/mastra/commit/23e0be261381e49534b4ff3101c60ee64a946cbf), [`7fc8806`](https://github.com/mastra-ai/mastra/commit/7fc880627d3cbf995d31ea0e8b807bf15417e651), [`0e02eac`](https://github.com/mastra-ai/mastra/commit/0e02eacdb2e30e1697a41910b41163742a181dc1), [`4df174c`](https://github.com/mastra-ai/mastra/commit/4df174c32bddf093a82f273070b8380aef7c9e90), [`f7c25b5`](https://github.com/mastra-ai/mastra/commit/f7c25b5106ddfb48e591f98df7a51e0f2dd01dba), [`7aad631`](https://github.com/mastra-ai/mastra/commit/7aad631b43bc10db77d5b8c66b200d7a49d18bf2), [`512100a`](https://github.com/mastra-ai/mastra/commit/512100a7d8b7e9c920f2590c6b3612f5de0d3cff), [`e81744c`](https://github.com/mastra-ai/mastra/commit/e81744cd13c46619c142dc521dc0baac47607a84), [`f8f653f`](https://github.com/mastra-ai/mastra/commit/f8f653f10980d01a73706cc3c8689ca5e40ce808), [`dc09cc1`](https://github.com/mastra-ai/mastra/commit/dc09cc1083d861cde192c1cd235324dc75b8c731), [`9ef432b`](https://github.com/mastra-ai/mastra/commit/9ef432b6faa534b57b0d182a610e13dd9a7123ff), [`36b4649`](https://github.com/mastra-ai/mastra/commit/36b4649045a3a380cbab8ceca866db4086223aff), [`b9cf308`](https://github.com/mastra-ai/mastra/commit/b9cf30846f97f99ac1906ee8a68f4f2d117b0378), [`2e1d098`](https://github.com/mastra-ai/mastra/commit/2e1d0984e325fd319d32ea182f596b3170be3847), [`377eb81`](https://github.com/mastra-ai/mastra/commit/377eb81ce43b964e3a6b541df172da74a8ff3716), [`1794a79`](https://github.com/mastra-ai/mastra/commit/1794a79178c418004a7261b1ad9114066f7ef01d), [`0cdc5dc`](https://github.com/mastra-ai/mastra/commit/0cdc5dc69024957815da4f51acc4119eb4f447d7), [`5740ec6`](https://github.com/mastra-ai/mastra/commit/5740ec60c760ffdfbfaa59d603d03b847c864e05)]:
109
+ - @mastra/core@1.60.0
110
+
3
111
  ## 1.17.0-alpha.2
4
112
 
5
113
  ### Minor Changes
@@ -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: "1.17.0-alpha.2"
6
+ version: "1.17.1-alpha.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.17.0-alpha.2",
2
+ "version": "1.17.1-alpha.0",
3
3
  "package": "@mastra/mcp",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -104,7 +104,7 @@ By default, `MCPServer` speaks the legacy (2025-era) MCP protocol: sessionful st
104
104
  - Tool list, prompt list, resource list, and resource update notifications also reach `2026-07-28` clients through `subscriptions/listen`.
105
105
  - Tool log messages honor the caller's per-request `logLevel` opt-in instead of the session-level `logging/setLevel`.
106
106
  - Configured `cacheHints` are advertised on cacheable results such as `tools/list`.
107
- - Tool elicitation (`options.mcp.elicitation.sendRequest()`) works on both eras. On `2026-07-28` requests, it uses the protocol's multi round-trip mechanism. The tool call first returns an `input_required` result. After the client answers, the call retries with the answer attached. The `sendRequest()` promise API is unchanged, but the tool function re-executes from the top on each retry, so keep side effects idempotent (or place them after the last elicitation) and keep the order of `sendRequest()` calls deterministic for a given input.
107
+ - Tool elicitation (`options.mcp.elicitation.sendRequest()`) works on both eras. On `2026-07-28` requests, it uses the protocol's multi round-trip mechanism. The tool call first returns an `input_required` result. After the client answers, the call retries with the answer attached. The `sendRequest()` promise API is unchanged, but the tool function re-executes from the top on each retry, so keep side effects idempotent (or place them after the last elicitation) and keep the order of `sendRequest()` calls deterministic for an input.
108
108
 
109
109
  ```typescript
110
110
  const server = new MCPServer({
package/dist/index.cjs CHANGED
@@ -27234,7 +27234,7 @@ var MCPServer = class extends _mastra_core_mcp.MCPServerBase {
27234
27234
  const toolSpec = {
27235
27235
  name: tool.id || "unknown",
27236
27236
  description: tool.description,
27237
- inputSchema: this.convertSchema(tool.parameters)
27237
+ inputSchema: this.convertInputSchema(tool.parameters)
27238
27238
  };
27239
27239
  if (tool.outputSchema) toolSpec.outputSchema = this.convertSchema(tool.outputSchema);
27240
27240
  if (tool.mcp?.annotations) toolSpec.annotations = tool.mcp.annotations;
@@ -28506,6 +28506,12 @@ var MCPServer = class extends _mastra_core_mcp.MCPServerBase {
28506
28506
  }
28507
28507
  return jsonSchema;
28508
28508
  }
28509
+ convertInputSchema(schema) {
28510
+ return this.convertSchema(schema) ?? {
28511
+ type: "object",
28512
+ properties: {}
28513
+ };
28514
+ }
28509
28515
  /**
28510
28516
  * Gets a list of all tools provided by this MCP server with their schemas.
28511
28517
  *
@@ -28529,7 +28535,7 @@ var MCPServer = class extends _mastra_core_mcp.MCPServerBase {
28529
28535
  id: toolId,
28530
28536
  name: tool.id || toolId,
28531
28537
  description: tool.description,
28532
- inputSchema: this.convertSchema(tool.parameters),
28538
+ inputSchema: this.convertInputSchema(tool.parameters),
28533
28539
  outputSchema: this.convertSchema(tool.outputSchema),
28534
28540
  toolType: tool.mcp?.toolType,
28535
28541
  _meta: withMastraToolStrictMeta(tool.mcp?._meta, tool.strict)
@@ -28540,7 +28546,7 @@ var MCPServer = class extends _mastra_core_mcp.MCPServerBase {
28540
28546
  id: toolId,
28541
28547
  name: tool.id || toolId,
28542
28548
  description: tool.description,
28543
- inputSchema: this.convertSchema(tool.parameters),
28549
+ inputSchema: this.convertInputSchema(tool.parameters),
28544
28550
  outputSchema: this.convertSchema(tool.outputSchema),
28545
28551
  toolType: tool.mcp?.toolType,
28546
28552
  _meta: withMastraToolStrictMeta(tool.mcp?._meta, tool.strict)
@@ -28580,7 +28586,7 @@ var MCPServer = class extends _mastra_core_mcp.MCPServerBase {
28580
28586
  return {
28581
28587
  name: tool.id || toolId,
28582
28588
  description: tool.description,
28583
- inputSchema: this.convertSchema(tool.parameters),
28589
+ inputSchema: this.convertInputSchema(tool.parameters),
28584
28590
  outputSchema: this.convertSchema(tool.outputSchema),
28585
28591
  toolType: tool.mcp?.toolType,
28586
28592
  _meta: withMastraToolStrictMeta(tool.mcp?._meta, tool.strict)