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>
## Description
`generateTypes` copied each bundled package into `dist/_types/<import
name>`. In `@mastra/core`, `@ai-sdk/provider` 1.1.3, 3.0.19 and 4.0.34
all went to `_types/@ai-sdk_provider`, and `@ai-sdk/provider-utils`
2.2.8, 4.0.62 and 5.0.69 to `_types/@ai-sdk_provider-utils`. The last
write won, file by file. In the published 1.81.0 that left provider
1.1.3, so the bundled v6/v7 provider copies import names that don't
exist there, and those types become `any` under `skipLibCheck`.
The copy tracking (`visited`) was also keyed by source path. An npm
alias that links to an already-copied package was skipped, while its
importer still got rewritten to the alias directory. That's why sharing
`visited` across files broke `@mastra/memory` in #28731.
Now each directory is named after the installed package and version, and
copies are tracked by destination for the whole run, so each destination
is written once and file order doesn't matter.
```ts
// dist/_types/@ai-sdk_openai-v6/dist/index.d.ts (before)
import { LanguageModelV3 } from '../../@ai-sdk_provider/dist/index.js'; // holds 1.1.3: no LanguageModelV3
// dist/_types/@ai-sdk_openai@3.0.132/dist/index.d.ts (after)
import { LanguageModelV3 } from '../../@ai-sdk_provider@3.0.19/dist/index.js';
```
Checked by type-checking core's built declarations with `skipLibCheck:
false`: every error from the overlap is gone (800 errors down to 711,
the rest also happen on `main`). The full CI build passes,
`e2e-tests/pkg-outputs` passes (1265), and `@mastra/memory` and
`mastracode/sdk` typecheck.
The new test runs `generateTypes` on a small pnpm-style layout with two
versions of one package plus an alias, and type-checks a consumer. It
fails on `main` for both the overwrite and the alias. To run it in CI I
removed `packages/_types-builder` from the excluded vitest projects.
Every package that bundles types gets renamed `_types` directories, but
only core had two versions of one package, so the changeset only covers
core.
Not fixed here: `@internal/external-types` merges `ai@4` and
`provider-utils@3` into one file that imports v1 and v2 names from a
single `@ai-sdk/provider`, so `LanguageModelV2ToolResultOutput`,
`LanguageModelV2ToolResultPart` and `SharedV2ProviderOptions` still
don't resolve. That happens before types-builder runs.
## Related issue(s)
Fixes#28732
## Type of change
- [x] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update
- [ ] Code refactoring
- [ ] Performance improvement
- [x] Test update
## Checklist
- [x] I have linked the related issue(s) in the description above
- [ ] I have made corresponding changes to the documentation (if
applicable)
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] I have addressed all Coderabbit comments on this PR
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## ELI5
When a project uses different versions of the same package, their type
files could overwrite each other. This change stores each installed
package version separately and adds a test to check that consumers
resolve the intended types.
## Changes
- `generateTypes` now includes the installed package name and version in
the bundled type directory when the package has a version.
- Copy tracking now spans the full generation run and deduplicates
copies by destination path.
- Added an integration test with two versions of a dependency, a nested
dependency, and an npm alias. The test generates bundled types and
type-checks a consumer.
- Added a test script and Vitest configuration for `_types-builder`, and
included the package in Vitest project discovery.
## Validation
The author reports that the new test fails on `main` because of the
overwrite and alias issues. The author also reports passing CI build,
`e2e-tests/pkg-outputs`, and typechecks for `@mastra/memory` and
`mastracode/sdk`.
The author reports that core declaration type-check errors decreased
from 800 to 711 with `skipLibCheck: false`. The author says the
remaining errors also occur on `main`.
The author notes that unresolved v1 and v2 names in merged
`@internal/external-types` declarations are not fixed by this change.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Three suites in `mastracode/` were re-enabled for the affected-unit CI
job when #24334 restored `mastracode/*/vitest.config.ts` to
`PROJECT_GLOBS`. They had not been running, so their failures were
latent; this makes them pass.
## Why these were invisible until now
Before #24334 the root config pointed at `mastracode/vitest.config.ts`,
which no longer exists. The affected-unit job still *received*
`mastracode/**` test paths, but no matching project resolved and the job
runs `--passWithNoTests`, so it reported success while running nothing.
The first PR to touch `packages/core` after the glob fix (#24336) became
the first run where these suites actually executed.
## Fixes
**`sandbox-filesystem` conformance — Linux `spawn E2BIG`**
The test bound `maxTestFileSize` at 128 KiB. Write payloads travel as
base64 inside a single `sh -c` argument (`sandbox-filesystem.ts:298`),
and Linux caps a single argument at `MAX_ARG_STRLEN` (128 KiB). base64
inflates the payload by 4/3, so 128 KiB became a ~171 KiB argument and
the write failed before the shell ran. macOS only bounds the whole
argument list (~1 MB), which is why this never reproduced locally.
Measured in `node:22-alpine` with the same command shape:
| payload | `sh -c` argument | result |
| --- | --- | --- |
| 128 KiB | 174,835 chars | `E2BIG` |
| 64 KiB | 87,455 chars | OK |
Lowered to 64 KiB. The comment now records that this is a real limit of
the write path (base64 in one argument), not just a smaller test
fixture.
**`mastracode/web` — cannot resolve its dependencies**
The new glob also matched `mastracode/web/vitest.config.ts`. That
directory is a standalone private app, not a pnpm workspace member, so
its dependencies are never installed and the suite failed with `Cannot
find package 'hono'`. Added to the existing `EXCLUDED_DIRS` list, which
is where non-project directories already live.
**`goal-parity` — missing `addUserMessage` mock**
The command context has required `addUserMessage` since the goal
reminder moved to the local render path (`commands/types.ts:35`,
provided in `mastra-tui.ts:1325`). The test's context literal is cast
`as any`, so the missing mock only surfaced at runtime: `TypeError:
ctx.addUserMessage is not a function`.
## Verification
- `sandbox-filesystem.conformance.test.ts` — 58/58 pass.
- `goal-parity.test.ts` — 5/5 pass (was 1 failing).
- Linux argv proof above, run in `node:22-alpine`.
- Excluding `mastracode/web`: `vitest list --project
unit:mastracode-web` goes from `Cannot find package 'hono'` to `No
projects matched`, while `unit:mastracode-core` still resolves normally.
- `prettier --check` and `git diff --check` clean.
- No changeset: test bounds and root test tooling are not published
behavior.
## Not covered
`mastracode/factory` `custom-board-runtime.test.ts` also fails on CI
(`CLIENT_CLOSED` while a deferred decision retries), but it passes 3/3
locally, so it is left alone rather than changed unverified.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## ELI5
This PR fixes three tests that failed after test discovery was restored.
It reduces oversized test data, skips an unrelated app, and adds a
missing test mock.
## Changes
- Reduced `sandbox-filesystem` `maxTestFileSize` from 128 KiB to 64 KiB
to prevent Linux `spawn E2BIG` errors.
- Excluded `mastracode/web` from Vitest discovery because its
dependencies are not in the pnpm workspace.
- Added the missing `addUserMessage` mock to the `goal-parity` test
context.
## Verification
- Targeted tests pass.
- Formatting and diff checks pass.
- The unrelated `mastracode/factory` CI failure was not changed because
it passes locally.
- No changeset was added.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Co-authored-by: yoko-reviewer[bot] <324360165+yoko-reviewer[bot]@users.noreply.github.com>
## Description
Add runnable workflow cases to the Vercel preview so reviewers can
inspect complex graphs and execution history before the canvas changes
in #24030 merge.
Opening the preview
├─ **was** — three workflows and six saved runs
└─ **now** — nine workflows and 25 runs produced by real
execution
| Workflow | What to inspect |
| --- | --- |
| Order fulfillment | Parallel checks, approval/resume, nested foreach
with parallel steps, dispatch failure, cancellation, debug pause |
| Delayed report | An eight-second wait and completed timing |
| Collection processing | Empty, single, repeated and Unicode items,
partial iteration failure, a tool returning null/false/zero/empty data |
| Delivery routing | Three conditional paths with all, one or no matches
|
| Retry window | Do-while, early exit, zero/computed delays,
past/computed deadlines |
| Agent review | A real agent step with a seeded input-processor
tripwire |
The existing request review, document batch and countdown workflows
remain available. Saved histories include success, failure, suspension,
pause, cancellation and tripwire. Start a new run to inspect live
running and waiting states.
Seeding runs once per preview process, takes about 12 seconds locally,
and makes no network calls. Agent review defaults to the tripwire input;
other prompts use the configured provider and require an API key. An
early `bail()` is stored as success by the engine, with later steps
unstarted.
The integration suite uses real Mastra execution and in-memory storage.
Existing preview regressions share its seed setup and 30-second hook
timeout, so the full seed runs once. It checks saved statuses, outputs,
parallel timing, explicit approval and reseeding without overwriting a
review decision. It also caught skipped branches leaking undefined
results; those are filtered out. Run it with `pnpm vitest run --project
unit:packages/playground/vercel-preview`; it is included in the normal
unit project discovery.
Full Vercel deployment and successful model generation remain unverified
locally.
> ██████████████████ **source** `+540 −1`
> █████████ **tests** `+268 −70`
> █ **test configuration** `+14`
## Related issue(s)
Split from #24030 so the preview workflows can merge first.
## Type of change
- [x] Bug fix (non-breaking change that fixes an issue)
- [x] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update
- [ ] Code refactoring
- [ ] Performance improvement
- [x] Test update
## Checklist
- [x] I have linked the related issue(s) in the description above
- [ ] I have made corresponding changes to the documentation (if
applicable)
- [x] I have added tests that prove my fix is effective or that my
feature works
- [ ] I have addressed all Coderabbit comments on this PR
## Summary
The `packages/playground` and `packages/playground-ui` Vitest suites
were never running in CI. The root `vitest.config.ts` discovers test
projects and the CI unit-test job selects them with `--project
'unit:*'`, but both packages were in the discovery exclusion list — so
~1,210 tests were silently skipped on every PR. This wires both suites
into the pipeline and fixes the failures that surfaced once the
playground suite actually executes.
## What changed
**Make the suites discoverable and CI-selectable**
- Removed `packages/playground` and `packages/playground-ui` from the
`EXCLUDED_DIRS` set in the root `vitest.config.ts`.
- Named the playground project `unit:packages/playground` (in its
existing `vitest.config.ts`) so it matches the CI `--project 'unit:*'`
glob.
- Added a `vitest.config.ts` for `playground-ui` named
`unit:packages/playground-ui` (it previously had no vitest config and
ran off `vite.config.ts`, so root discovery — which globs for
`vitest.config.ts` — could not find it).
- Added the `test`/`test:run` scripts and pinned `vitest` + `jsdom`
devDeps for the private `@internal/playground` package so `pnpm --filter
./packages/playground test` works.
**Fix the playground test failures exposed by running under jsdom 27**
- `conversation-panel.test.tsx`: wrapped the test tree in a real
`QueryClientProvider` (the component pulls in `useCurrentUser` via
`StreamChatProvider`). No mocking of our own hooks.
- `agent-channels-page.msw.test.tsx`: replaced a brittle `.animate-spin`
class selector with the Spinner accessible `role="status"` / name
"Loading", which also removes a render-timing race.
## Why
Without this, regressions in the playground UI and the playground
component library ship undetected — these are the primary (MSW-based)
test suites for those packages per their `AGENTS.md`, but CI was not
executing them.
## Test plan
- `pnpm --filter ./packages/playground test` → 129 files / 924 tests
pass.
- `pnpm --filter ./packages/playground-ui test` → 35 files / 286 tests
pass.
- `pnpm vitest list --project 'unit:*'` (the exact CI selection) now
enumerates both `unit:packages/playground` (924 tests) and
`unit:packages/playground-ui` (286 tests).
- `typecheck` passes for both packages.
## Notes
- No changeset: changes are test files, test configuration, and
devDeps/scripts in a private package — no shipped behavior or public API
change.
- These suites now share the CI `unit:*` shards, so a future flake here
would gate unrelated PRs. They were green across repeated full runs;
worth watching.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## ELI5
This PR adds two packages' test suites to the CI pipeline so they get
automatically checked whenever code changes. These tests weren't being
run in CI before, and when they were enabled, some tests had to be fixed
to work properly.
## Changes
### Test Infrastructure Updates
- **Root vitest config**: Removed `packages/playground` and
`packages/playground-ui` from the excluded directories list so tests in
these packages are now discovered and run in CI
- **playground vitest config**: Added test suite naming
(`unit:packages/playground`), set environment to Node, and specified
test file patterns
- **playground-ui vitest config**: New configuration file added with
React plugin, path aliases, test environment setup, and suite naming
(`unit:packages/playground-ui`)
### Test Suite Enablement
- **playground package.json**: Added `test` and `test:run` scripts, and
pinned `vitest` and `jsdom` versions in devDependencies to support test
execution
### Test Fixes
Fixed test failures that were exposed when running under jsdom 27:
- **conversation-panel.test.tsx**: Wrapped the rendered component in a
React Query `QueryClientProvider` context that was required by
components using `useCurrentUser` via `StreamChatProvider`
- **agent-channels-page.msw.test.tsx**: Updated loading state assertion
from checking for a `.animate-spin` CSS class selector to using the more
robust accessibility role `status` with name "Loading" to avoid
timing/race issues
## Test Coverage
The changes enable 1,210 total tests across both packages to run in CI:
- playground: 924 tests across 129 files
- playground-ui: 286 tests across 35 files
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Co-authored-by: Mastra Code (anthropic/claude-opus-4-8) <noreply@mastra.ai>
## Summary
Fixes the issue where Vitest doesn't properly discover nested projects
in workspace configs (https://github.com/vitest-dev/vitest/issues/8544).
## Changes
- Replace hardcoded project list in `vitest.config.ts` with dynamic
discovery using `globSync`
- Automatically detect configs with nested `projects:` arrays by reading
file content
- For nested projects (core, evals, schema-compat), import the config
and flatten with correct `root` path
- Add `sequence.groupOrder` to evals projects to fix Vitest 4 conflict
with different `maxWorkers` settings
## How it works
1. Globs for all `vitest.config.ts` files in the monorepo directories
2. Reads each config to detect if it has a `projects:` array
3. For simple configs, uses the directory path directly
4. For nested projects, imports the config and expands each project with
the correct root
## Test Plan
- `pnpm vitest list` now works without the `sequence.groupOrder` error
- `pnpm vitest run --project 'unit:packages/schema-compat:v4'` passes
- `pnpm vitest run --project 'unit:packages/memory'` passes
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Chores**
* Adjusted test execution ordering across Vitest projects.
* Added dynamic project discovery for Vitest so test suites are
auto-detected and loaded at runtime, supporting both single-folder and
nested project setups.
* Improved handling for configs that cannot be loaded at runtime by
falling back to directory-based discovery with a warning.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Mastra Code <noreply@mastra.ai>
## Summary
This PR reorganizes the test infrastructure across the monorepo by
introducing namespaced Vitest projects, proper test classification, and
a dedicated e2e CI job.
### Vitest project namespacing
- Rename all vitest project names from generic `'unit'` to
`'unit:<package-path>'` (e.g. `'unit:packages/core'`,
`'unit:auth/auth0'`) across ~100 packages
- Enables targeted test filtering with `--project 'unit:*'` glob
patterns in CI and locally
- Update CI workflow to use `'unit:*'` and `'typecheck:*'` patterns
### Test classification
- **Store tests** → `e2e:stores/*` (require external services like
Postgres, Redis, etc.)
- **RAG tests** → `e2e:packages/rag` (require embeddings API)
- **Evals LLM scorer tests** → `e2e:packages/evals` (require LLM API
keys)
- **pubsub tests** → `e2e:pubsub/*` (require Google Cloud)
- Add `isolate: false` to unit test configs for faster execution
### Core test reorganization
Split `agent.test.ts` (~7.5k lines) into focused unit test modules:
- `callbacks.test.ts` — callback/hook behavior
- `input-processors.test.ts` — input processing logic
- `instructions.test.ts` — instruction/system prompt handling
- `memory-metadata.test.ts` — memory metadata tests
- `save-and-errors.test.ts` — save behavior and error handling
- `title-generation.test.ts` — title generation logic
Renamed integration tests to `*.e2e.test.ts` for clarity (e.g.
`azure.integration.test.ts` → `azure.e2e.test.ts`).
### CI changes
- Add dedicated `e2e-test` job in `vitest-changed.yml` with shard-based
matrix
- Normalize shard names (`/` → `-`) for GitHub artifact compatibility
- Wire e2e job into `merge-reports` dependency chain
### Test fixes
- `tsx` → `tsx@latest` in MCP spawn calls to fix version resolution
- Rewrite `deployers/cloud` mock patterns for test reliability
- Skip network-dependent `mcp-registry-registry` tests (apitracker,
mcprun)
- Fix codemod `typeParameters` compatibility check
- Add `cwd` to CLI execa call
### Test plan
- Verified `pnpm vitest run --project 'unit:*'` runs only unit tests
- Verified `pnpm vitest run --project 'e2e:*'` runs only e2e tests
- Verified all extracted agent test files pass independently
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Tests**
* Added comprehensive test suites for agent features including
callbacks, input processors, instructions, memory handling, and title
generation across v1 and v2 implementations
* Reorganized test infrastructure with dedicated end-to-end test
workflows separate from unit tests
* Enhanced test isolation and parallel execution with named test
projects
* **Chores**
* Restructured test configuration across all packages for improved
organization and execution
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Mastra Code <noreply@mastra.ai>
Add support for commonjs (require)
- add require statements to all package.json to enable commonjs
- add bundle magic to `mastra dev` and `mastra build` to handle commonjs
requires
- updated github action to lint our bundle outpus and package.jsons
These have been deprecated for a while now, so it's safe to delete the
files
Co-authored-by: Your Name <you@example.com>
Co-authored-by: Ward Peeters <ward@coding-tech.com>