0
Fork 0
mirror of https://github.com/mastra-ai/mastra.git synced 2026-11-17 08:44:46 +00:00
Commit graph

857 commits

Author SHA1 Message Date
dane-ai-mastra[bot]
d60ba71be0 chore: version - exit prerelease mode 2026-11-12 21:12:29 +00:00
dane-ai-mastra[bot]
5c87442ed7
chore: version packages (alpha) (#30203)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and publish to npm
yourself or [setup this action to publish
automatically](https://github.com/changesets/action#with-publishing). If
you're not ready to do a release yet, that's fine, whenever you add more
changesets to main, this PR will be updated.

⚠️⚠️⚠️⚠️⚠️⚠️

`main` is currently in **pre mode** so this branch has prereleases
rather than normal releases. If you want to exit prereleases, run
`changeset pre exit` on `main`.

⚠️⚠️⚠️⚠️⚠️⚠️

# Releases

> The changelog information of each package has been omitted from this
message, as the content exceeds the size limit.

## @mastra/auth-auth0@1.3.0-alpha.0


## @mastra/auth-clerk@1.4.0-alpha.0


## @mastra/auth-okta@0.3.0-alpha.0


## @mastra/auth-supabase@1.2.0-alpha.0


## @mastra/client-js@1.60.0-alpha.13


## @mastra/auth@1.2.0-alpha.0


## @mastra/core@1.83.0-alpha.13


## @mastra/playground-ui@69.0.0-alpha.15


## @mastra/rag@2.8.0-alpha.3


## @mastra/server@1.83.0-alpha.13


## @mastra/server-adapters-test-suite@0.3.0-alpha.5


## @mastra/auth-better-auth@1.1.11-alpha.2


## @mastra/auth-cloud@1.2.9-alpha.0


## @mastra/auth-neon@0.3.6-alpha.1


## @mastra/auth-workos@1.6.9-alpha.0


## @mastra/discord@1.3.4-alpha.0


## @mastra/react@1.15.0-alpha.13


## @mastra/deployer-cloud@1.83.0-alpha.13


## @mastra/deployer-cloudflare@1.2.42-alpha.3


## @mastra/deployer-netlify@1.2.42-alpha.1


## @mastra/deployer-sandbox@0.3.27-alpha.1


## @mastra/deployer-vercel@1.2.42-alpha.1


## @mastra/longmemeval@1.1.42-alpha.13


## @mastra/opencode@0.1.42-alpha.13


## @mastra/factory@0.28.0-alpha.15


## create-factory@0.4.3-alpha.15


## @mastra/code-sdk@1.19.0-alpha.15


## mastracode@0.50.0-alpha.14


## @mastra/agent-builder@1.2.1-alpha.5


## mastra@1.39.0-alpha.15


## @mastra/connect@1.4.0-alpha.6


## @mastra/deployer@1.83.0-alpha.13


## @mastra/editor@0.17.1-alpha.7


## @mastra/mcp@2.9.0-alpha.5


## @mastra/mcp-docs-server@1.3.13-alpha.17


## @mastra/memory@1.41.1-alpha.5


## @mastra/schema-compat@1.4.0-alpha.2


## @mastra/elysia@0.1.23-alpha.13


## @mastra/express@1.5.27-alpha.13


## @mastra/fastify@1.5.27-alpha.13


## @mastra/hono@1.7.25-alpha.13


## @mastra/koa@1.7.27-alpha.13


## @mastra/nestjs@0.3.0-alpha.13


## @mastra/next@0.2.41-alpha.13


## @mastra/tanstack-start@0.2.41-alpha.13


## @mastra/voice-google-gemini-live@0.14.19-alpha.2


## @mastra/voice-openai-realtime@0.14.9-alpha.3


## @mastra/voice-xai-realtime@0.2.18-alpha.2


## @mastra/inngest@1.11.2-alpha.9


## @mastra/temporal@0.6.0-alpha.13


## create-mastra@1.39.0-alpha.15


## @internal/playground@1.39.0-alpha.15

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-11-12 12:07:03 -08:00
Daniel Lew
392c7b69d5
feat(server): built-in MCP endpoint for agents, workflows and tools (#29929)
Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
2026-11-12 12:56:28 -05:00
dane-ai-mastra[bot]
055a8c3b82 chore: version packages 2026-11-12 04:17:40 +00:00
mastra-platform[bot]
2d4284603a
Fix MCP core compatibility, Windows browser paths, and AI SDK tool titles (#30125) 2026-11-11 15:45:01 -08:00
mastra-platform[bot]
056d35d943
Enforce JSON Schema formats in MCP tool validation (#30113) 2026-11-11 14:16:55 -08:00
Dane - AI (Mastra)
c22107fce3
chore(deps): update dependency @ai-sdk/provider-utils@>=3.0.0 <3.0.38 to v3.0.45 (#29844) 2026-11-10 20:07:34 -08:00
YujohnNattrass
5c0f12c5a2
ci(mcp): fix MCP compatibility job on version-packages PRs (#29988)
Co-authored-by: YJ <yj@example.com>
Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
2026-11-10 19:55:49 -08:00
dane-ai-mastra[bot]
23cc34a9c5
chore: version packages (alpha) (#29938)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and publish to npm
yourself or [setup this action to publish
automatically](https://github.com/changesets/action#with-publishing). If
you're not ready to do a release yet, that's fine, whenever you add more
changesets to main, this PR will be updated.

⚠️⚠️⚠️⚠️⚠️⚠️

`main` is currently in **pre mode** so this branch has prereleases
rather than normal releases. If you want to exit prereleases, run
`changeset pre exit` on `main`.

⚠️⚠️⚠️⚠️⚠️⚠️

# Releases

> The changelog information of each package has been omitted from this
message, as the content exceeds the size limit.

## @mastra/factory@0.28.0-alpha.6


## @mastra/code-sdk@1.19.0-alpha.6


## @mastra/playground-ui@69.0.0-alpha.7


## @mastra/client-js@1.60.0-alpha.6


## @mastra/react@1.15.0-alpha.6


## @mastra/deployer-cloud@1.83.0-alpha.6


## @mastra/longmemeval@1.1.42-alpha.6


## @mastra/opencode@0.1.42-alpha.6


## create-factory@0.4.3-alpha.6


## mastracode@0.50.0-alpha.6


## @mastra/agent-builder@1.2.1-alpha.3


## mastra@1.39.0-alpha.6


## @mastra/core@1.83.0-alpha.6


## @mastra/deployer@1.83.0-alpha.6


## @mastra/editor@0.17.1-alpha.4


## @mastra/mcp@2.9.0-alpha.3


## @mastra/mcp-docs-server@1.3.13-alpha.9


## @mastra/memory@1.41.1-alpha.3


## @mastra/rag@2.7.3-alpha.2


## @mastra/schema-compat@1.3.18-alpha.0


## @mastra/server@1.83.0-alpha.6


## @mastra/elysia@0.1.23-alpha.6


## @mastra/express@1.5.27-alpha.6


## @mastra/fastify@1.5.27-alpha.6


## @mastra/hono@1.7.25-alpha.6


## @mastra/koa@1.7.27-alpha.6


## @mastra/nestjs@0.3.0-alpha.6


## @mastra/next@0.2.41-alpha.6


## @mastra/server-adapters-test-suite@0.3.0-alpha.3


## @mastra/tanstack-start@0.2.41-alpha.6


## @mastra/upstash@1.6.1-alpha.0


## @mastra/vectorize@1.1.5-alpha.0


## @mastra/voice-google-gemini-live@0.14.19-alpha.0


## @mastra/voice-openai-realtime@0.14.9-alpha.0


## @mastra/voice-xai-realtime@0.2.18-alpha.0


## @mastra/inngest@1.11.2-alpha.4


## @mastra/temporal@0.6.0-alpha.6


## create-mastra@1.39.0-alpha.6


## @internal/playground@1.39.0-alpha.6

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-11-10 15:51:29 -08:00
Leo
c3ef10ee30
fix(core,mcp): warn when same-named MCP tools replace each other (#29415)
## Summary

When two MCP servers expose a tool with the same name and you pass
`toolsets: await mcp.listToolsets()` to an agent, the agent flattens
toolsets by tool name, so only the later server's tool reaches the model
and nothing is logged. `listTools()` has a smaller variant of the same
problem: server and tool names can both contain `_`, so `local` +
`x_status` and `local_x` + `status` both become `local_x_status`, and
one tool is dropped. This PR makes both cases log a warning, without
changing which tool wins, and fixes the `listToolsets()` reference,
which said its keys were namespaced.

```diff
 Agent.listToolsets (packages/core/src/agent/agent.ts)
   for each toolset, for each tool
+    if an earlier toolset already used this tool name
+      logger.warn(tool, [earlier toolset, this toolset])
     toolsForRequest[toolName] = tool        # last still wins

 MCPClient.listToolsWithErrors / toolsFromDefinitions (packages/mcp/src/client/configuration.ts)
-  tools[`${server}_${tool}`] = tool
+  setNamespacedTool(...)                    # same key, warns when a different pair already took it
```

Docs: the `listToolsets()` reference now says tools keep their raw
names, explains what happens on a collision, and shows `toolsets: { mcp:
await mcp.listTools() }` as a way to keep both tools at request time.
The `listTools()` reference describes the `_` key collision. The "Static
and runtime tools" table in the MCP guide gets a "Tool names" row.

## Evidence

New tests:
`packages/core/src/agent/__tests__/toolset-name-collisions.test.ts`
(real `Agent`, `stream` and `generate`, mock model, checks which tools
reach the model) and
`packages/mcp/src/client/tool-name-collisions.test.ts` (real MCP servers
over HTTP on 127.0.0.1, real `MCPClient`). Only the logger's `warn` is
spied on.

- **Before** (main's `agent.ts` and `configuration.ts` swapped in, same
tests):
  ```
× warns, naming both toolsets, when two toolsets expose `search`
(stream)
× warns, naming both toolsets, when two toolsets expose `search`
(generate)
  Tests  2 failed | 1 passed (3)
× warns, naming both servers and tools, when `local`/`x_status` and
`local_x`/`status` collide
× warns the same way when rebuilding a cached catalog with
toolsFromDefinitions()
  Tests  2 failed | 1 passed (3)
  ```
**After:** `Tests 3 passed (3)` in each file. Each test also asserts
that the winning tool is the same as on main (the later toolset or
server), and that tools with different names produce no warning.

What the warnings look like (captured from a real run):

```
[AGENT] Tool "search" from toolset "tickets" replaces the tool with the same name from toolset "docs", so the "docs" tool is not used. Give the tools distinct names to keep both. {
  agent: 'Support Agent', tool: 'search', toolsets: [ 'docs', 'tickets' ], runId: '...'
}
[LLM] MCP tool key "local_x_status" from server "local_x" (tool "status") replaces the tool from server "local" (tool "x_status"), which produces the same key. Only the tool from "local_x" is kept. Rename one of the servers in `servers` to keep both. {
  key: 'local_x_status', replaced: { serverName: 'local', toolName: 'x_status' }, replacedBy: { serverName: 'local_x', toolName: 'status' }
}
```

I also ran the docs workaround against two real MCP servers that both
expose `search`: with `toolsets: { mcp: await mcp.listTools() }` the
model received `docs_search` and `tickets_search`, and the snippet
typechecks.

Other checks run: existing `tools.test.ts`, `tool-handling.test.ts` and
`mcp-instructions.test.ts` (core), plus `configuration.test.ts` and
`discovery-settled.test.ts` (mcp), all pass. `tsc --noEmit` is clean for
core and for the touched mcp files. `oxlint` and `oxfmt` pass on the
touched files, and remark, oxfmt-mdx and Vale (error level) pass on both
docs pages. I took no docs screenshots: the change is two paragraphs, a
code block and one table row.

## Merge Danger

**Door:** two-way. The change only adds `logger.warn` calls and docs
text. No tool names, keys or winners change.

**Blast radius:** agents called with `toolsets` whose tool names
collide, and `MCPClient.listTools()` / `toolsFromDefinitions()` with
colliding `server_tool` keys. Those users now see one warning per
request (agent) or per discovery call (MCP client). Everyone else sees
no change.

Closes #29360

## Follow-ups

- Namespacing `listToolsets()` keys (the issue's first suggested fix)
would change the tool names the model sees, so it needs a maintainer
decision and is left out here.
- A toolset tool that replaces one of the agent's own `tools`, or a
`clientTools` entry that replaces a toolset tool, is still silent. That
is a different and possibly intentional override path, so this PR
doesn't warn on it.
- `mastra-mcp` typegen builds the same `${server}_${tool}` keys, so the
same `_` collision can produce a duplicate key in the generated types.

## Council review

| Round | Sol (GPT-6.1 Sol) | Opus (Claude Opus 5.5) | Grok 4.7 |
|---|---|---|---|
| 1 | Correctness 10, Tests 9, Scope 10, Code quality 10 | not run
(Sol-only round) | empty seat |
| 2 | 10 / 9 / 10 / 9 | 9 / 9 / 9 / 8 | empty seat |
| 3 | 10 / 9 / 10 / 9 | 9 / 9 / 10 / 9 | empty seat |
| 4 | 10 / 9 / 10 / 10 | 9 / 9 / 9 / 9 | empty seat |

Created with Claude Opus 5.5 in T3 Code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## ELI5

When tools from different servers have the same name, one can replace
another without notice. This change adds warnings when that happens and
updates the documentation, while keeping the existing rule that the
later tool wins.

## Changes

- Warn when an agent combines toolsets that contain the same raw tool
name.
- Warn when `listTools()` or `toolsFromDefinitions()` produce the same
`serverName_toolName` key for different server and tool pairs.
- Update the MCP documentation to explain raw tool names, collision
behavior, and how `listTools()` keeps server-prefixed names.
- Add tests for collisions, which tool remains, and distinct names.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 18:30:12 -05:00
shreyas-mastra
8a301f6d66
chore(deps): force minimatch 11 and glob 14 for Vanta findings (#29916) 2026-11-10 12:57:20 -08:00
dane-ai-mastra[bot]
779d2875b1
chore: version packages (alpha) (#29912)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and publish to npm
yourself or [setup this action to publish
automatically](https://github.com/changesets/action#with-publishing). If
you're not ready to do a release yet, that's fine, whenever you add more
changesets to main, this PR will be updated.

⚠️⚠️⚠️⚠️⚠️⚠️

`main` is currently in **pre mode** so this branch has prereleases
rather than normal releases. If you want to exit prereleases, run
`changeset pre exit` on `main`.

⚠️⚠️⚠️⚠️⚠️⚠️

# Releases

> The changelog information of each package has been omitted from this
message, as the content exceeds the size limit.

## @mastra/auth-studio@1.4.0-alpha.1


## @mastra/factory@0.28.0-alpha.5


## @mastra/mcp-apps-components@0.1.0-alpha.5


## @mastra/playground-ui@69.0.0-alpha.6


## @mastra/client-js@1.60.0-alpha.5


## @mastra/react@1.15.0-alpha.5


## @mastra/deployer-cloud@1.83.0-alpha.5


## @mastra/longmemeval@1.1.42-alpha.5


## @mastra/opencode@0.1.42-alpha.5


## create-factory@0.4.3-alpha.5


## @mastra/code-sdk@1.19.0-alpha.5


## mastracode@0.50.0-alpha.5


## @mastra/agent-builder@1.2.1-alpha.2


## mastra@1.39.0-alpha.5


## @mastra/core@1.83.0-alpha.5


## @mastra/deployer@1.83.0-alpha.5


## @mastra/editor@0.17.1-alpha.3


## @mastra/mcp@2.9.0-alpha.2


## @mastra/mcp-docs-server@1.3.13-alpha.8


## @mastra/memory@1.41.1-alpha.2


## @mastra/rag@2.7.3-alpha.1


## @mastra/server@1.83.0-alpha.5


## @mastra/elysia@0.1.23-alpha.5


## @mastra/express@1.5.27-alpha.5


## @mastra/fastify@1.5.27-alpha.5


## @mastra/hono@1.7.25-alpha.5


## @mastra/koa@1.7.27-alpha.5


## @mastra/nestjs@0.3.0-alpha.5


## @mastra/next@0.2.41-alpha.5


## @mastra/server-adapters-test-suite@0.3.0-alpha.2


## @mastra/tanstack-start@0.2.41-alpha.5


## @mastra/libsql@1.30.0-alpha.2


## @mastra/turso@0.1.21-alpha.2


## @mastra/inngest@1.11.2-alpha.3


## @mastra/temporal@0.6.0-alpha.5


## create-mastra@1.39.0-alpha.5


## @internal/playground@1.39.0-alpha.5

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-11-10 10:50:08 -08:00
Leo
92f9771a0f
fix(mcp): send a hydrated tool's lazy connect with the call's requestContext (#29539)
## Summary

A tool rebuilt with `toolsFromDefinitions()` or `toolFromDefinition()`
connects on its first `execute()`, but that connect ran before
`execute()` entered the call's context. The handshake
(`server/discover`, and `initialize` + `notifications/initialized` on
2025-11-25 servers) reached the server definition's custom `fetch` with
`requestContext === null`, so a server that authenticates every request
refused it and a client built only from a cached catalog never
connected. This PR runs the lazy connect inside a connection-scoped
context that only the transport's `fetch` reads.

```diff
 buildToolFromListEntry → execute(input, context)   (packages/mcp/src/client/client.ts)
+  operationContext = context.requestContext ?? null
   if connectFirst
-    await connect()                                 # fetch saw null
+    connectAsCall(operationContext, connect)       # exits any operation scope, sets the connection context
   operationContextStore.run(operationContext, tools/call)

 forceReconnect, inside a tool call (reconnectAfterTransportFailure)
-  connect()                                         # in the call's operation scope
+  connectAsCall(operationContext, connect)

 transport fetch wrapper
-  requestContext = operationContextStore ?? null
+  requestContext = operation scope (even an explicit null)
+                ?? connectionContextStore           # handshake, event stream
+                ?? replyContextStore, for JSON-RPC replies only
+                ?? null

 connectHttp, before client.connect()
+  every transport.onmessage runs outside connectionContextStore,
+  with the reply context captured when the transport was created
```

Why a second store instead of moving the connect into
`operationContextStore.run` (the fix the issue proposed):
`operationContextStore` also labels the entries `logger` receives.
Connecting inside it would put the first caller's context on every later
server log that arrives on the connection's event stream, or from a
stdio child process, including logs from other users' calls. The
connection store gives the handshake and the long-lived event stream the
opening call's credentials, while those logs stay unlabelled as on main.
Calls with no `requestContext`, and handshakes no call started
(`listTools()`, `listToolDefinitions()`), still pass `null`.

Server messages on an HTTP connection are delivered outside the
connection context, starting with the handshake. A request your code
starts from a server log or notification on that connection (for example
`client.listTools()` from a `logger` callback) gets `null`, as on main,
not the opening caller's context. The client's own JSON-RPC replies to
server requests on the connection, such as an elicitation answer on the
event stream, still go out with the connection's context.

A tool call that reconnects (a refused request, or a stdio server that
exited) now connects the same way. On main it reconnected inside the
call's operation scope, so the new event stream or stdio child delivered
every later server message in it. Later server logs were labelled with
the reconnecting caller, and a request started from a log handler
reached `fetch` as that caller. The new handshake, event stream and
replies still carry the caller's context. Logs on a call's own response
stream keep that call's label, as on main, which is why the fix exits
the operation scope when connecting rather than on every inbound
message.

Docs: the `fetch` paragraph in the `MCPClient` reference and the
`MastraFetchLike` JSDoc now say when the handshake gets a call's
`requestContext`. The reference example now shows how discovery
authenticates when the server checks every request (an app token limited
to discovery, or a cached catalog), and the auth-failure section no
longer says every request is a `POST`: on 2025-11-25 servers the event
stream is a `GET`.

## Evidence

New test file
`packages/mcp/src/client/hydrated-tool-request-context.test.ts`: real
MCP servers over HTTP on 127.0.0.1 (a 2026-07-28 stateless server and a
stateful 2025-11-25 server), plus a real stdio child
(`src/__fixtures__/logging-echo-server.ts`). The client's custom `fetch`
puts the `requestContext` user into an `x-user` header, and the server
records the header it actually received for each JSON-RPC method.

- **Before** (origin/main's `client.ts`, same tests):
  ```
× sends the lazy connect's handshake with the requestContext of the call
that opened it (2026-07-28)
× opens one connection for concurrent first calls and sends each
tools/call as its own user (2026-07-28)
× sends the lazy connect's handshake with the requestContext of the call
that opened it (2025-11-25)
× opens one connection for concurrent first calls and sends each
tools/call as its own user (2025-11-25)
× opens the event stream as the first call but does not label a later
call's server logs with it
AssertionError: expected [ { method: 'server/discover', … } ] to deeply
equal []
AssertionError: expected Set{ 'no-request-context' } to deeply equal
Set{ 'alice' }
  Tests  5 failed | 3 passed (8)
  ```
**After:** `Tests 17 passed (17)`, 5 of 5 repeated runs on the latest
head.
- **Requests started from server messages** (3 tests added after
review): a `client.listTools()` started from a server log on the event
stream, or from a log sent during the handshake, reaches `fetch` without
alice's context; a reply to an `elicitation/create` the server sends on
the event stream reaches it as alice. Against the previous head's
`client.ts`, the two leak tests fail (`tools/list` sent as `alice`);
with the reply branch disabled, the elicitation test fails.
- **Reconnects** (4 tests added after the CodeRabbit re-review). An HTTP
server stops, alice's call is refused and reconnects as the server comes
back. The handshake, event stream and retried call reach `fetch` as
alice. A server log on the new stream is unlabelled, and a `listTools()`
it starts gets `null`; on the previous head they were `alice`. An
elicitation reply on the new stream still goes as alice. A stdio server
exits, bob's call respawns it, and carol's later log is unlabelled; on
the previous head it was `bob`. A `reconnectServer()` from a log
callback answers elicitation as no one (was `alice`). A hydrated tool
connecting from a callback inside alice's call handshakes as bob, its
own caller (was `alice`). A guard test checks that a log on a call's own
response stream stays labelled with that call.
- **The issue's proposed fix** (connect inside
`operationContextStore.run`) passes the handshake tests but fails the
two log tests: `expected 'alice' to be null` for bob's server log on the
event stream and from the stdio child.
- **The issue's `repro.ts`**, run against a local build of this package:
on main it prints `server/discover (requestContext is null)` and `BUG: 1
of 2 requests reached fetch without the call's requestContext`; with
this change, `server/discover alice`, `tools/call alice`, `OK: all 2
requests reached fetch with the call's requestContext`. The `--listed`
control passes on both.

Other checks run: every non-e2e test file in `packages/mcp/src/client`
(622 tests) passes; `tsc --noEmit -p tsconfig.build.json` is clean, and
the new test file typechecks; `oxlint --type-aware --deny-warnings
src/client` and prettier pass on the changed files (oxfmt ignores
`src/client`); the docs page passes `oxfmt-mdx --check`, remark and
Vale. Not run: the client e2e project.

## Merge Danger

**Door:** two-way. Only the `requestContext` that a custom `fetch`
receives during a hydrated tool's first connect changes; reverting
restores `null`.

**Blast radius:** apps that build tools with `toolsFromDefinitions()` /
`toolFromDefinition()` and pass a 3-argument `fetch`. Their handshake,
and on 2025-11-25 servers the long-lived event stream and its re-opens,
now carry the first caller's `requestContext`. For a client shared
across users, that stream is authenticated as whoever's call opened the
connection, as already happens today after a reconnect inside a call. A
reconnect inside a call no longer labels later server logs with that
caller. Servers without a custom `fetch` (including stdio) see no
change.

Closes #29531

## Council review

Rounds: 5

| Seat | Round 1 | Round 2 | Round 3 | Round 4 | Round 5 |
| --- | --- | --- | --- | --- | --- |
| Claude Opus 5.5 | not run | 9/10 | 8.5/10 | 9/10 | 9/10 |
| GPT-6.1 Sol | 9.5/10 | 9.5/10 | 9.5/10 | 8/10 | 9.5/10 |
| Grok 4.7 | empty seat | empty seat | empty seat | empty seat | empty
seat |

CodeRabbit re-review fixes (reconnect context), GPT-6.1 Sol (Correctness
/ Tests / Scope / Code quality):

| Round | Scores | Finding fixed |
| --- | --- | --- |
| 1 | 8 / 8 / 10 / 9 | a `reconnectServer()` from a log callback kept
the old caller's reply context |
| 2 | 8 / 8 / 10 / 9 | a hydrated connect inside another call's scope
handshook as that caller |
| 3 | 9 / 9 / 10 / 9 | none |

Created with Claude Opus 5.5 in T3 Code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## ELI5

When a tool connects to a server, the server may need the caller’s
information to allow the connection. This change sends that information
during the handshake when a tool call opens the connection, without
attaching it to later server messages.

## Changes

- Pass the opening tool call’s `requestContext` to lazy connection
handshakes and reconnect handshakes for tools rebuilt with
`toolsFromDefinitions()` or `toolFromDefinition()`.
- Keep handshakes started by `listTools()` or `listToolDefinitions()`
context-free. Calls without a `requestContext` also pass `null`.
- Keep server messages and requests started by their handlers outside
the opening call’s context. Replies to server requests use the
connection’s context.
- Add HTTP and stdio tests for context propagation, concurrent first
calls, discovery handshakes, streams, server logs, and reconnects.
- Update the custom-fetch documentation and `MastraFetchLike` JSDoc.
Clarify discovery authentication and the `GET` event stream, and add a
patch changeset for `@mastra/mcp`.

## Validation

Test and CI results: not available.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 11:08:49 -05:00
Dane - AI (Mastra)
4bd4b7f48e
chore(deps): update better-auth monorepo to v1.7.18 (#29714)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-11-09 12:39:24 +01:00
dane-ai-mastra[bot]
f21e0742ce chore: version packages 2026-11-07 04:18:11 +00:00
Daniel Lew
a873e2df43
fix(mcp): don't hang OAuth sign-in on the browser's spare callback connections (#29560)
Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
2026-11-05 10:15:44 -08:00
Arthur Fiorette
544224c38f
fix(mcp): read resources expanded from advertised templates (#29493) 2026-11-04 23:29:33 -03:00
Arthur Fiorette
3cf319b5af
fix(mcp): don't resend a tool call whose outcome is unknown (#29492) 2026-11-04 17:37:26 -08:00
Dane - AI (Mastra)
bfe3af4ae1
chore(deps): update better-auth monorepo to v1.7.15 (#29497) 2026-11-04 17:36:58 -08:00
dane-ai-mastra[bot]
675caf0613
chore: version packages (alpha) (#29336)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and publish to npm
yourself or [setup this action to publish
automatically](https://github.com/changesets/action#with-publishing). If
you're not ready to do a release yet, that's fine, whenever you add more
changesets to main, this PR will be updated.

⚠️⚠️⚠️⚠️⚠️⚠️

`main` is currently in **pre mode** so this branch has prereleases
rather than normal releases. If you want to exit prereleases, run
`changeset pre exit` on `main`.

⚠️⚠️⚠️⚠️⚠️⚠️

# Releases

> The changelog information of each package has been omitted from this
message, as the content exceeds the size limit.

## @mastra/client-js@1.60.0-alpha.0


## @mastra/react@1.15.0-alpha.0


## @mastra/factory@0.28.0-alpha.0


## @mastra/code-sdk@1.19.0-alpha.0


## mastra@1.39.0-alpha.0


## @mastra/core@1.83.0-alpha.0


## @mastra/mcp@2.9.0-alpha.0


## @mastra/mcp-apps-components@0.1.0-alpha.0


## @mastra/playground-ui@69.0.0-alpha.0


## @mastra/server@1.83.0-alpha.0


## @mastra/nestjs@0.3.0-alpha.0


## @mastra/clickhouse@1.30.0-alpha.0


## @mastra/duckdb@1.19.0-alpha.0


## @mastra/libsql@1.30.0-alpha.0


## @mastra/pg@1.36.0-alpha.0


## @mastra/temporal@0.6.0-alpha.0


## @mastra/auth-better-auth@1.1.11-alpha.0


## @mastra/deployer-cloud@1.83.0-alpha.0


## @mastra/deployer-cloudflare@1.2.42-alpha.0


## @mastra/deployer-netlify@1.2.42-alpha.0


## @mastra/deployer-sandbox@0.3.27-alpha.0


## @mastra/deployer-vercel@1.2.42-alpha.0


## @mastra/longmemeval@1.1.42-alpha.0


## @mastra/opencode@0.1.42-alpha.0


## create-factory@0.4.3-alpha.0


## mastracode@0.49.1-alpha.0


## @mastra/arize@1.3.30-alpha.0


## @mastra/arthur@0.4.30-alpha.0


## @mastra/braintrust@1.3.27-alpha.0


## @mastra/datadog@1.4.22-alpha.0


## @mastra/deepeval@0.1.24-alpha.0


## @mastra/laminar@1.3.32-alpha.0


## @mastra/langfuse@1.6.6-alpha.0


## @mastra/langsmith@1.4.3-alpha.0


## @mastra/observability@1.23.2-alpha.0


## @mastra/otel-bridge@1.5.22-alpha.0


## @mastra/otel-exporter@1.5.2-alpha.0


## @mastra/posthog@1.4.7-alpha.0


## @mastra/sentry@1.2.32-alpha.0


## @mastra/agent-builder@1.2.1-alpha.0


## @mastra/connect@1.3.2-alpha.0


## create-mastra@1.39.0-alpha.0


## @mastra/deployer@1.83.0-alpha.0


## @mastra/editor@0.17.1-alpha.0


## @mastra/mcp-docs-server@1.3.13-alpha.0


## @mastra/memory@1.41.1-alpha.0


## @mastra/rag@2.7.3-alpha.0


## @mastra/redis-streams@0.8.1-alpha.0


## @mastra/elysia@0.1.23-alpha.0


## @mastra/express@1.5.27-alpha.0


## @mastra/fastify@1.5.27-alpha.0


## @mastra/hono@1.7.25-alpha.0


## @mastra/koa@1.7.27-alpha.0


## @mastra/next@0.2.41-alpha.0


## @mastra/tanstack-start@0.2.41-alpha.0


## @mastra/spanner@1.11.2-alpha.0


## @mastra/turso@0.1.21-alpha.0


## @mastra/inngest@1.11.2-alpha.0


## @mastra/gcs@0.3.6-alpha.0


## @internal/playground@1.39.0-alpha.0

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-11-04 14:40:27 -08:00
Marvin Frachet
944d4bcb13
feat(mcp-apps-components): add prebuilt MCP Apps with a dashboard renderer (#29321)
This adds `@mastra/mcp-apps-components`, a package of prebuilt MCP Apps
you can serve from any `MCPServer`, plus the server and client changes
they need to read data safely as the signed-in user. Each app has its
own entry point (no root barrel). The first one is a dashboard renderer:
a tool returns a dashboard definition and the host renders it as live
observability charts.

```ts
import { MCPServer } from '@mastra/mcp';
import { dashboardRendererApp } from '@mastra/mcp-apps-components/dashboard-renderer';
import { observabilityAppTools } from '@mastra/mcp-apps-components/observability-tools';

new MCPServer({
  id: 'dashboard-mcp-server',
  name: 'Dashboard MCP Server',
  version: '1.0.0',
  appResources: { 'ui://mastra/dashboard': dashboardRendererApp() },
  tools: { showObservabilityDashboard, ...observabilityAppTools },
});
```

## How it works

**The app.** A single self-contained HTML page, inlined into the
package's JS so it survives deployer bundling (Vercel, Netlify,
Cloudflare) with no file reads at runtime. Its iframe never reaches the
network: it reads data with `callServerTool` over the host's existing
MCP connection, so no CSP or `baseUrl` setup is needed. It follows the
host's light/dark theme. Drilldowns continue the conversation when the
host supports `ui/message`; on hosts that also support
`ui/update-model-context`, the app passes the exact filters as
structured context and posts a short prompt, otherwise it spells the
filters out in the message.

**Typed observability tools.** `observabilityAppTools` is 11 app-only
tools, one per read-only observability route the dashboard uses
(trace/span/metric/score aggregates, breakdowns, time series,
percentiles, and score listing). Each takes the route's own input schema
and runs the route in-process through the new `invokeRoute()`.

**`invokeRoute()` (`@mastra/server/server-adapter`).** Runs a JSON
server route in-process as the caller, with the same validation, RBAC
permission and FGA checks its HTTP endpoint applies on every adapter,
and returns `{ status, body }`. It does not re-authenticate: when auth
is configured, the request context must carry the user Mastra server
auth resolved, or the call gets a 401. Non-JSON routes throw, and
HTTP-only handler params (`request`, `registeredTools`, `taskStore`,
`routePrefix`) are not supplied.

**Caller identity in MCP tools.** MCP tools served over HTTP now see the
caller Mastra server auth resolved (user, permissions, roles, resource,
organization) in their `requestContext`, on Hono, Express, Fastify, Koa,
Elysia and NestJS. The server attaches it to the MCP request under a
symbol key, so it can only come from the server, never from
client-supplied auth claims.

**Hiding app-only tools.** `MCPClient.listTools()`/`listToolsets()` hide
tools marked `_meta.ui.visibility: ['app']` from agents.

**Studio host.** Studio advertises the host capabilities it handles
(tool calls, messages, model context), passes its theme, routes app tool
calls to the requested tool in the MCP tool playground, and refuses app
calls to model-only tools. App model context is added to the next user
message only, as a clearly delimited block of untrusted app data, never
as system instructions.

## Try it

`examples/agent` has a `dashboard-agent`. In Studio, try "Show me agent
runs over the last 7 days as a line chart".

## Docs

- New reference page for `invokeRoute()`.
- New "Use prebuilt Mastra apps" section in the MCP connections guide.

## Testing

- `invokeRoute` unit tests (auth, permission, validation, handler
errors, non-JSON routes).
- Shared MCP transport suite case, run on every adapter, checking tools
see the server-resolved user and permissions and unauthenticated calls
get 401.
- `observability-tools` tests through a real Hono server with auth and
RBAC: MCP calls, Studio relay, permission denial, invalid input, and a
bundled-consumer test for the inlined HTML.
- Playground and playground-ui tests for the app viewer and model
context handling.
- Manual Studio run: dashboard renders live data and drilldown sends the
context block with the next message.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## ELI5

This PR adds ready-made MCP apps, including a dashboard that shows
observability data. It also lets Studio display these apps and pass
their context to chat as untrusted user content.

## What changed

- Added `@mastra/mcp-apps-components` with a dashboard renderer and
app-only observability tools. The tools invoke server routes in-process
and use the routes’ validation and authorization checks.
- Added `invokeRoute()` for in-process execution of eligible JSON
routes.
- Updated MCP server adapters to pass trusted, server-resolved caller
identity to MCP tools. MCP client discovery filters app-only tools from
agent-facing listings.
- Updated Studio and the playground to render MCP apps, relay app tool
calls, provide host capabilities, restrict tool calls and links, and
attach app context to the next chat message.
- Added a dashboard agent example and documentation for MCP Apps and
`invokeRoute()`.

## Validation

The author reports tests for route invocation, observability tools, MCP
transports across all six adapters, and playground app and chat
behavior. The author also reports a manual Studio check. These results
were not independently verified.

The author reports that the npm reservation for
`@mastra/mcp-apps-components` remained open and required an npm
organization admin before merge.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
2026-11-04 10:41:58 -08:00
shreyas-mastra
f0ad164646
chore(security): Vanta 2026-11-02 - @hono/node-server 2.1.6 (MCP SDK/templates), graphql-scalars 2.0.1, raw-body 4, jose 6 (overrides) (#29199) 2026-11-04 07:58:48 -08:00
Dane - AI (Mastra)
9ce7e350ea
chore(deps): lock file maintenance (#29341)
Co-authored-by: wardpeet <ward@coding-tech.com>
Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
2026-11-04 15:03:55 +01:00
mastra-platform[bot]
aa6777693d
feat(core): load storage v2 workflow result steps lazily (#29362)
Co-authored-by: Tony Kovanen <rase-@users.noreply.github.com>
2026-11-04 07:32:39 +01:00
mastra-platform[bot]
f9feb98ba3
fix(core,mcp): keep submitted values out of tool validation logs (#29331)
> Opened by @user_01KN2T7F5T2WYEMHY58VJGPZ8R

Fixes #29318

## Problem
When a tool rejects its input, output, suspend data, or resume data, the
validation error message repeats the submitted values (for example
`Provided arguments: {"email": "person@example.com"}`). That's on
purpose, so the model can see what it sent and fix the call. But the
same message was also written to the logs, which put user data such as
email addresses into log output.

## Change
- **Core** (`tools/validation.ts`, `tool-builder/builder.ts`,
`tool.ts`): a new `getValidationIssuePaths()` helper returns the dotted
field paths that failed validation (or `root` for top-level issues).
Validation-failure logs now contain the tool metadata plus `issuePaths`
and no longer include the full message. This covers input, output,
suspend-data, and resume-data validation.
- **MCP** (`server/server.ts`): the "rejected its input" warnings for
plain tools and `run_` workflow tools log `issuePaths` instead of the
message. `MCP_SERVER_TOOL_EXECUTE_FAILED` no longer puts the serialized
`args` into exception details.
- The error returned to the model or MCP caller is the same as before.

## Tests
- `builder.test.ts`: five new tests (input, resume data, suspend data,
AI SDK tool output, Mastra tool output). Each one checks that no logger
call contains the sensitive value and that `issuePaths` is logged. All
five fail without the fix.
- `server-validation-logging.test.ts`: a new MCP end-to-end test over
HTTP. It checks that the caller still gets the validation error and that
server logs only contain `issuePaths`. It fails without the fix.
- Two existing assertions in `validation.test.ts` expected the old
message in the log. They now expect the sanitized form.
- Results: `packages/core` `src/tools` 531 passed, `tsc` clean.
`packages/mcp` `src/server` 565 passed. One stdio events test failed
only when the full suite ran in parallel; it passed when rerun on its
own.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## ELI5

When a tool rejects information, its logs should not repeat the
information people sent. This change logs the tool and the fields that
failed, while keeping errors available to callers.

## Summary

- Updated core validation logs for tool input, output, suspend data, and
resume data. Logs include tool metadata and failing field paths instead
of validation messages that may contain submitted values.
- Added the public `getValidationIssuePaths` helper. It returns dotted
paths, uses `root` for top-level errors, and masks undeclared property
names.
- Updated MCP server validation logs to report failing field paths. MCP
tool-execution failure details no longer include serialized arguments.
- Updated MCP client logs to omit submitted arguments, server error
text, and full error messages or stacks. Output-validation logs report
issue paths. Other error logs use `errorKind`, which filters error names
and codes.
- Sanitized tracked exceptions for remote MCP tool and task failures.
Caller-facing errors remain available.
- Added core and MCP logging tests.
- Raised the minimum `@mastra/core` peer version to `1.82.0-0` for
`@mastra/mcp`, `@mastra/connect`, and `@mastra/code-sdk`.

## Test results

The PR reports 531 passing core tool tests and a clean TypeScript check.
It reports 565 passing MCP server tests. One stdio events test failed in
a parallel full-suite run, then passed when rerun alone.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: mastra-platform[bot] <mastra-platform[bot]@users.noreply.github.com>
Co-authored-by: mastra-platform[bot] <284800079+mastra-platform[bot]@users.noreply.github.com>
2026-11-04 01:59:48 +00:00
dane-ai-mastra[bot]
6e8dfcb83f chore: version - exit prerelease mode 2026-11-03 23:45:58 +00:00
dane-ai-mastra[bot]
4bc3aa672f
chore: version packages (alpha) (#29255)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and publish to npm
yourself or [setup this action to publish
automatically](https://github.com/changesets/action#with-publishing). If
you're not ready to do a release yet, that's fine, whenever you add more
changesets to main, this PR will be updated.

⚠️⚠️⚠️⚠️⚠️⚠️

`main` is currently in **pre mode** so this branch has prereleases
rather than normal releases. If you want to exit prereleases, run
`changeset pre exit` on `main`.

⚠️⚠️⚠️⚠️⚠️⚠️

# Releases

> The changelog information of each package has been omitted from this
message, as the content exceeds the size limit.

## @mastra/factory@0.27.0-alpha.3


## @mastra/agent-builder@1.2.0-alpha.3


## @mastra/core@1.82.0-alpha.3


## @mastra/mcp@2.8.0-alpha.2


## @mastra/memory@1.41.0-alpha.3


## @mastra/playground-ui@68.0.0-alpha.3


## @mastra/ring-signals@0.1.0-alpha.0


## @mastra/libsql@1.29.0-alpha.2


## @mastra/mongodb@1.26.0-alpha.2


## @mastra/mysql@0.16.0-alpha.3


## @mastra/pg@1.35.0-alpha.3


## @mastra/discord@1.3.3-alpha.0


## @mastra/slack@1.8.1-alpha.0


## @mastra/teams@0.1.4-alpha.0


## @mastra/telegram@0.2.5-alpha.0


## @mastra/client-js@1.59.0-alpha.3


## @mastra/react@1.14.1-alpha.3


## @mastra/deployer-cloud@1.82.0-alpha.3


## @mastra/longmemeval@1.1.41-alpha.3


## @mastra/opencode@0.1.41-alpha.3


## create-factory@0.4.2-alpha.3


## @mastra/code-sdk@1.18.0-alpha.3


## mastracode@0.49.0-alpha.3


## @mastra/arize@1.3.29-alpha.2


## @mastra/arthur@0.4.29-alpha.2


## @mastra/laminar@1.3.31-alpha.2


## @mastra/langfuse@1.6.5-alpha.2


## @mastra/otel-bridge@1.5.21-alpha.2


## @mastra/otel-exporter@1.5.1-alpha.2


## @mastra/sentry@1.2.31-alpha.3


## mastra@1.38.0-alpha.3


## @mastra/connect@1.3.1-alpha.1


## @mastra/deployer@1.82.0-alpha.3


## @mastra/editor@0.17.0-alpha.3


## @mastra/evals@1.10.11-alpha.0


## @mastra/mcp-docs-server@1.3.12-alpha.4


## @mastra/server@1.82.0-alpha.3


## @mastra/elysia@0.1.22-alpha.3


## @mastra/express@1.5.26-alpha.3


## @mastra/fastify@1.5.26-alpha.3


## @mastra/hono@1.7.24-alpha.3


## @mastra/koa@1.7.26-alpha.3


## @mastra/nestjs@0.2.41-alpha.3


## @mastra/next@0.2.40-alpha.3


## @mastra/tanstack-start@0.2.40-alpha.3


## @mastra/turso@0.1.20-alpha.2


## @mastra/inngest@1.11.1-alpha.2


## @mastra/temporal@0.5.0-alpha.3


## create-mastra@1.38.0-alpha.3


## @internal/playground@1.38.0-alpha.3

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-11-03 13:59:38 -07:00
mastra-platform[bot]
3015ac82d0
feat(mcp): let MCPServer return images, audio and files from tools via toModelOutput (#29247)
Co-authored-by: Arthur Fiorette <47537704+arthurfiorette@users.noreply.github.com>
2026-11-03 11:52:33 -08:00
Daniel Lew
e6b6811a95
feat(mcp,playground-ui): answer MCP task input requests from the agent chat (#29032)
Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
2026-11-03 11:27:04 -08:00
Dane - AI (Mastra)
47a6cd82e5
chore(deps): update ai sdk (#29242)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-11-03 16:12:54 +01:00
dane-ai-mastra[bot]
886679eb10
chore: version packages (alpha) (#29205)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and publish to npm
yourself or [setup this action to publish
automatically](https://github.com/changesets/action#with-publishing). If
you're not ready to do a release yet, that's fine, whenever you add more
changesets to main, this PR will be updated.

⚠️⚠️⚠️⚠️⚠️⚠️

`main` is currently in **pre mode** so this branch has prereleases
rather than normal releases. If you want to exit prereleases, run
`changeset pre exit` on `main`.

⚠️⚠️⚠️⚠️⚠️⚠️

# Releases

> The changelog information of each package has been omitted from this
message, as the content exceeds the size limit.

## @mastra/client-js@1.59.0-alpha.2


## @mastra/factory@0.27.0-alpha.2


## @mastra/code-sdk@1.18.0-alpha.2


## mastra@1.38.0-alpha.2


## @mastra/core@1.82.0-alpha.2


## @mastra/editor@0.17.0-alpha.2


## @mastra/server@1.82.0-alpha.2


## @mastra/clickhouse@1.29.0-alpha.1


## @mastra/duckdb@1.18.0-alpha.1


## @mastra/pg@1.35.0-alpha.2


## @mastra/platform-workspace@1.12.0-alpha.1


## @mastra/react@1.14.1-alpha.2


## @mastra/deployer-cloud@1.82.0-alpha.2


## @mastra/deployer-sandbox@0.3.26-alpha.1


## @mastra/longmemeval@1.1.41-alpha.2


## @mastra/opencode@0.1.41-alpha.2


## @mastra/parallel@0.1.5-alpha.0


## create-factory@0.4.2-alpha.2


## mastracode@0.49.0-alpha.2


## @mastra/arize@1.3.29-alpha.1


## @mastra/arthur@0.4.29-alpha.1


## @mastra/braintrust@1.3.26-alpha.1


## @mastra/datadog@1.4.21-alpha.1


## @mastra/deepeval@0.1.23-alpha.1


## @mastra/laminar@1.3.31-alpha.1


## @mastra/langfuse@1.6.5-alpha.1


## @mastra/langsmith@1.4.2-alpha.1


## @mastra/observability@1.23.1-alpha.1


## @mastra/otel-bridge@1.5.21-alpha.1


## @mastra/otel-exporter@1.5.1-alpha.1


## @mastra/posthog@1.4.6-alpha.1


## @mastra/sentry@1.2.31-alpha.2


## @mastra/agent-builder@1.1.33-alpha.2


## @mastra/deployer@1.82.0-alpha.2


## @mastra/mcp@2.8.0-alpha.1


## @mastra/mcp-docs-server@1.3.12-alpha.3


## @mastra/memory@1.41.0-alpha.2


## @mastra/playground-ui@68.0.0-alpha.2


## @mastra/rag@2.7.2-alpha.0


## @mastra/elysia@0.1.22-alpha.2


## @mastra/express@1.5.26-alpha.2


## @mastra/fastify@1.5.26-alpha.2


## @mastra/hono@1.7.24-alpha.2


## @mastra/koa@1.7.26-alpha.2


## @mastra/nestjs@0.2.41-alpha.2


## @mastra/next@0.2.40-alpha.2


## @mastra/tanstack-start@0.2.40-alpha.2


## @mastra/dsql@1.5.6-alpha.0


## @mastra/libsql@1.29.0-alpha.1


## @mastra/mongodb@1.26.0-alpha.1


## @mastra/mssql@1.11.1-alpha.0


## @mastra/mysql@0.16.0-alpha.2


## @mastra/oracledb@0.5.6-alpha.0


## @mastra/spanner@1.11.1-alpha.0


## @mastra/turso@0.1.20-alpha.1


## @mastra/voice-google@0.14.5-alpha.0


## @mastra/inngest@1.11.1-alpha.1


## @mastra/temporal@0.5.0-alpha.2


## @mastra/e2b@0.16.1-alpha.1


## create-mastra@1.38.0-alpha.2


## @internal/playground@1.38.0-alpha.2

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-11-02 20:29:47 -07:00
Arthur Fiorette
96b1bfbf50
fix(mcp): reject calls to unknown tools with a JSON-RPC protocol error (#29204) 2026-11-02 08:34:50 -08:00
dane-ai-mastra[bot]
eed9cc214e chore: version packages 2026-11-01 04:20:58 +00:00
Dane - AI (Mastra)
a69d91af24
chore(deps): update security updates [security] (#28883) 2026-10-31 11:41:36 -07:00
Arthur Fiorette
8bea9662c5
fix(mcp): authorize hosted MCP tool calls once, against the server's resource (#29077) 2026-10-31 11:36:02 -07:00
mastra-platform[bot]
eddb0605db
fix(mcp, mastracode): report each MCP server as it settles so one stalled server can't block the others (#29028)
> Opened by @abhiaiyer91

Fixes #29004

## Summary
Mastra Code discovers MCP tools through one shared `MCPClient`, and it
didn't set any server's status until the combined
`listToolsetsWithErrors()` call returned. That call waits for every
server, and requests have a 7-day timeout. So one server that never
finished its handshake left **every** server on "connecting...", and
reconnecting a healthy server had to wait for the stalled one.

The fix is in two parts.

**`@mastra/mcp` (minor)**
- **`onServerSettled` option:** `listToolsWithErrors()`,
`listToolsetsWithErrors()` and `listToolDefinitionsWithErrors()` accept
an `onServerSettled(serverName, { value | error, duration })` callback.
It fires for each server as soon as that server succeeds, fails or hits
`perServerTimeoutMs`, before the aggregate call resolves. If the
callback throws or its promise rejects, the error is logged and
discovery carries on. A rejected callback never becomes an unhandled
rejection.
- **`serverNames` option:** the discovery calls accept an optional
`serverNames` list, so a caller can discover only the servers it needs.
Mastra Code uses it to retry just the servers that timed out, and to
refresh the tools of just the server being reconnected.
- **Timeout error code:** a discovery timeout now has `code:
MCP_DISCOVERY_TIMEOUT_CODE` (exported), so callers can tell a slow
server from a failed one.
- **Stalled connects are torn down (patch):** if a stdio server never
answered its handshake, `disconnect()` could hang behind a pending
`reconnectServer()`, and the server process was left running. Two
causes: the SDK's version-negotiation probe child is never attached as
the client transport, and a failed attempt could drop a client that a
newer attempt still owned. Now an in-flight connect is tracked and
closed by `disconnect()` and `reconnectServer()`, attempts from an older
lifecycle generation stop, and a failed attempt can't remove a client a
newer attempt is still using.
- Docs: `onServerSettled` and `serverNames` are added to the `MCPClient`
reference, including a retry example that only rediscovers the servers
that timed out.

**`@mastra/code-sdk` (patch)**
- **Single client:** the manager still uses one `MCPClient`. It passes
`perServerTimeoutMs` (60s by default, configurable via
`createMcpManager(..., { discoveryTimeoutMs })`) and sets each server's
status and tools from `onServerSettled`. Healthy servers show as
connected as soon as they're ready.
- **Late servers:** a server that times out shows as failed. If it
finishes later (for example a cold `npx` install), it switches to
connected and its tools are registered. Tools are resolved per agent
request, so they're available from the next turn.
- **Attempt guard:** per-server attempt tokens drop results from a
superseded attempt, a reload, a disabled server or a disconnected
manager.
- **Reconnect:** a reconnect from `/mcp` calls
`client.reconnectServer(name)` and returns once *that* server settles.
It shares one 60s deadline across reconnect and tool listing, and
doesn't wait for other servers.
- **Exact tool removal:** a server's previous tools are removed by the
exact tool names that server reported, not by a `${name}_` prefix. A
server named `foo` no longer deletes `foo_bar_ping` from the unrelated
server `foo_bar`.
- **Scoped rediscovery:** the late retry for timed-out servers
rediscovers only those servers, and a reconnect refreshes only the
server being reconnected. A server that failed on start is no longer
relaunched (and no longer re-prompts for auth) every time a sibling
times out or is reconnected.
- **Stable tool order:** `getTools()` returns tools in server config
order, whatever order servers settle in, so the tool list sent to the
model doesn't change between runs.

## Test plan
- `packages/mcp/src/client/discovery-settled.test.ts` (real stdio
processes): the callback fires for the healthy server while the stalled
one is still pending, and the aggregate call is still waiting. A
throwing callback doesn't break discovery.
- `packages/mcp/src/client/discovery-settled.test.ts`: an `async`
callback that rejects doesn't break discovery and doesn't raise an
unhandled rejection.
- `packages/mcp/src/client/stalled-connect.test.ts` (real stdio, pid
files):
  - `disconnect()` kills the stalled child of a timed-out discovery.
- `disconnect()` resolves promptly while a reconnect to a stalled server
is pending.
- A new connection works after a disconnect that cut a reconnect short.
  - Each test checks that no child process is left.
- `mastracode/sdk/src/mcp/__tests__/manager-stalled-server.test.ts`
(real `@mastra/mcp` client and stdio fixtures; HOME, app data and
CODEX_HOME isolated). 8 tests:
- The healthy server is connected while the stalled one is still
`connecting`.
  - The stalled server fails with a timeout error.
  - A slow server that finishes after the timeout switches to connected.
  - Reconnecting a healthy server while another is stalled.
- A stalled reconnect is bounded by one 1s deadline (under 1.9s total),
and `disconnect()` then takes under 3s with no child left.
- Reconnecting while the timed-out startup attempt is still finishing
never shows a failure.
  - A late discovery doesn't re-add tools after the server is disabled.
- A server that failed on start is not relaunched when a sibling times
out or is reconnected.
- `manager.test.ts`: tools come back in config order when a later server
settles first, a reconnect asks the client to discover only that server
(`serverNames: ['fs']`), and a server whose name starts with another
server name keeps its own tools.
- `packages/mcp/src/client/discovery-settled.test.ts`: discovery can be
scoped to a list of server names, and the other servers are not touched.
- `manager-stalled-server.test.ts`: a server that failed on start is not
relaunched when a sibling times out or is reconnected.
- `manager.test.ts` is back to single-client assertions. Its
`@mastra/mcp` mock emulates `onServerSettled` from each test's aggregate
result.
- `@mastra/mcp`: `vitest run` gives 1448 passed, 6 skipped (78 files).
`@mastra/code-sdk`: `vitest run src/mcp` gives 145/145. ACP conformance
(`test:acp:conformance`, built SDK) passes in all three shutdown modes.
`tsc --noEmit`, oxlint and oxfmt are clean, and the MDX lint passes.
- The `onServerSettled` option type stays `(serverName, result) =>
void`. An `async` callback is assignable to that type, so async
callbacks are supported without widening the type to `void |
Promise<void>` — that union rejects any callback that returns a value
and broke `tsc --noEmit` in `mastracode/sdk`. The implementation still
observes the callback's return value at runtime and logs a rejected
promise instead of leaving it unhandled.

## Proof
**Revert checks**
- `configuration.ts` without `onServerSettled`: both discovery-settled
tests fail (`expected [] to include 'healthy'`).
- `client.ts` and `handleConnectError` back to main: all 3
stalled-connect tests fail. The first leaves a live child; the other two
hang to the 20s test timeout.
- `manager.ts` from main (`b0e86c50`), with the fixed `@mastra/mcp`: 6
of the 7 manager tests that existed before the `serverNames` change
fail, and the new no-respawn test fails on main too (8 spawns instead of
4). The healthy server never reports connected, which is the #29004
symptom. The disable test passes on main because main has no
late-discovery path at all.
- `getTools()` back to insertion order: the config-order test fails
(`remote_context` first), and ACP conformance fails `follow-up turn and
client MCP subprocess cwd/environment`, the same failure as the CI
Mastra Code E2E job on `04378d98`. Its mocked model calls the first tool
whose name contains `context`, and that was the HTTP probe's tool.
- Fixed `manager.ts` with the attempt guard forced to `true`: the
disable test fails 3/3, because the late result marks the disabled
server connected.
- The exact-tool removal reverted to the `${name}_` prefix: the
prefix-sharing test fails, because `foo` settling drops `foo_bar_ping`
while `foo_bar`'s status still says connected.
- The `serverNames` filter reverted: the failing-server test fails. The
server that failed on start is spawned 8 times instead of 4, because
each sibling timeout and each reconnect relaunches it.
- The async-callback rejection handler removed: the new async-callback
test fails, because the rejection escapes as an unhandled rejection.
- The `onServerSettled` type widened back to `void | Promise<void>`:
`tsc --noEmit` in `mastracode/sdk` fails with TS2322 at
`manager.ts:553`, because the callback returns `record(...)`'s value.

**Real servers (Linux sandbox, real manager via `tsx`, status changes
logged with timestamps)**
- `everything`: `npx -y @modelcontextprotocol/server-everything` with an
empty npm cache
- `stalled`: a stdio process that reads stdin and never replies
- `remote-stalled`: `npx -y mcp-remote http://127.0.0.1:<port>/mcp
--allow-http`, cold cache, pointed at an HTTP server that never responds

| Scenario | `everything` | `stalled` / `remote-stalled` | `init()` |
`disconnect()` |
|---|---|---|---|---|
| Pre-fix `manager.ts` (`b0e86c50`), 80s | still `connecting` | still
`connecting` | never settled | n/a |
| This PR, 60s cap | connected (13 tools) at 11.5s | failed (timeout) at
60.7s | settled at 60.6s | 161ms, no child left |
| This PR, 5s cap (forces a late connect) | failed at 5.7s, then
connected (13 tools) at 12.6s | failed (timeout) at 5.7s | settled at
5.7s | 160ms, no child left |

## Unverified
- **Reconnect-while-starting guard:** the test passes even with the
guard removed. With one shared client, the abandoned startup attempt
joins the reconnect's connection and also ends up connected, so the
stale-write order can't be forced reliably. The guard is proven by the
disable test.
- **fal-ai, figma-console and devrev:** not run, because they need
credentials. The `mcp-remote` dead-endpoint run stands in for devrev's
stall.
- **TUI:** not driven. `/mcp` reads `getServerStatuses()`, which is what
the real-server runs recorded.
- **macOS and Windows:** the sandbox is Linux-only, and no CI workflow
uses macOS or Windows runners.
- **CI "Affected UNIT Test":** the only failing test in that job is
`packages/connect/src/__tests__/channels.test.ts:473` — a 5s timeout on
the first cold import of the real `@mastra/discord`, which takes ~4.6s
under runner load. It passes in isolation on this head, the rest of the
file's MCP-free import graph never reaches `@mastra/mcp`, and another
test in the same file fails on `main` in this sandbox. Everything else
in the job is green: 16143 passed, 15 skipped, no type errors.

## Risk: medium
This changes connect, reconnect and disconnect lifecycle code in
`@mastra/mcp`, which every `MCPClient` user goes through, not just
Mastra Code. The new option is additive, and the full `@mastra/mcp`
suite passes. One visible change: `disconnect()` during a stalled
connect now logs that connect's abandonment as an
`MCP_CLIENT_CONNECT_FAILED` error. A manual reconnect that takes longer
than 60s shows as failed until it finishes or is retried.



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## ELI5

When one MCP server gets stuck, Mastra Code can still show tools from
the servers that connected successfully. A stuck server gets its own
timeout, and it can still connect later if its attempt is still current.

## Summary

- `@mastra/mcp` adds `onServerSettled` to tool, toolset, and
tool-definition discovery. The callback reports each server’s result and
discovery duration. Callback errors are logged and ignored.
- Discovery timeouts use the exported `MCP_DISCOVERY_TIMEOUT_CODE`. The
new `serverNames` option limits discovery to selected configured
servers.
- MCP client lifecycle handling stops stalled connection attempts during
disconnect or reconnect and prevents superseded attempts from changing
current state.
- Mastra Code keeps one shared `MCPClient` and updates each server’s
status and tools as discovery settles. Its per-server discovery timeout
defaults to 60 seconds and can be configured with `discoveryTimeoutMs`.
- A timed-out server can connect later and register its tools if its
attempt is still current. Attempt checks prevent stale results from
overriding newer attempts or affecting disabled servers and disconnected
managers.
- Reconnecting from `/mcp` waits only for the selected server, with one
timeout covering reconnect and tool listing. Tool order follows server
configuration order.
- The MCP client reference documents the discovery callback and server
selection option.

## Validation

The author reports 1,445 tests passed and 6 skipped in the `@mastra/mcp`
suite, and 143/143 passed for `@mastra/code-sdk`’s `vitest run src/mcp`.
The author also reports passing ACP conformance in all three shutdown
modes.

The author reports that macOS and Windows were not tested, the TUI was
not driven, and credential-dependent fal-ai, figma-console, and devrev
servers were not run.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: mastra-platform[bot] <284800079+mastra-platform[bot]@users.noreply.github.com>
2026-10-30 16:45:37 -07:00
dane-ai-mastra[bot]
77076a1012 chore: version - exit prerelease mode 2026-10-30 23:02:25 +00:00
dane-ai-mastra[bot]
582ef17a2b
chore: version packages (alpha) (#28888)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-10-30 14:56:53 -07:00
Daniel Lew
80f2f21133
feat: show MCP tasks in Studio (server Tasks panel and tool-call task chip) (#28629)
> **Targets `main`.** #28343, #28521, and #28619, which this builds on,
are merged, so the diff shows only the Studio work.

## What this adds

MCP servers with `tasks` enabled run some tool calls (and, with the
workflows/agents PR, `run_<workflow>` / `ask_<agent>` calls) as
long-running MCP tasks. Until now Studio showed nothing about them: the
server page didn't say which tools run as tasks or list any tasks, and a
chat tool-call card for a task-backed tool showed only the final result,
with no task id, status or running time.

**Server page (`/mcps/:serverId`)**
- Tools list gets a **Task** column: `always` / `auto`, `required` when
clients without task support are refused for that tool, and `recover`
when the call is retried after a restart.
- New **Tasks** panel: surface, status, created, updated, expiry, open
input requests, a short task key and the **client** that sent the task.
It refreshes every 2s while any task is still running.
- Filter by status, surface or client (filters live in the URL).
Clicking a client in a row filters to that client, so you can see which
client's tasks keep failing.
  - Shows 50 tasks at a time with **Load more** for older ones.
- **Find by MCP task id**: paste the id a client shows (e.g. from the
chat chip) to open that task.
- Opening a task shows its metadata and result or error. You can answer
an `elicitation/create` request with a form built from its
`requestedSchema`: Accept is the primary action, Decline the secondary
one. Cancel task is a quieter red action below the form. Other input
methods are shown read-only.

**Chat tool-call card**
- A chip `task · working · 0:42` → `completed` / `failed` / `cancelled`,
with a button that copies the **MCP** task id. The Mastra
background-task id is a different id.

## How it's built

The layering is the same as the MCP events Studio PR: core contract →
`@mastra/mcp` → `@mastra/server` → `@mastra/client-js` → Studio.

- **`@mastra/core`**: experimental, optional `getTasksInfo()` /
`getTasksInspector()` on `MCPServer`, the same pattern as
`getEventsInfo` / `getEventsInspector`. Each task surface reports its
own `mode`, `required`, `recover` and `ttlMs`. Nothing new goes into
`tools/list` or onto the wire.
- **`@mastra/mcp`**: the protocol store still can't list tasks. A
separate optional `MCPTaskStoreAdmin` (`list`, `updateByKey`,
`cancelByKey`) is keyed by the stored task key, which is a hash of the
task id. `get/update/cancel` now go through the same key-based paths, so
Studio's cancel and answer run the exact code that `tasks/cancel` and
`tasks/update` run, with the same fencing and persist-before-ack. The
in-memory and background-task stores implement it. Custom stores that
don't implement it get "this store can't be listed". The MCP client
writes an `mcp-task` progress entry (`MCPTaskProgress`) to the tool's
output stream when the task is created and on each status change.
- **`@mastra/server`**:
- `GET /mcp/:serverId/tasks`: newest first, `limit` 50 by default and at
most 200; filters `status`, `surface`, `client` (the hashed client key)
and `key`; returns `nextCursor` for the next page. The background-task
store pushes surface, client and key into its query; status is checked
after reading, because an expired running row reads as failed.
- `POST /mcp/:serverId/tasks/find`: body `{ taskId }`, hashed on the
server, so raw ids never land in URLs or access logs
  - `POST /mcp/:serverId/tasks/:taskKey/cancel`
  - `POST /mcp/:serverId/tasks/:taskKey/input`
  - `tasks_capability` on server list/detail.
- **`@mastra/client-js`**: `getMcpServerTasks` (filters + cursor),
`findMcpServerTask`, `cancelMcpServerTask`, `answerMcpServerTaskInput`.

### Access and privacy
- Responses carry hashed task keys, hashed caller keys and, since #28521
(`ebcfb2bbe96`), the caller's `clientLabel`: client id plus token
subject or user id, or plus a short prefix of the token's hash for
token-only callers. The label is never a credential and is never used to
authorize. Raw task ids and tokens never reach Studio. The client filter
matches the hashed key, not the label. Tasks stored before labels
existed show a short form of the key.
- Only operators see this view: the routes need Mastra auth,
resource-scoped sessions get nothing, and MCP itself has no list method.
- **Permissions:** listing and finding tasks need `mcp:read` (same model
as `/background-tasks`). Cancelling and answering need `mcp:write`,
because they act on another client's task. With the default roles,
`admin` can act on tasks, while `member` and `viewer` can only see them.
Studio hides Cancel, Accept and Decline for users without `mcp:write`
and says why.
- Since #28521 (`19dbb7732b0`), task rows store only a hash of the
caller's principal, so neither the store nor `/background-tasks` holds
the raw principal.
- **Resource-scoped Studio sessions fail closed.** They get no list and
a 404 on cancel/answer, because Mastra resource ids and MCP principals
have no defined mapping. Only unscoped sessions see a server's tasks.
- Unknown or expired keys return 404.

### Known limits
- **The chip's task id is live-only.** Progress isn't saved with the
thread, so a reloaded thread shows only the final result.
- **Deferred calls:**
- Background-task progress and completion chunks don't reach the
tool-call card after the chat turn ends.
- The server-side SSE has them, but the thread stream never delivers
them to the browser. This looks like an existing stream/association gap
and isn't fixed here.
- The chip works around it: until progress shows the task ended, it
polls `GET /background-tasks/:id` to learn how the task ended.
- The agent still quotes the Mastra background-task id in its reply.
Changing what the model is told is out of scope.
- Answering client-side `inputRequests` from chat is out of scope.

## Test plan
- `@mastra/mcp`:
- admin contract suite against both stores: list, filters (status,
surface, client, key), cursor paging over every task exactly once,
idempotent cancel/answer, cross-principal, raw id rejected;
- inspector `find` by raw id (a task key or unknown id finds nothing)
and `clientLabel` on listed tasks for both stores;
- the background store fills a full page even when newer rows can't be
read as tasks;
- `getTasksInfo` / `getTasksInspector` on `MCPServer`, checking that
`tools/list` doesn't change;
  - client `onStatus` and progress writes.
- All existing 3c task tests are green before and after the `*ByKey`
refactor.
- `@mastra/server`: handler tests for `tasks_capability`, unscoped list,
default limit and `nextCursor`, filters and cursor passed to the store,
unknown status rejected, limit cap, `clientLabel` kept, find by raw id
(id only in the body, 404 for unknown/scoped/not listable), scoped
callers failing closed (an empty-string resource id is also treated as
scoped), not-listable stores, and 404s. A mutation check confirmed the
scoping tests fail without the guard.
- `@mastra/client-js`: request shapes, including key URL-encoding,
filter/cursor query and the find body.
- Studio:
- MSW tests for the Tasks panel (every status, empty, not listable,
resource scoped, live refresh, cancel, answer form, Load more, URL
status filter, click-a-client filter showing its label, no-match state,
find by id (opens the task / says not found), drawer client label, tool
Task column with `required` per tool);
- chip tests (live progress, terminal states, polling the background
task for deferred calls, `readToolPart`).
  - Mutation checks confirmed the key tests fail without the change.
- Manual, in the showcase app:
- answering an elicitation and cancelling from the drawer both drive the
task to its end state;
- the chip goes from `working` to `completed · 0:12` on a live deferred
`slow_report`.
- Lint passes for every touched package, and typecheck passes for core,
mcp, client-js, playground-ui and playground. `@mastra/server` typecheck
shows only an existing `@mastra/agent-builder` resolution error.

## Screenshots

**Before: server page, no task information**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-before-server-mcp.png"
alt="Before: server page, no task information" width="720">

**Before: tool card shows only the result**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-before-client-slow-report-completed.png"
alt="Before: tool card shows only the result" width="720">

**After: Task column per surface (`required` only on `gated`)**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-server-tools.png"
alt="After: Task column per surface (`required` only on `gated`)"
width="720">

**After: Tasks panel with filters, find box and Client column**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-server-tasks.png"
alt="After: Tasks panel with filters, find box and Client column"
width="720">

**After: filtered to failed tasks from one client**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-server-tasks-failing-client.png"
alt="After: filtered to failed tasks from one client" width="720">

**After: Load more under the first 50 tasks**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-server-tasks-load-more.png"
alt="After: Load more under the first 50 tasks" width="720">

**After: a pasted task id opens its task**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-server-tasks-find.png"
alt="After: a pasted task id opens its task" width="720">

**After: drawer, working**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-drawer-working.png"
alt="After: drawer, working" width="720">

**After: drawer, input required**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-drawer-input-required.png"
alt="After: drawer, input required" width="720">

**After: answering an elicitation from Studio**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-drawer-answer-form.png"
alt="After: answering an elicitation from Studio" width="720">

**After: answered**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-drawer-answered.png"
alt="After: answered" width="720">

**After: drawer, completed**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-drawer-completed.png"
alt="After: drawer, completed" width="720">

**After: drawer, failed**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-drawer-failed.png"
alt="After: drawer, failed" width="720">

**After: cancelled from Studio**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-drawer-cancelled-from-studio.png"
alt="After: cancelled from Studio" width="720">

**After: chat chip while the task runs**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-client-slow-report-running.png"
alt="After: chat chip while the task runs" width="720">

**After: chat chip when it completes**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-client-slow-report-completed.png"
alt="After: chat chip when it completes" width="720">

**After: chat chip for a failed task**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-client-expiring-failed.png"
alt="After: chat chip for a failed task" width="720">

<details><summary>Tablet (768px) and phone (390px)</summary>

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-server-tools-768.png"
alt="tools-768" width="720">

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-server-tasks-768.png"
alt="tasks-768" width="720">

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-server-tools-390.png"
alt="tools-390" width="720">

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-server-tasks-390.png"
alt="tasks-390" width="720">

</details>





<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## ELI5

Studio can now show tasks that run through MCP servers and their status.
Users with the right access can answer task requests or cancel tasks.
Chat tool calls can also show task progress.

## Summary

- Added MCP task listing and lookup in Studio, with status, surface, and
client filters, pagination, and lookup by MCP task ID.
- Added task details with status, timestamps, results or errors, and
supported input requests. Users with `mcp:write` can answer requests or
cancel tasks.
- Required `mcp:read` for listing and lookup. Resource-scoped sessions
cannot inspect tasks. Custom task stores need the `MCPTaskStoreAdmin`
interface to support listing.
- Added task capability metadata to MCP server responses and task-mode
metadata to the tools list.
- Added task progress updates and a chat chip that shows task status and
elapsed time, with a button to copy the MCP task ID. For deferred tool
calls, the chip polls the background-task endpoint for status updates.
- Added MCP task methods to `MastraClient` and experimental task types
and inspector hooks in core.

## Validation

The PR description reports tests for task stores, server routes, client
requests, and Studio behavior. It also reports lint checks and
typechecks for several packages. The `@mastra/server` typecheck reports
an existing `@mastra/agent-builder` resolution error. The PR description
reports manual checks for task answering, cancellation, and
deferred-task completion.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
2026-10-30 09:31:21 -04:00
Daniel Lew
ea26a4b1cc
feat(mcp): serve workflows and agents as MCP tasks (#28619)
Lets an `MCPServer` serve its workflows (`run_<workflow>`) and agents
(`ask_<agent>`) as MCP tasks (SEP-2663, experimental), with the same
modes as tools. Before this, `tasks.workflows` and `tasks.agents` threw
"not supported yet", and those tools could only answer synchronously.

Stacked on #28521 (← #28420 ← #28340). It also carries the core stack
#28425 → #28507 → #28590 until those merge. `@mastra/mcp` only, no core
changes.

```ts
const server = new MCPServer({
  id: 'reports',
  name: 'Reports',
  version: '1.0.0',
  workflows: { nightly },
  agents: { researcher },
  tasks: {
    workflows: { nightly: 'always' },
    agents: { researcher: { mode: 'auto', syncWindowMs: 1000 } },
  },
});
```

**Workflows.** A workflow task follows a single run. The run starts
once, under the `tools/call` that creates the task, with a fresh `runId`
that is never the task id. After that, a task attempt never starts a
run. It can only:
- re-attach by polling `getWorkflowRunById`,
- resume on a `tasks/update`, where core's `suspended → running` claim
allows one resume per suspension (if the claim is lost, the attempt
follows whoever resumed the run instead),
- or cancel the run.

When a step suspends, the task moves to `input_required` with a form
built from the step's `resumeSchema` (nested workflows are walked too).
If the schema can't be shown as a form, the task stays `working` and
follows a resume made from Studio or the API.

If a server dies mid-run, core's boot sweep (`recovery.workflows:
'auto'`) continues the run on the next instance, and the task
re-attaches to it there. A server that shuts down gracefully, or loses
the task's lease to another worker, only stops following the run: it
never cancels it.

An answer to a suspension that was already resumed elsewhere (Studio,
the API) is dropped: the task checks the step and its `suspendedAt`
before resuming, and on a refused resume, then follows the run and asks
again.

A run that ends `failed`, `tripwire` or `canceled` completes the task
with `isError`. A task ends `failed` only on infra problems: a lost run,
TTL expiry, or a store error.

**Cancelling.** Both task stores get an optional, fire-and-forget
`onCancel(context)` hook, called on `tasks/cancel` and on TTL expiry,
even while no attempt runs (a task waiting for input). MCPServer uses it
to cancel the run: a run executing in this process is stopped here, a
run waiting is cancelled in storage, and a run executing on another
instance is left to that instance (writing `canceled` under it would
only be overwritten). Core aborts that instance's attempt once its row
reads cancelled (#28523); the background store then re-reads the row
and, if it was cancelled or expired, calls `onCancel` there too, so the
run stops where it executes. Aborting an attempt for any other reason
(shutdown, lost lease) never cancels the run. With a custom
`tasks.store`, the docs say how to cancel the run from the exported
`WorkflowTaskContext`.

**Agents.** Agent tasks reuse the tool-task path: `abortSignal` cancels
the run, a throw ends the task as `isError`, and `recover` applies. If
an agent pauses for tool approval, the task completes with an `isError`
message for now. Agent approval inside tasks is a follow-up.

**Config.** `tasks.default` now also covers workflows and agents that
aren't listed. `tasks.required` takes the names clients call, such as
`run_nightly`. Unknown keys still throw at construction.

**Tracing.** Each workflow or agent task is one trace, like a tool task.
Attempts are `task attempt run_<key> #n` / `ask_<key> #n` spans under
the `tools/call` root. A workflow run starts under attempt #1 (or under
the root in `'auto'`), and each run resumed after `tasks/update` sits
under the attempt that resumed it, on whichever instance answers. An
agent's `agent run` sits under its attempt. A run that Mastra's workflow
recovery restarts after a crash starts a trace of its own: that's by
design, since durable workflows and agents cover tracing across a crash.
The task's attempt that follows the restarted run stays in the task's
trace.

**Behaviour difference to note.** A synchronous `run_` call (mode
`'off'`, or a client without the extension) still answers a failed run
without `isError`. In task mode, and in `'auto'` when the run finishes
inside the window, a failed run answers with `isError`, per S9.

**The run id lives in the row's `args.context`, not `metadata`.**
`workFor` reads `args.context`, so the run id sits there with the rest
of the work's context instead of in `metadata`.

**Known limitations**
- Same step suspending again in a loop: if a resume from outside MCP
lands between the task's check and its own `resume()`, a stale answer
can resume the step's *next* suspension. Closing that window needs core
`resume({ expectedSuspendedAt })`. Different steps are safe: core
refuses the stale step and the task follows the run.
- A suspension that can't be shown as a form, or a run another instance
executes, keeps the task polling once a second and holding a
background-task slot.

**Testing**
- `pnpm --filter ./packages/mcp test:server` 3× clean: 421 passed.
`tsc`, oxlint and oxfmt clean.
- New `server-tasks-workflows.test.ts` (32 tests, in-memory and
background store), using real `MCPServer` over HTTP and real workflows,
plus an agent on a mock model. It covers:
  - auto fast and slow
  - suspend → update → complete, with the side-effect step running once
  - decline
  - cancel while working and while waiting for input
  - failed
  - unrepresentable schema
  - another principal
  - config errors
  - agent slow, cancel, error and pause
- Additions to `server-tasks-background.test.ts` (libsql file, two
instances):
  - answer through B for a run that A started
  - two instances taking the same answer at once
  - a run resumed outside MCP first
  - cancelling a waiting run from the other instance
- a server shutting down mid-step, and one losing its lease to another
worker: the run carries on and the task completes
- tracing: one trace per task across `tasks/update` on a peer, a
shutdown re-attach, and a crash restart (the following attempt is in the
task trace; the restarted run has its own)
- a child server SIGKILLed mid-step, after which a new instance runs
`restartAllActiveWorkflowRuns()`. The task completes on one run, and the
steps run `fetch, crunch, crunch`.
- Mutation-checked. The matching tests fail when I:
- start a run in `work` instead of re-attaching (the steps then show 4
entries),
  - drop the claim-lost fallback,
  - drop the `onCancel` hook (3 cancel tests fail).
- Manual check in the showcase playground: `run_nightly` and
`ask_researcher` driven from the client agent's Studio chat. The approve
form went through `tasks/update`, server Studio showed one run per call,
and cancelling while waiting for input cancelled the run.

The `ask_<agent>` result is the whole `generate()` output as JSON (about
5k tokens for a short answer). That's also true of the synchronous tool
today, so it isn't changed here, but it's worth a follow-up.

## Screenshots (tracing)

**Before: `run_nightly` start is an Error, and `tasks/update` and each
poll are separate traces**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/tracing/before-run_nightly-trace.png"
alt="before" width="720">

**After: one trace with `tools/call` → attempt #1 (run) → `tasks/update`
→ attempt #2 (resumed run)**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/tracing/after-run_nightly-trace.png"
alt="after" width="720">

**Before: `ask_researcher`'s agent run is its own root trace**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/tracing/before-ask_researcher-trace.png"
alt="before agent" width="720">

**After: the agent run sits under its task attempt**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/tracing/after-ask_researcher-trace.png"
alt="after agent" width="720">



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## ELI5

This change lets MCP clients start and manage workflow and agent tasks,
as well as ordinary tool tasks. Clients can check task progress, provide
input when a workflow pauses in a supported way, and cancel supported
tasks.

## Summary

- Adds experimental task support for workflow tools named
`run_<workflow>` and agent tools named `ask_<agent>`.
- Extends task configuration so defaults and required-task checks can
include workflows and agents.
- Starts one workflow run per workflow task. Later task attempts track,
resume, or cancel that run.
- In `auto` mode, a workflow run that finishes within `syncWindowMs`
returns synchronously. Otherwise, it continues as a task.
- Requests input only for workflow suspensions with a client-fillable
`resumeSchema`. Other suspensions remain in progress.
- Adds workflow recovery and cancellation support, including
cancellation of associated workflow runs when tasks are cancelled or
expire.
- Runs agent tasks through the tool-task path. Agent tasks that pause
for tool approval return an error result.
- Adds optional `onCancel(context)` hooks to the in-memory and
background task stores.
- Adds workflow and agent task tests, tracing coverage, reference
documentation, and a changeset.

## Validation

The PR description reports three successful runs of `pnpm --filter
./packages/mcp test:server`, with 421 passing tests per run. It also
reports clean TypeScript, oxlint, and oxfmt checks, plus manual checks
in the showcase playground. These results were not independently
verified.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
2026-10-30 07:40:19 -04:00
Daniel Lew
f548c12cfb
feat(mcp): keep MCP tool tasks in Mastra background-task storage (#28521)
Closes #28337.

> **Stacked:** base is `daniel/mcp-tasks-3a-server-tools` (#28420).
Until they merge, this diff also contains the core commits from the
stack **3b (#28425) → 3b2 (#28507) → 3b3 (#28590)**. To see only this
PR's changes, use the commits listed below (the latest core merge is
`6fb648cd33`, 3b3).

## What this does

An `MCPServer` that is registered on a Mastra instance with
`backgroundTasks` enabled now keeps its MCP tool tasks in Mastra
background-task storage, not in process memory. When instances share
storage (for example one libsql file or one database), any instance can
answer `tasks/get`, `tasks/update` and `tasks/cancel` for any task, and
any of them can run it. Tasks also survive a server restart.

```ts
const reports = new MCPServer({
  id: 'reports',
  tools: { buildReport },
  tasks: { tools: { buildReport: { mode: 'always', recover: true } } },
});
new Mastra({ storage, backgroundTasks: { enabled: true }, mcpServers: { reports } });
```

- **Store selection:** an explicit `tasks.store` is always used.
Otherwise, if Mastra background tasks exist and the storage adapter
supports per-row expiry (`supportsTaskExpiry`), tasks go to Mastra
storage. On an older adapter the server keeps tasks in memory and logs a
warning. Without Mastra background tasks, tasks stay in memory as
before.
- **New `recover` option** (`tasks.recover`, or per tool
`tasks.tools.x.recover`; default `false`). When the server running a
task crashes:
- `recover: false`: the task ends `failed` (`-32603`, "task lost: the
server restarted while it was running"), and `execute` never runs twice.
- `recover: true`: another instance runs `execute` again from the start,
once. Use this only for idempotent tools.
  - Tasks waiting for input resume on any instance either way.
- **`'auto'` handoff:** an `'auto'` tool that outlives its sync window
keeps running under the original request. Its row is pinned to that
worker (3b2 `pinToWorker`), so a peer never runs it a second time.
- **Sweeper:** each instance periodically fails tasks past their TTL,
re-issues resumes for answered tasks whose queued resume was lost with
its process, and settles tasks whose worker died. These writes use the
same fencing as core recovery, so each row is settled once. Each tick is
bounded: at most 100 expired rows, plus one rotating page of 100 other
open rows. Rows left pending by a dead instance are restarted only while
slots are free (capacity checked once per sweep), and the rest wait for
later ticks.
- **Open task caps across instances:** `create` honours the `limits`
from #28420 (`maxOpenTasksPerClient`, `maxOpenTasks`) by counting open,
unexpired rows for `mcp-server:<id>` and for the caller's hashed
principal in storage, and throws `MCPTaskLimitError` when a cap is
reached.
- **Answers are stored before `tasks/update` is acknowledged**, so an
answer is never lost, even if the instance that took it dies.

### Row mapping (deviates from S4 for security; approved)
- `toolCallId` is `sha256(taskId)`, never the task id itself. The task
id is a bearer token, and these rows are visible to unscoped
`/background-tasks` readers, global hooks and DB dumps.
- `agentId` is `mcp-server:<id>`, and `resourceId` is
`mcp-server:<id>:<sha256 of the principal>`. A Mastra resource id can
never match that `resourceId`, so resource-scoped `/background-tasks`
callers don't see MCP rows.
- The bearer token is stripped from the stored request context.
`authInfo.extra` and `user` are stored as-is (documented).
- The envelope (principal hash as `principalKey`, readable
`clientLabel`, TTL, input requests/answers, used keys) lives in
`metadata`, and the TTL in `expiresAt`.

Docs: `reference/tools/mcp-server.mdx` gains "Tasks across instances"
and "Recovery after a crash", plus the `recover`/`store`/`ttlMs`
entries. Changeset: `@mastra/mcp` minor.

## Commits (this PR only)
- `eeeae052c8` recover option in task config
- `dbcb5528ab` background-task store, projection, store selection
- `a8db20d3fb` sweeper
- `f07975e780` libsql integration suite (two instances on one file;
child server SIGKILLed mid-task)
- `489d1d12ff2` docs + changeset
- `6a6c484800` test teardown that doesn't leak writes past shutdown
- `d0984dcee7` pin the `'auto'` handoff row (`pinToWorker`); sweep
lapsed pins
- `66dec45811` cross-instance cancel test, expected to fail for now
- `67d678751c` review fixes: cancel/expiry abort a pinned 'auto'
attempt, sweeper dispatches rows queued on a dead instance, qualified
row `toolName` (no fallback to a same-named Mastra tool), `tasks/update`
errors on an unstored answer, store choice retried after a storage
error, lazy sweeper, warning for a generated server id, docs
- `075b314629` K1/K2 race test: a stale `tasks/update` for an earlier
suspension must not land on a later one
- `639b2bef7f` `tasks/update` fences its write on `expectedSuspendedAt`
(from #28590), fixing that race; K1/K2 test flipped to a plain `it`,
plus a unit test that a refused fenced write drops the answer instead of
storing it on the new suspension
- `7199c39d4d` docs: when a cancel from another instance stops a queued
first attempt
- `19dbb7732b` rows store a sha256 of the caller's principal
(`resourceId` `mcp-server:<id>:<hash>`, `metadata.principalKey`), never
the principal itself
- `ebcfb2bbe9` rows carry a readable `metadata.clientLabel` (client id
+ subject, user id, or token-hash prefix; never a credential, never used
for matching); the sweep reclaims a running row whose lease a graceful
shutdown released (ported from `fedc469d97`)
- `53265bdfea` each MCP tool task is one trace: the creating
`tools/call` is the root (ends OK, no longer ERROR), every attempt
(incl. `'auto'` first runs, resumes, recovered runs on a peer) is a
`task attempt <tool> #n` child via `resumedFromSpanId` (the
workflow/agent resume parentage), `tasks/update`/`tasks/cancel` join the
trace, `tasks/get` is untraced; task fields in span metadata
(`mcpTaskKey`, `attempt`, `resumed`, `recovered`, `mcpTaskStatus`); raw
task ids scrubbed from spans and store errors; root flushed on task
start (a rootless trace drops out of `listTraces`); `taskKeyOf` moved to
`shared/tasks/task-id.ts`, identical to #28343. Optional store
additions: `MCPTaskCreateParams.trace`, `MCPTaskAttempt.trace`,
`MCPTaskStore.traceOf`.
- `9b75753bea` attempts are numbered across instances: core's reclaim
of a lapsed lease leaves `retryCount` alone, so the store keeps an
explicit attempt count in the row envelope (fenced on the claim). A run
recovered after SIGKILL is `#2`, `recovered: true`. Studio check of the
kill -9 case (root never exported vs. flushed): rootless trace is
missing from the list and only reachable by id as an orphan attempt;
with the flush it is listed as `tools/call` → `task attempt #2`.
- `04ced40e2b` with #28506, #28509 and #28523 on main (merged through
the stack), the FGA and cross-instance cancel tests run as plain tests
and the `drain()` teardown workaround is gone.

## Tests
`src/server/server-tasks-background.test.ts`: real `Mastra` +
`LibSQLStore` on a temp file, real HTTP. The whole 3a task suite also
runs against both stores (in-memory and Mastra background tasks).
- A task created on A is read, answered and run on B. Each attempt runs
once.
- SIGKILL mid-task × `recover: true/false` × (peer already up / fresh
instance after the crash): completes after one more run, or fails as
lost with exactly one run.
- `'auto'` first attempt: an idle peer doesn't rerun it. A peer sweeping
while A's row waits for a slot doesn't rerun it either. With the owner
killed (slot free, and slot taken) and `recover: false`, the task fails
as lost and the peer never runs it.
- A queued resume lost with its killed process gets resumed by the next
instance.
- A task waiting for input past its TTL fails, a late answer isn't
taken, and `cleanup()` deletes finished rows at their TTL.
- Isolation: no rows in agent threads or resource-scoped listings, no
plaintext task id or token, and global hooks receive the rows.
- Selection: an adapter without expiry support falls back to memory with
a warning, and an explicit store wins.
- Open task caps: two instances on one libsql file share the per-client
cap (a call on B is refused while alice has 2 open on A, bob still gets
a task, a finished task frees the slot). The 3a cap suite also runs
against this store.
- Unit: projection (expiry, lost-message mapping, open keys), key-reuse
failure, sweeper expiry/reclaim (`recover` both ways, settled once), a
task waiting for input stops counting against the caps at its TTL before
the sweep fails it, 250 abandoned rows are restarted at most 100 per
sweep and all complete, and with 3 free slots one sweep restarts 3 of 20
rows and the next restarts none.

`pnpm --filter ./packages/mcp test:server`: 375 passed, three runs in a
row, all exit 0, no unhandled rejections. Each review fix and each
tracing change has a regression test that fails with the change reverted
(including both suspension-fence tests, which fail with
`expectedSuspendedAt` removed).

### Core fix #28719 merged in
#28509 made graceful shutdown wait for aborted runs before handing their
leases back, by which point the runs had already dropped out of
`ownedLeases`. #28719 snapshots the held leases first. It's merged into
this branch so the hand-back test runs as a plain test: after
`shutdown()` the row is `running` with no owner or lease, and a peer
reruns the `recover: true` task at its next sweep. With #28719's manager
change reversed, that test fails (1 failed, 32 passed).

### Mutation checks
- Without the `pinToWorker` pin, the `'auto'` sweeping-peer test fails
because the tool runs twice. The slot-taken lost test fails too: no
owner on the row.
- Without the sweep of lapsed pinned rows, the slot-taken lost test
never leaves `working`.
- Before 3b2, the `'auto'` sweeping-peer test failed against the
unpinned code: the tool ran twice.
- Without the cap check in `create`, the cross-instance cap test and the
5 cap tests of the 3a suite on this store fail. Without the TTL filter
on the count, the input-past-TTL count test fails. Restarting every
candidate instead of only the free slots fails the free-slots test (20
restarts, not 3), and the old unbounded sweep fails the batch test (250
restarts in one sweep).

### Known limitations

- A task trace's duration is the root `tools/call`'s, a few ms, since
the root is the request that created the task. Studio's Duration column
understates every task; follow-up to show the task's real span.
- Per-owner concurrency (`perOwnerConcurrency` for `mcp-server:<id>`)
can be briefly exceeded across instances. Peers count running rows in
storage, and a pinned pending row whose first attempt is already running
under its request isn't counted until it is dispatched.
- The open task caps are count-then-insert across instances, so creates
racing on different instances can each pass the count and go over a cap
by up to their number.

## Manual e2e (real `mastra build` output, libsql file, SIGKILL)
Playground server app with `LibSQLStore` + `backgroundTasks`,
`durable_report` with `recover: true` and `fragile_report` with the
default. Two built instances (`node .mastra/output/index.mjs`) run
behind a round-robin proxy, plus per-instance proxies, and every
exchange is captured. **16/16 checks pass** with #28523 on main.
- Round robin: polls alternate between instances, every poll sees the
task, and it completes. `tasks/cancel` through the other instance is
acked and the task reads `cancelled`.
- SIGKILL A while B is up: `durable_report` completes on B, which ran it
once. `fragile_report` reads `failed` "task lost…", and B never ran it.
- SIGKILL the only instance and start a fresh one: same results, through
startup recovery.
- `/api/background-tasks`: rows sit under `mcp-server:tasks-playground`,
with no MCP task id or bearer token in the response.
- Cancel through B stops the run on A: A's journal shows
`fragile_report` start 23:16:15.032, then `aborted` at 23:16:16.212,
about 1s after the cancel.

## Screenshots (tracing)

**Recovered task after SIGKILL: one trace, `tools/call` → `task attempt
#2`**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/tracing/3c-recovered-trace-detail.png"
alt="recovered trace" width="720">

**Without the root flush, a task whose instance was killed is missing
from the trace list**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/tracing/3c-noflush-list.png"
alt="no flush" width="720">

**With the flush it's listed**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/tracing/3c-flush-list.png"
alt="flush" width="720">






<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## ELI5

MCP tasks can use shared Mastra storage instead of living only in one
server’s memory. This lets server instances share task status and work,
and can let another instance retry a task after a server stops.

## What changed

- When Mastra background tasks are enabled, MCP servers use an
explicitly configured `tasks.store` first. Otherwise, they use Mastra
storage when it supports per-task expiry, or fall back to in-memory
storage.
- Shared storage supports cross-instance task reads, updates,
cancellation, execution, and recovery. Recovery defaults to `false` and
can be configured globally or per tool.
- The background store handles task expiry, cleanup, open-task limits,
and recovery sweeps. It stores hashes of task IDs and caller principals,
not the original values or bearer tokens.
- MCP task attempts can link to the task’s trace. Poll requests are not
traced.
- Core background tasks add worker pinning for pending tasks and
suspension-time fencing for updates. Storage adapters implement the
fencing condition.
- Documentation, changesets, and tests cover the MCP task storage and
core background-task changes.

## Validation

The PR description reports that `pnpm --filter ./packages/mcp
test:server` passed 375 tests in three consecutive runs. It also reports
16 successful manual end-to-end checks with built instances and a LibSQL
file. These results are author-reported. Reported limitations include
trace duration reflecting the creating `tools/call` root, brief
cross-instance concurrency-cap overruns, and count-then-insert races
that can exceed open-task caps.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
2026-10-29 22:34:44 -04:00
Daniel Lew
e80dd64c83
fix(mcp): accept any MCP task createdAt in MCPClient (#28899)
## Summary

Follow-up to #28343 (MCP Tasks client), addressing two CodeRabbit
threads that came in after it merged.

**Valid ISO 8601 `createdAt` no longer fails the call.** #28343 rejected
any task whose `createdAt` `Date.parse` can't read. That includes valid
ISO 8601 basic format such as `20261029T120000Z`, so a tool call against
a server using it failed outright. The schema now accepts any string.
When `createdAt` doesn't parse, `waitForTask` counts the TTL from when
it started waiting. That keeps the TTL backstop working and stops an
unreadable timestamp from turning the outage limit into `NaN`, which
used to make the wait poll forever.

**Disconnect test checks every request.** The "does not reconnect after
disconnect" test counted only `initialize`, but a reconnect can go
through `server/discover` instead. It now asserts no request of any kind
reaches the server after the call ends.

## Test plan

- `wait.test.ts`: new "counts the TTL from when it first saw the task
when createdAt does not parse". Without the fix the vitest worker hangs
in an endless poll loop and crashes.
- `schemas.test.ts`: accepts `20261029T120000Z`; failed before the fix.
- `tasks.test.ts` disconnect test: reverting the #28343 disconnect fix
in `client.ts` makes it time out.
- `pnpm --filter ./packages/mcp test:client` 557 passed (x2);
`test:server` 251 passed; `tsc --noEmit` clean; oxlint/prettier clean;
Vale (CI config) 0 errors on `mcp-client.mdx`.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## ELI5
This change lets the MCP client accept task timestamps that JavaScript
cannot parse. If it cannot parse a timestamp, the client starts the
task’s time limit when it begins waiting, so it can still stop waiting
when the limit expires.

## Changes
- The task schema accepts any string for `createdAt`, including
`20261029T120000Z`.
- `waitForTask` uses `createdAt` to calculate the TTL. If parsing fails,
it uses the time waiting began.
- Polling waits stop at the TTL deadline. The client polls at the
deadline before reporting expiration.
- The TTL caps the wait between polls. It does not end a poll or other
operation that is already in progress.
- The disconnect test checks for any request after the pending call
fails, not only `initialize` requests.
- The documentation explains the TTL fallback when the client cannot
parse `createdAt`.

## Validation
The PR description reports 557 client tests passed twice, 251 server
tests passed, and clean type-checking, lint, formatting, and
documentation checks. These checks were not independently run.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
2026-10-29 17:40:27 -04:00
Daniel Lew
e30d29bb8f
feat(mcp): MCPServer serves MCP Tasks for tools (#28420)
Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
2026-10-29 16:53:37 -04:00
Daniel Lew
76f4110887
feat(mcp): MCPClient can wait for MCP Tasks from remote servers (#28343)
Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
2026-10-29 16:28:44 -04:00
Daniel Lew
096e246ad7
feat(mcp): internal wire layer and task store for MCP Tasks (#28340)
Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
2026-10-29 15:17:12 -04:00
Dane - AI (Mastra)
f6cd11f348
chore(deps): lock file maintenance (#28672)
This PR contains the following updates:

| Update | Change |
|---|---|
| lockFileMaintenance | All locks refreshed |

---

> [!WARNING]
> Some dependencies could not be looked up. Check the [Dependency
Dashboard](../issues/9505) for more information.

🔧 This Pull Request updates lock files to use the latest dependency
versions.

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - "before 6am on wednesday"
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get
[config
help](https://redirect.github.com/renovatebot/renovate/discussions) if
that's undesired.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend Renovate
CLI](https://redirect.github.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xOTAuMCIsInVwZGF0ZWRJblZlciI6IjQ0LjE5MC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJhdXRvbWF0aW9uIl19-->

---------

Co-authored-by: mastra-platform[bot] <284800079+mastra-platform[bot]@users.noreply.github.com>
2026-10-29 10:02:15 +00:00
Dane - AI (Mastra)
07c1bf2362
chore(deps): update dependency @ai-sdk/provider-utils@>=3.0.0 <3.0.38 to v3.0.42 (#28773) 2026-10-28 18:08:16 -07:00
Dane - AI (Mastra)
f2ad3844f3
chore(deps): update opentelemetry (#28581)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: mastra-platform[bot] <284800079+mastra-platform[bot]@users.noreply.github.com>
2026-10-28 16:48:54 -07:00
shreyas-mastra
6deb7c0a1e
chore(security): Vanta 2026-10-28 - qs 6.16.1, @modelcontextprotocol/node 2.1.1 floors (#28716)
Refs mastra-ai/platform#2931

Vanta remediation pass for 2026-10-28. It follows #28325, which has
merged.

## 2026-10-28 update
Today's live Vanta export added 3 advisory IDs on `mastra-ai/mastra`
(GitHub/Dependabot). This PR fixes the two that have a published fix and
leaves deepmerge, which has none.

| Package | From → To | Finding | Where | How |
|---|---|---|---|---|
| qs | 6.16.0 → 6.16.1 | CVE-2026-110816 / GHSA-6pq8-jhm2-2vcw (Medium
×4) | root `pnpm-lock.yaml`, 9 `e2e-tests/*` lockfiles,
`scripts/gh-issue-triage/package-lock.json` | Raised the existing floors
`qs@>=6.7.0 <6.16.0: 6.16.0` → `<6.16.1: 6.16.1` and `'qs@<6.7.0':
6.16.0` → `6.16.1`. Raised the npm override in gh-issue-triage. |
| @modelcontextprotocol/node | 2.0.0 → 2.1.1 | GHSA-f897-62hf-6gxq (High
×2; HTTP transports had no body-size or batch-length limit) | root
`pnpm-lock.yaml` (published `@mastra/mcp` 1.18.0, used as `mcp-legacy`),
`scripts/gh-issue-triage/package-lock.json` | New pnpm override
`'@modelcontextprotocol/node@>=2.0.0 <2.1.0': 2.1.1` and a new npm
override in gh-issue-triage. I used 2.1.1 rather than 2.1.2 because
2.1.2 needs a `@modelcontextprotocol/server` peer of `^2.4.0`, while
`@mastra/mcp` 1.18 resolves server 2.3.1. `packages/mcp` itself already
uses node 2.1.2. |

- Both versions are older than the 1-day `minimumReleaseAge`: qs 6.16.1
was published 10-14 and node 2.1.1 on 10-02. I did not use qs 6.16.2
(10-27), which is too new.
- No floors or overrides were removed; existing ones were only raised.
- `pnpm install --frozen-lockfile --lockfile-only` passes at the root.
Each nested e2e workspace was regenerated with `pnpm install
--lockfile-only`.
- Added the empty changeset
`.changeset/vanta-2026-10-28-security-floors.md`. No published package
changes.
- After this change, osv-scanner over all 33 lockfiles reports only the
documented leftovers:
  - zod 3.25.76 (zod v3 compat line on purpose)
  - ai 4.3.19 / `@ai-sdk/provider-utils` 2.2.8 (vendored v4 line)
- `@azure/msal-node` 5.6.0 / 6.0.1 (fix 7.1.0 needs majors in identity
and teams)
  - `@opentelemetry/core` 1.30.1 (needs pubsub 6)
  - extract-zip 2.0.1 (no patched release)
- deepmerge 4.3.1 (CVE-2026-93753 / GHSA-gcqx-w48m-w2h4; no patched
release, 4.3.1 is the latest)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## ELI5

This PR updates dependency rules and package versions to use newer
releases, including security fixes for `qs` and
`@modelcontextprotocol/node`. It also updates AI SDK dependencies and
does not include published package changes.

## Summary

- Raise the `qs` override target to `6.16.1` in the root and e2e
workspaces and in `scripts/gh-issue-triage`.
- Add an `@modelcontextprotocol/node` override at `2.1.1` in the root
workspace and `scripts/gh-issue-triage`.
- Update AI SDK dependency versions across package manifests and add a
changeset describing the provider-utils update.
- Add an empty changeset for the security-only dependency updates.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

## Update 2026-10-28 (afternoon)
- Merged origin/main (clean).
- Bumped the AI SDK v5 compat line from @ai-sdk/provider-utils 3.0.41 to
3.0.42 (patch, published 2026-10-21; it blocks `.internal` hostnames in
download URL validation and encodes provider-returned IDs in request
paths). This addresses the Aikido /mastra Highs AIKIDO-2026-10990 and
AIKIDO-2026-10981:
- ai 5.0.277 → 5.0.282, @ai-sdk/gateway 2.0.168 → 2.0.173 (vendored
ai_v5)
- anthropic 2.0.109 → 2.0.110, google 2.0.103 → 2.0.106, groq 2.0.58 →
2.0.59, openai 2.0.135 → 2.0.137, openai-compatible 1.0.58 → 1.0.59, xai
2.0.99 → 2.0.100
- Nested lockfiles updated: memory/integration-tests and
playground/e2e/kitchen-sink.
- No new overrides. Changeset:
`vanta-2026-10-28-ai-sdk-v5-provider-utils.md`.
2026-10-28 18:51:27 -04:00
Dane - AI (Mastra)
29747ebd1d
chore(deps): update better-auth monorepo to v1.7.13 (#28538)
This PR contains the following updates:

| Package | Type | Update | Change | Pending |
|---|---|---|---|---|
|
[@better-auth/drizzle-adapter@<1.7.7](https://www.better-auth.com/docs/adapters/drizzle)
([source](https://redirect.github.com/better-auth/better-auth/tree/HEAD/packages/drizzle-adapter))
| pnpm-workspace.overrides | patch | [`1.7.7` →
`1.7.13`](https://renovatebot.com/diffs/npm/@better-auth%2fdrizzle-adapter@<1.7.7/1.7.7/1.7.13)
| `1.7.14` |
| [better-auth](https://better-auth.com)
([source](https://redirect.github.com/better-auth/better-auth/tree/HEAD/packages/better-auth))
| pnpm-workspace.overrides | patch | [`^1.7.7` →
`^1.7.13`](https://renovatebot.com/diffs/npm/better-auth/1.7.7/1.7.13) |
`1.7.14` |
| [better-auth](https://better-auth.com)
([source](https://redirect.github.com/better-auth/better-auth/tree/HEAD/packages/better-auth))
| dependencies | patch | [`^1.7.12` →
`^1.7.13`](https://renovatebot.com/diffs/npm/better-auth/1.7.12/1.7.13)
| `1.7.14` |

---

> [!WARNING]
> Some dependencies could not be looked up. Check the [Dependency
Dashboard](../issues/9505) for more information.

---

### Release Notes

<details>
<summary>better-auth/better-auth
(@&#8203;better-auth/drizzle-adapter@<1.7.7)</summary>

###
[`v1.7.13`](https://redirect.github.com/better-auth/better-auth/blob/HEAD/packages/drizzle-adapter/CHANGELOG.md#1713)

[Compare
Source](https://redirect.github.com/better-auth/better-auth/compare/v1.7.12...v1.7.13)

###
[`v1.7.12`](https://redirect.github.com/better-auth/better-auth/blob/HEAD/packages/drizzle-adapter/CHANGELOG.md#1712)

[Compare
Source](https://redirect.github.com/better-auth/better-auth/compare/v1.7.11...v1.7.12)

###
[`v1.7.11`](https://redirect.github.com/better-auth/better-auth/blob/HEAD/packages/drizzle-adapter/CHANGELOG.md#1711)

[Compare
Source](https://redirect.github.com/better-auth/better-auth/compare/v1.7.10...v1.7.11)

###
[`v1.7.10`](https://redirect.github.com/better-auth/better-auth/blob/HEAD/packages/drizzle-adapter/CHANGELOG.md#1710)

[Compare
Source](https://redirect.github.com/better-auth/better-auth/compare/v1.7.9...v1.7.10)

###
[`v1.7.9`](https://redirect.github.com/better-auth/better-auth/blob/HEAD/packages/drizzle-adapter/CHANGELOG.md#179)

[Compare
Source](https://redirect.github.com/better-auth/better-auth/compare/v1.7.8...v1.7.9)

###
[`v1.7.8`](https://redirect.github.com/better-auth/better-auth/blob/HEAD/packages/drizzle-adapter/CHANGELOG.md#178)

[Compare
Source](https://redirect.github.com/better-auth/better-auth/compare/v1.7.7...v1.7.8)

##### Patch Changes

-
[#&#8203;11512](https://redirect.github.com/better-auth/better-auth/pull/11512)
[`4175b34`](4175b34a8f)
Thanks [@&#8203;bytaesu](https://redirect.github.com/bytaesu)! - Align
the installed `@better-auth/utils` version with `better-call` while
accepting `^0.4.2 || ^0.5.0` across official package peers.

-
[#&#8203;11731](https://redirect.github.com/better-auth/better-auth/pull/11731)
[`0cfe07d`](0cfe07dccd)
Thanks
[@&#8203;gustavovalverde](https://redirect.github.com/gustavovalverde)!
- Drizzle schemas that store dates in string columns now work:
`timestamp({ mode: "string" })`, MySQL `datetime({ mode: "string" })`,
and SQLite `text()`, including on Cloudflare D1. Before, the adapter
passed a JavaScript `Date` to those columns. Drivers such as
postgres-js, better-sqlite3 and D1 rejected it, so email sign-up, social
sign-in and session refresh failed. Filtering on those columns, for
example when listing sessions, failed the same way. Better Auth now
writes these dates as UTC text and reads a value without a time zone as
UTC.

If your server's time zone is not UTC and you use node-postgres or
mysql2 with a string column that has no time zone, existing rows were
written in the server's local time. They now read back shifted by the
server's UTC offset, so sessions and verification codes created before
the upgrade can expire early or late. Schemas generated by the CLI use
date columns and are unaffected.

</details>

<details>
<summary>better-auth/better-auth (better-auth)</summary>

###
[`v1.7.13`](https://redirect.github.com/better-auth/better-auth/blob/HEAD/packages/better-auth/CHANGELOG.md#1713)

[Compare
Source](https://redirect.github.com/better-auth/better-auth/compare/v1.7.12...v1.7.13)

##### Patch Changes

-
[#&#8203;11985](https://redirect.github.com/better-auth/better-auth/pull/11985)
[`9cb95fe`](9cb95fe3d0)
Thanks [@&#8203;bytaesu](https://redirect.github.com/bytaesu)! - Type
declarations no longer list type-only exports as values, so importing
one as a value now fails type checking instead of failing at runtime.

- Updated dependencies
\[[`2712441`](2712441e35),
[`1cf4b2c`](1cf4b2c8f5)]:
-
[@&#8203;better-auth/core](https://redirect.github.com/better-auth/core)@1.7.13
-
[@&#8203;better-auth/drizzle-adapter](https://redirect.github.com/better-auth/drizzle-adapter)@1.7.13
-
[@&#8203;better-auth/kysely-adapter](https://redirect.github.com/better-auth/kysely-adapter)@1.7.13
-
[@&#8203;better-auth/memory-adapter](https://redirect.github.com/better-auth/memory-adapter)@1.7.13
-
[@&#8203;better-auth/mongo-adapter](https://redirect.github.com/better-auth/mongo-adapter)@1.7.13
-
[@&#8203;better-auth/prisma-adapter](https://redirect.github.com/better-auth/prisma-adapter)@1.7.13
-
[@&#8203;better-auth/telemetry](https://redirect.github.com/better-auth/telemetry)@1.7.13

###
[`v1.7.12`](https://redirect.github.com/better-auth/better-auth/blob/HEAD/packages/better-auth/CHANGELOG.md#1712)

[Compare
Source](https://redirect.github.com/better-auth/better-auth/compare/v1.7.11...v1.7.12)

##### Patch Changes

-
[#&#8203;11925](https://redirect.github.com/better-auth/better-auth/pull/11925)
[`fb48619`](fb48619083)
Thanks [@&#8203;bytaesu](https://redirect.github.com/bytaesu)! - The JWT
plugin now verifies JWTs and session cookie-cache JWTs with the
algorithm of the stored key instead of the one named in the token
header, and logs a warning when it signs or verifies a JWT without an
issuer or audience.

-
[#&#8203;11924](https://redirect.github.com/better-auth/better-auth/pull/11924)
[`681aa5c`](681aa5c443)
Thanks [@&#8203;bytaesu](https://redirect.github.com/bytaesu)! -
`auth.api.getSession()` now keeps the original database error as
`error.cause` when the session lookup fails, so server code can tell a
transient failure from a bug.

-
[#&#8203;11930](https://redirect.github.com/better-auth/better-auth/pull/11930)
[`b18e3b8`](b18e3b8fdf)
Thanks [@&#8203;bytaesu](https://redirect.github.com/bytaesu)! - OAuth
callbacks completed through the OAuth proxy now run the same checks as
the standard OAuth callback, including issuer and ID token nonce
validation.

- Updated dependencies
\[[`681aa5c`](681aa5c443),
[`4bc78ba`](4bc78baa83),
[`876608d`](876608da86),
[`083a743`](083a74329b),
[`492134a`](492134aeba)]:
-
[@&#8203;better-auth/core](https://redirect.github.com/better-auth/core)@1.7.12
-
[@&#8203;better-auth/drizzle-adapter](https://redirect.github.com/better-auth/drizzle-adapter)@1.7.12
-
[@&#8203;better-auth/kysely-adapter](https://redirect.github.com/better-auth/kysely-adapter)@1.7.12
-
[@&#8203;better-auth/memory-adapter](https://redirect.github.com/better-auth/memory-adapter)@1.7.12
-
[@&#8203;better-auth/mongo-adapter](https://redirect.github.com/better-auth/mongo-adapter)@1.7.12
-
[@&#8203;better-auth/prisma-adapter](https://redirect.github.com/better-auth/prisma-adapter)@1.7.12
-
[@&#8203;better-auth/telemetry](https://redirect.github.com/better-auth/telemetry)@1.7.12

###
[`v1.7.11`](https://redirect.github.com/better-auth/better-auth/blob/HEAD/packages/better-auth/CHANGELOG.md#1711)

[Compare
Source](https://redirect.github.com/better-auth/better-auth/compare/v1.7.10...v1.7.11)

##### Patch Changes

-
[#&#8203;10719](https://redirect.github.com/better-auth/better-auth/pull/10719)
[`bd65db0`](bd65db02c1)
Thanks [@&#8203;rendermani](https://redirect.github.com/rendermani)! -
Recognize PostgreSQL `int8` as a valid number type in migration diffs.
Kysely's introspector reports `pg_type.typname`, so Better Auth's own
`bigint` columns (such as the database-backed rate limiter's
`lastRequest`) came back as `int8` and were reported as a type mismatch
on every run.

-
[#&#8203;11521](https://redirect.github.com/better-auth/better-auth/pull/11521)
[`37a75c9`](37a75c95d1)
Thanks [@&#8203;aryan1306](https://redirect.github.com/aryan1306)! - Fix
database-backed rate limiting returning an excessively large
`X-Retry-After` header instead of the remaining seconds in the
rate-limit window.

- Updated dependencies
\[[`ce96569`](ce965696d1),
[`2f6ca3f`](2f6ca3f370),
[`dfd8dd2`](dfd8dd287a)]:
-
[@&#8203;better-auth/core](https://redirect.github.com/better-auth/core)@1.7.11
-
[@&#8203;better-auth/drizzle-adapter](https://redirect.github.com/better-auth/drizzle-adapter)@1.7.11
-
[@&#8203;better-auth/kysely-adapter](https://redirect.github.com/better-auth/kysely-adapter)@1.7.11
-
[@&#8203;better-auth/memory-adapter](https://redirect.github.com/better-auth/memory-adapter)@1.7.11
-
[@&#8203;better-auth/mongo-adapter](https://redirect.github.com/better-auth/mongo-adapter)@1.7.11
-
[@&#8203;better-auth/prisma-adapter](https://redirect.github.com/better-auth/prisma-adapter)@1.7.11
-
[@&#8203;better-auth/telemetry](https://redirect.github.com/better-auth/telemetry)@1.7.11

###
[`v1.7.10`](https://redirect.github.com/better-auth/better-auth/blob/HEAD/packages/better-auth/CHANGELOG.md#1710)

[Compare
Source](https://redirect.github.com/better-auth/better-auth/compare/v1.7.9...v1.7.10)

##### Patch Changes

-
[#&#8203;11393](https://redirect.github.com/better-auth/better-auth/pull/11393)
[`eebd47a`](eebd47a0e7)
Thanks [@&#8203;breken-ai](https://redirect.github.com/breken-ai)! - If
you use the `lastLoginMethod` plugin with `oneTap`, signing in through
Google One Tap now records `"google"`, the same value as signing in with
the Google button. Before, a One Tap sign-in recorded nothing: the
`better-auth.last_used_login_method` cookie kept its previous value or
stayed unset, and so did `user.lastLoginMethod` with `storeInDatabase`.

If your `customResolveMethod` includes a `/one-tap/callback` →
`"google"` workaround, remove that mapping; keep the resolver if it
handles other routes.

-
[#&#8203;11821](https://redirect.github.com/better-auth/better-auth/pull/11821)
[`09d07e6`](09d07e6fea)
Thanks
[@&#8203;gustavovalverde](https://redirect.github.com/gustavovalverde)!
- The Google One Tap prompt (`authClient.oneTap()` without `button`) no
longer calls `getSkippedReason()`, which Google's FedCM migration guide
says to remove. Before, it called it under any `promptOptions.fedCM`
setting.

A skipped prompt now ends the flow and calls `onPromptNotification`
right away instead of retrying. Google doesn't report why a prompt was
skipped, and a prompt the user closed stays hidden for Google's cooldown
period, so the retries could not bring it back. Dismissed prompts still
retry as before.

Google Identity Services still logs its FedCM migration warning, because
it does so whenever `prompt()` receives a listener. The plugin needs the
listener to track dismissals and skips, so the warning is expected and
safe to ignore.

-
[#&#8203;11819](https://redirect.github.com/better-auth/better-auth/pull/11819)
[`eaecb72`](eaecb7229e)
Thanks
[@&#8203;gustavovalverde](https://redirect.github.com/gustavovalverde)!
- Google One Tap now applies your
`socialProviders.google.mapProfileToUser` and custom `getUserInfo`, the
same as the standard Google sign-in. Before, One Tap ignored both and
always stored the token's `name`, `email`, `email_verified`, and
`picture` claims.

If you configured either one, users created through One Tap now get the
fields it returns, including any extra fields such as a first name from
`given_name`. Returning users are updated from it on each One Tap
sign-in when `socialProviders.google.overrideUserInfoOnSignIn` is on,
and so are existing users that One Tap links when
`account.accountLinking.updateUserInfoOnLink` is on. Check that your
mapper suits One Tap users too.

If you set `socialProviders.google.overrideUserInfoOnSignIn`, One Tap
sign-ins now update returning users' name, image, and email from Google,
as the redirect sign-in already does.

Setups that configure none of these, including `oneTap({ clientId })`
with no Google provider, are unaffected.

-
[#&#8203;11820](https://redirect.github.com/better-auth/better-auth/pull/11820)
[`88c9a37`](88c9a37856)
Thanks
[@&#8203;gustavovalverde](https://redirect.github.com/gustavovalverde)!
- If you set `autoSelect` or `cancelOnTapOutside` on `oneTapClient()`,
the One Tap prompt and the Sign in with Google button now use them.
Before, only values passed to `authClient.oneTap()` took effect, so with
`autoSelect: true` on the plugin, returning users still had to pick an
account. Values passed to `oneTap()` still override the plugin's. Apps
that set these options only on `oneTap()`, or not at all, are
unaffected.

-
[#&#8203;11696](https://redirect.github.com/better-auth/better-auth/pull/11696)
[`0cf1f7c`](0cf1f7c6bc)
Thanks [@&#8203;drewsephski](https://redirect.github.com/drewsephski)! -
You can now import the One Tap plugin from
`better-auth/plugins/one-tap`, as you can for other plugins. Previously
this import failed with a "not exported" error. Imports from
`better-auth/plugins` and `better-auth/client/plugins` are unchanged.

-
[#&#8203;11822](https://redirect.github.com/better-auth/better-auth/pull/11822)
[`414e845`](414e845f12)
Thanks
[@&#8203;gustavovalverde](https://redirect.github.com/gustavovalverde)!
- You can now import the Captcha and OpenAPI plugins from
`better-auth/plugins/captcha` and `better-auth/plugins/open-api`, as you
can for other plugins. Previously these imports failed with a "not
exported" error. Imports from `better-auth/plugins` are unchanged.

If your TypeScript config uses `"moduleResolution": "node"` (or
`node10`), `better-auth/plugins/multi-session` and `better-auth/test`
now resolve their types. Previously TypeScript reported that it could
not find their declarations. Projects using `bundler`, `node16`, or
`nodenext` resolution are unaffected.

- Updated dependencies
\[[`fedd055`](fedd05586c),
[`bbd0a19`](bbd0a19c30),
[`99cdfe7`](99cdfe7c2e)]:
-
[@&#8203;better-auth/core](https://redirect.github.com/better-auth/core)@1.7.10
-
[@&#8203;better-auth/mongo-adapter](https://redirect.github.com/better-auth/mongo-adapter)@1.7.10
-
[@&#8203;better-auth/drizzle-adapter](https://redirect.github.com/better-auth/drizzle-adapter)@1.7.10
-
[@&#8203;better-auth/kysely-adapter](https://redirect.github.com/better-auth/kysely-adapter)@1.7.10
-
[@&#8203;better-auth/memory-adapter](https://redirect.github.com/better-auth/memory-adapter)@1.7.10
-
[@&#8203;better-auth/prisma-adapter](https://redirect.github.com/better-auth/prisma-adapter)@1.7.10
-
[@&#8203;better-auth/telemetry](https://redirect.github.com/better-auth/telemetry)@1.7.10

###
[`v1.7.9`](https://redirect.github.com/better-auth/better-auth/blob/HEAD/packages/better-auth/CHANGELOG.md#179)

[Compare
Source](https://redirect.github.com/better-auth/better-auth/compare/v1.7.8...v1.7.9)

##### Patch Changes

-
[#&#8203;11766](https://redirect.github.com/better-auth/better-auth/pull/11766)
[`6edaa61`](6edaa61e62)
Thanks [@&#8203;bytaesu](https://redirect.github.com/bytaesu)! - An
`onAPIError.onError` handler that throws or rejects no longer fails the
request or causes an unhandled promise rejection. The error is logged
and the original error response is returned. Async handlers now finish
before the response is sent.

- Updated dependencies \[]:
-
[@&#8203;better-auth/core](https://redirect.github.com/better-auth/core)@1.7.9
-
[@&#8203;better-auth/drizzle-adapter](https://redirect.github.com/better-auth/drizzle-adapter)@1.7.9
-
[@&#8203;better-auth/kysely-adapter](https://redirect.github.com/better-auth/kysely-adapter)@1.7.9
-
[@&#8203;better-auth/memory-adapter](https://redirect.github.com/better-auth/memory-adapter)@1.7.9
-
[@&#8203;better-auth/mongo-adapter](https://redirect.github.com/better-auth/mongo-adapter)@1.7.9
-
[@&#8203;better-auth/prisma-adapter](https://redirect.github.com/better-auth/prisma-adapter)@1.7.9
-
[@&#8203;better-auth/telemetry](https://redirect.github.com/better-auth/telemetry)@1.7.9

###
[`v1.7.8`](https://redirect.github.com/better-auth/better-auth/blob/HEAD/packages/better-auth/CHANGELOG.md#178)

[Compare
Source](https://redirect.github.com/better-auth/better-auth/compare/v1.7.7...v1.7.8)

##### Patch Changes

-
[#&#8203;11512](https://redirect.github.com/better-auth/better-auth/pull/11512)
[`4175b34`](4175b34a8f)
Thanks [@&#8203;bytaesu](https://redirect.github.com/bytaesu)! - Align
the installed `@better-auth/utils` version with `better-call` while
accepting `^0.4.2 || ^0.5.0` across official package peers.

-
[#&#8203;11565](https://redirect.github.com/better-auth/better-auth/pull/11565)
[`b1cfc1e`](b1cfc1ec1e)
Thanks [@&#8203;bytaesu](https://redirect.github.com/bytaesu)! - Omit
non-returned custom fields from inferred output schema types.

-
[#&#8203;11540](https://redirect.github.com/better-auth/better-auth/pull/11540)
[`678c555`](678c555beb)
Thanks [@&#8203;bytaesu](https://redirect.github.com/bytaesu)! - Align
cookie security attributes with RFC 6265bis.

-
[#&#8203;10591](https://redirect.github.com/better-auth/better-auth/pull/10591)
[`193efff`](193efff3d2)
Thanks [@&#8203;kdelay](https://redirect.github.com/kdelay)! - Expired
or revoked sessions now clear stale cookies when using `customSession`.

-
[#&#8203;11625](https://redirect.github.com/better-auth/better-auth/pull/11625)
[`369176e`](369176e7f6)
Thanks
[@&#8203;gustavovalverde](https://redirect.github.com/gustavovalverde)!
- Fixed single-use checks for apps that set
`advanced.database.generateId: "uuid"`. Default id generation is
unaffected, and no migration is needed.

- On SQLite and MySQL, SAML sign-in, DPoP-bound requests checked against
the database replay store, `private_key_jwt` client authentication, and
magic link or email OTP sign-ins that adopt an unverified account failed
with a `NOT NULL` error on the `id` column. They now work. SIWE sign-in
ignored the `email` field and used the wallet-derived address; it now
uses the supplied email when no other account has it.
- On Postgres and MongoDB, a reused SAML assertion, DPoP proof, or
client assertion was accepted. Each one is now accepted only once.

With `generateId: "serial"`, behavior is unchanged: these checks need
string ids, and Better Auth now logs a warning the first time one of
these flows runs.

-
[#&#8203;11391](https://redirect.github.com/better-auth/better-auth/pull/11391)
[`352d04c`](352d04c8eb)
Thanks [@&#8203;breken-ai](https://redirect.github.com/breken-ai)! - Fix
`customSession` treating session lookup failures as signed-out users.
Server-side `getSession` now throws an API error, and HTTP clients
receive an error response.

-
[#&#8203;11750](https://redirect.github.com/better-auth/better-auth/pull/11750)
[`e9d9921`](e9d9921217)
Thanks
[@&#8203;gustavovalverde](https://redirect.github.com/gustavovalverde)!
- Generic OAuth providers configured with `discoveryUrl` now recover
without a restart when discovery fails at startup. Since 1.7.3, a
provider whose discovery request failed at boot (for example, because
the identity provider was still starting) was skipped, and every sign-in
returned `PROVIDER_NOT_FOUND` until the app restarted. Better Auth now
retries discovery on the next sign-in, callback, or account-linking
request for that provider, and the provider works as soon as discovery
succeeds. While discovery keeps failing, sign-in and account linking
still return `PROVIDER_NOT_FOUND` and callbacks redirect with
`error=oauth_provider_not_found`, and each request may wait up to 10
seconds for the retry.

-
[#&#8203;11549](https://redirect.github.com/better-auth/better-auth/pull/11549)
[`1bd5c37`](1bd5c37884)
Thanks [@&#8203;bytaesu](https://redirect.github.com/bytaesu)! - Fix
`lastLoginMethod` failing sign-in when `cookieName` or `maxAge` is
explicitly `undefined`.

-
[#&#8203;11174](https://redirect.github.com/better-auth/better-auth/pull/11174)
[`766cfb3`](766cfb3f42)
Thanks [@&#8203;Bekacru](https://redirect.github.com/Bekacru)! - Stop
double-decoding `callbackURL`, `newUserCallbackURL` and
`errorCallbackURL` on magic link verify so percent-encoded characters in
callback query params are preserved.

-
[#&#8203;11505](https://redirect.github.com/better-auth/better-auth/pull/11505)
[`c46992f`](c46992f6ce)
Thanks [@&#8203;bytaesu](https://redirect.github.com/bytaesu)! -
Preserve the referenced model and field keys when generating Kysely
migrations, so custom table names that match another model key produce
the intended foreign keys.

-
[#&#8203;11718](https://redirect.github.com/better-auth/better-auth/pull/11718)
[`1d95ebf`](1d95ebf3fe)
Thanks [@&#8203;bytaesu](https://redirect.github.com/bytaesu)! - Fix
missing device sessions and failed automatic session switching after
cache eviction when `storeSessionInDatabase` is enabled and
`preserveSessionInDatabase` is disabled. Automatic switching now follows
the order of held sessions, and large lists or sessions whose users no
longer exist no longer cause valid sessions to disappear.

-
[#&#8203;10266](https://redirect.github.com/better-auth/better-auth/pull/10266)
[`c68b2cd`](c68b2cd8a5)
Thanks [@&#8203;shiminshen](https://redirect.github.com/shiminshen)! -
Projects that enable `exactOptionalPropertyTypes` can use the
`oauthProvider()` and `mcp()` plugins again. Since 1.7.0, adding either
plugin to `betterAuth()` failed to type-check with a TS2322 error.

-
[#&#8203;11637](https://redirect.github.com/better-auth/better-auth/pull/11637)
[`2627237`](2627237fae)
Thanks
[@&#8203;gustavovalverde](https://redirect.github.com/gustavovalverde)!
- Projects using the organization plugin with `skipLibCheck: false` no
longer get `TS2536: Type '"role"' cannot be used to index type ...` from
`crud-members.d.mts`. The `role` returned by `getActiveMemberRole` is
now typed as the organization's role names directly. Projects with
`skipLibCheck: true` (the default in most templates) were unaffected.

-
[#&#8203;10866](https://redirect.github.com/better-auth/better-auth/pull/10866)
[`3d1f008`](3d1f008ae3)
Thanks [@&#8203;heliohm](https://redirect.github.com/heliohm)! - The
organization plugin no longer pulls every zod locale into server
bundles.

-
[#&#8203;11626](https://redirect.github.com/better-auth/better-auth/pull/11626)
[`67743ed`](67743ed6e8)
Thanks
[@&#8203;gustavovalverde](https://redirect.github.com/gustavovalverde)!
- Password resets and password changes no longer keep the new password
when revoking the user's sessions fails. With
`revokeSessionsOnPasswordReset` or `revokeOtherSessions`, database
sessions are revoked and the password is saved in one transaction when
transactions are enabled for the adapter, so a failure leaves the old
password and sessions in place. Sessions in secondary storage are still
removed after commit, on a best-effort basis. This covers
`/reset-password`, the email OTP and phone number reset endpoints, and
`/change-password`. `onPasswordReset` now runs after sessions are
revoked, so a throwing callback no longer leaves them active, and a
callback that lists the user's sessions no longer sees the revoked ones.

-
[#&#8203;10698](https://redirect.github.com/better-auth/better-auth/pull/10698)
[`f0ce580`](f0ce580fbd)
Thanks
[@&#8203;jashkarangiya](https://redirect.github.com/jashkarangiya)! - If
you set the phone number plugin's `verifyOTP` option,
`/phone-number/reset-password` now checks the code with it, as
`/phone-number/verify` already does. Before, password reset always
compared the code with the one Better Auth generated, so apps that
verify codes through a provider such as Twilio Verify could not reset
passwords. If your `sendPasswordResetOTP` sends the code Better Auth
generates, make sure `verifyOTP` accepts that code. Apps that don't set
`verifyOTP` are unaffected.

-
[#&#8203;11646](https://redirect.github.com/better-auth/better-auth/pull/11646)
[`07a0938`](07a09389ef)
Thanks
[@&#8203;gustavovalverde](https://redirect.github.com/gustavovalverde)!
- A failed password reset no longer spends the reset link or OTP.
`/reset-password`, `/email-otp/reset-password` and
`/phone-number/reset-password` now check the token or code without
consuming it, validate and hash the new password, then consume it in the
same transaction as the session revocation and password write. A
rejected password, such as one refused by `haveIBeenPwned`, always
leaves the link or OTP usable. A later failure, such as a failed session
revocation or password write, also leaves it usable when the adapter's
transactions are enabled and verification values are stored in the
database (the default without secondary storage, or
`verification.storeInDatabase: true`). Wrong codes still count against
the OTP attempt limit.

-
[#&#8203;11643](https://redirect.github.com/better-auth/better-auth/pull/11643)
[`92dfcea`](92dfceaa14)
Thanks
[@&#8203;gustavovalverde](https://redirect.github.com/gustavovalverde)!
- A sign-up that fails after its session is created no longer leaves
that session in secondary storage. With `storeSessionInDatabase` enabled
and `preserveSessionInDatabase` off, the secondary-storage copy is
written only after the sign-up commits, and listing a user's sessions
now reads the database, so a session whose cached copy failed to write
is still listed and revoked. With other secondary-storage settings,
sign-up, passkey registration and SSO sign-in with `resolveUser` keep
the session write inside their transaction, so a storage failure rolls
back the new user, passkey or account instead of keeping them without a
session. A session revoked by a `session.create.after` database hook
also stays revoked.

-
[#&#8203;11488](https://redirect.github.com/better-auth/better-auth/pull/11488)
[`e15625f`](e15625ff38)
Thanks [@&#8203;Bekacru](https://redirect.github.com/Bekacru)! -
SvelteKit 3 projects can now install Better Auth without
`--legacy-peer-deps`. The `@sveltejs/kit` peer range now includes
`^3.0.0`; SvelteKit 2 projects are unaffected.

- Updated dependencies
\[[`4175b34`](4175b34a8f),
[`435645e`](435645e5eb),
[`369176e`](369176e7f6),
[`0cfe07d`](0cfe07dccd),
[`9904b29`](9904b29ece),
[`e78f15a`](e78f15aa31),
[`60525e0`](60525e08fd),
[`8133265`](813326536c),
[`ea85d13`](ea85d133d6),
[`916ef5c`](916ef5c530),
[`1d95ebf`](1d95ebf3fe),
[`6214610`](62146108c7),
[`67743ed`](67743ed6e8),
[`c46d2a6`](c46d2a6ac4),
[`92dfcea`](92dfceaa14),
[`a9f455d`](a9f455d586),
[`9725f1b`](9725f1b361)]:
-
[@&#8203;better-auth/core](https://redirect.github.com/better-auth/core)@1.7.8
-
[@&#8203;better-auth/drizzle-adapter](https://redirect.github.com/better-auth/drizzle-adapter)@1.7.8
-
[@&#8203;better-auth/kysely-adapter](https://redirect.github.com/better-auth/kysely-adapter)@1.7.8
-
[@&#8203;better-auth/memory-adapter](https://redirect.github.com/better-auth/memory-adapter)@1.7.8
-
[@&#8203;better-auth/mongo-adapter](https://redirect.github.com/better-auth/mongo-adapter)@1.7.8
-
[@&#8203;better-auth/prisma-adapter](https://redirect.github.com/better-auth/prisma-adapter)@1.7.8
-
[@&#8203;better-auth/telemetry](https://redirect.github.com/better-auth/telemetry)@1.7.8

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - "before 6am every weekday"
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these
updates again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend Renovate
CLI](https://redirect.github.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xODYuNCIsInVwZGF0ZWRJblZlciI6IjQ0LjE5Mi4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJhdXRvbWF0aW9uIl19-->

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-10-28 19:24:36 +00:00