mirror of
https://github.com/mastra-ai/mastra.git
synced 2026-11-17 08:44:46 +00:00
25 commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
d60ba71be0 | chore: version - exit prerelease mode | ||
|
|
05a6931471 |
chore: version packages (alpha) (#30172)
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 ## @mastra/client-js@1.60.0-alpha.12 ### Minor Changes - Allow `querySpans()` to sort by `model` or `provider`. ([#30096](https://github.com/mastra-ai/mastra/pull/30096)) ```ts orderBy: [{ field: 'model', direction: 'asc' }]; ``` ### Patch Changes - The generated route types for scores now include the `SCORER` and `PROCESSOR` entity types, matching the entity types experiments can emit. ([#30145](https://github.com/mastra-ai/mastra/pull/30145)) - Add span-local error counts. ([#30088](https://github.com/mastra-ai/mastra/pull/30088)) - Updated dependencies [[`56f654f`]( |
||
|
|
f9088d8510 |
feat(mcp-apps-components): accept the editor's widget shapes in chat-authored dashboards (#30192)
Dashboards authored in chat rejected several widgets the dashboard
editor can build, so a model couldn't recreate what a user had in the
editor. This widens the shared option schemas in `@mastra/playground-ui`
and the renderers behind them, and the chat authoring schema in
`@mastra/mcp-apps-components` picks the changes up.
KPIs can now combine values (`ratio`, `minus`, `max`, `coalesce`), read
score, trace and span aggregates, and use the `duration`, `percent` and
`score` formats. Percentiles come through trace/span measures, which
give one whole-range value (metric percentiles are always bucketed, so
they can't make a single KPI figure). KPIs now also request the previous
window, so combined values show a change:
```ts
{
label: 'Error rate',
format: 'percent',
value: {
ratio: {
of: { traceAggregate: { measure: 'errorCount', compare: 'previousWindow' } },
over: { traceAggregate: { measure: 'count', compare: 'previousWindow' } },
},
},
}
// p95 latency
{ label: 'p95 latency', format: 'duration', value: { traceAggregate: { measure: 'duration.p95', compare: 'previousWindow' } } }
```
Line charts can plot `scoreTimeSeries`, and charts accept `blue`,
`orange`, `pink`, `yellow`, `red` and `purple`, all mapped to existing
data-viz tokens. KPI `icon` and `detail`, series `color` and table
`emptyMessage` are now optional: series without a color take one from a
palette by position, and tables without a message show "No data". Metric
types in the discovery API (counter vs. histogram) are not part of this
PR.
Tested with new widget tests that open dashboards through the real tool:
p95 latency and error-rate KPIs compared with the previous window, plus
a score line chart and a table that set no colors or empty message. The
KPI test fails against the old KPI request plan. Typecheck, lint and the
existing suites pass in both packages.
---------
Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
|
||
|
|
3a6ca42696 |
chore: version packages (alpha) (#30026)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> |
||
|
|
7947e18c2c |
feat(playground-ui): let hosts add their own buttons to dashboard widgets (#30043)
Dashboard widgets only knew how to show a pin button:
`DashboardRenderer` took `onPin`/`isPinned` and `StatelessWidget` took
`pin`, so any other host button meant changing the renderer. This
replaces them with a host `actions` slot, so apps embedding widgets (the
Metrics page, the MCP observability widget, other projects) can compose
whatever buttons they need without rebuilding the grid.
Buttons are built with the new `MetricsCard.Action`. The card is a
`group/metrics-card`, so each button picks its own visibility with
classes: hidden until hover/focus, or always shown (e.g. a pinned card's
unpin). Host buttons sit after the card's drilldown and alert buttons.
```tsx
<DashboardRenderer
definition={definition}
scope="project"
widgetActions={widget => {
const isPinned = pinnedIds.includes(widget.id);
return (
<MetricsCard.Action
label={`${isPinned ? 'Unpin' : 'Pin'} ${widget.title ?? 'widget'}`}
onClick={() => savePin(widget, !isPinned)}
className={isPinned ? undefined : 'hidden group-hover/metrics-card:inline-flex group-focus-within/metrics-card:inline-flex'}
>
{isPinned ? <PinOffIcon /> : <PinIcon />}
</MetricsCard.Action>
);
}}
/>
```
This is breaking for `@mastra/playground-ui` consumers:
`ChartCard.persistentActions`, the `reveal` prop on
`MetricsCard.Actions`, `PinAction` and `WidgetPin` are gone (see the
changeset).
`@mastra/mcp-apps-components` moves its pin button to the new API and
adds an optional `onConfigure` to `observabilityWidgetHost`. It works
like `onPin`: when passed, each widget shows a settings button that
gives the host the widget plus the date preset, range and filters it is
drawn with, so the host can open its own dialog.
```tsx
observabilityWidgetHost({
resourceUri: 'ui://mastra/observability-widget',
onConfigure: ({ widget, datePreset, filters }) => openWidgetSettings(widget, datePreset, filters),
});
```
Tested with the playground-ui dashboard/metrics suites, the
mcp-apps-components suite (including new `onConfigure` host and app
tests), typecheck of playground-ui, playground and mcp-apps-components,
and a manual check in Storybook (`Dashboards/DashboardRenderer/Host
actions`) of hover, keyboard focus and pinned states.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## ELI5
Dashboard hosts can now choose which buttons appear on each widget.
Observability widgets can also open host-controlled settings.
## Changes
- Added `DashboardRenderer.widgetActions` for host-provided actions.
- Added `MetricsCard.Action` and `onCardHover` for hover, focus, pinned,
and touch behavior.
- Placed host actions after drilldown and alert actions.
- Preserved host actions when a widget later renders an error.
- Added `observabilityWidgetHost.onConfigure`, which receives the
widget, date preset, custom range, and filters.
- Added request validation, documentation, tests, and Storybook
coverage.
- Kept hover-only actions keyboard-focusable and reachable on touch
devices.
## Breaking changes
Removed `onPin`, `isPinned`, `pin`, `persistentActions`, `reveal`,
`PinAction`, and `WidgetPin`. Consumers must use `widgetActions` with
`MetricsCard.Action`.
## Scope
36 files changed, with 717 additions and 290 deletions.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
|
||
|
|
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> |
||
|
|
571afaa5ee |
feat(mcp-apps-components): export model-facing draft schemas for saving dashboards (#29832)
Tools that save dashboards a model writes currently take each widget as an open object (`z.record(z.string(), z.unknown())`). The model gets no guidance on the shape, and bad widgets are only caught by hand after the call. #29913 exported the widget schema and `toObservabilityWidget`. This adds `createObservabilityDraftSchemas`, which builds the widget and dashboard schemas from one catalog and lets a service offer only the choices it accepts: ```ts import { createObservabilityDraftSchemas, toObservabilityDashboard, toObservabilityWidget, } from '@mastra/mcp-apps-components/dashboards'; const schemas = createObservabilityDraftSchemas( { metricNames }, { kinds: ['kpis', 'timeseries', 'table'], dashboardFilters: false }, ); const addWidget = createTool({ id: 'addWidget', inputSchema: schemas.widget, execute: async widget => saveWidget(toObservabilityWidget(widget)), }); const createDashboard = createTool({ id: 'createDashboard', inputSchema: schemas.dashboard, execute: async dashboard => saveDashboard(toObservabilityDashboard({ dashboard }).dashboard), }); ``` `kinds` and `dashboardFilters: false` leave those choices out of the JSON schema the model sees, and reject them if it writes them anyway. `toObservabilityWidget` keeps a widget's `id` when the model gives one, so pinned widgets stay addressable, and when it throws, the error's `cause` is the `ZodError` with draft paths. Like `toObservabilityDashboard`, it checks against the default schemas, so outside a tool built from your schemas, check the draft against them first. Invalid drafts are rejected before `execute` runs, with paths into what the model wrote: ``` - timeseries.series.1.value.metricTimeSeries.aggregation: Invalid option: … - rows.0.widgets.0.kpis.tabs.0: another view is already labelled 'Runs' ``` The existing widget and dashboard schemas change in two ways. The dashboard tool's input schema is about 28% smaller (11.4k tokens, down from 15.9k), because metric and score filters are now defined once instead of at every read. And a widget whose tabs share a label is now rejected when the tool is called, instead of opening as an error card. Every draft that passes now converts to a widget that passes `strictDashboardWidgetSchema`. Worth knowing: `@mastra/schema-compat`'s OpenAI, Anthropic and Gemini layers turn a named schema wrapped in `.optional()` into an empty object. Here that would have left OpenAI strict mode unable to write any valid widget. This PR puts the name on the optional field itself to avoid it, and a test runs the schema through all three layers to keep it that way. The schema-compat bug affects any tool using that pattern; there's no issue filed for it yet. Tests run against a real MCP server over HTTP. They include a save-tool server set up like the example above, and a round trip of every Studio widget through the strict schema. The `./dashboards` entry stays React-free, at about 9 KB gzipped when minified, the same as before. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## ELI5 This PR gives models clear rules for writing dashboard drafts. It checks drafts before conversion and reports where they need changes, so invalid dashboards are less likely to reach storage. ## Summary - Add `createObservabilityDraftSchemas` to build widget and dashboard draft schemas from one catalog. Options can limit widget kinds and omit dashboard filters. - Reuse named metric and score filter schemas to reduce repeated schema definitions. - Check widget drafts against renderer rules, including view options, table columns, and duplicate tab labels. Report issues with paths into the draft. - Preserve supplied widget IDs during conversion. Include the `ZodError` as the cause when widget conversion fails. - Export the new schema factory and types from the package entry point and dashboard module. - Add tests for schema restrictions, validation, provider compatibility transformations, and strict stored-widget validation. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: YJ <yj@example.com> Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com> |
||
|
|
e7aa4f00e1 |
feat(mcp-apps-components): add a strict schema for stored dashboard definitions (#29802)
Core's `dashboardDefinitionSchema` checks a dashboard's structure and
queries, but accepts any widget kind and treats each view's `options` as
opaque, so a definition can pass it and still render an error in place
of a widget. The full check only ran at render time inside
playground-ui's React widget registry, which services that store
dashboards can't depend on.
This adds a `@mastra/mcp-apps-components/dashboards` subpath with
`strictDashboardDefinitionSchema`, `strictDashboardWidgetSchema` and
handwritten `StrictDashboard*` types. They only accept the built-in
widget kinds (`kpis`, `table`, `timeseries`, `scores`), check each
view's options and table column options against the kind's schema, and
run each kind's own checks at both org and project scope. Problems come
back as zod issues with paths. Option errors point into the options, and
problems a kind finds point at the view, with a message saying what's
wrong. The parsed data is the input unchanged. Definitions core has
already parsed also pass. Dashboards with custom widget kinds should
keep using core's schema. They're meant to be called where definitions
are stored, not in request-body schemas, since their input type is
`unknown` and their JSON schema is empty.
```ts
import { strictDashboardDefinitionSchema } from '@mastra/mcp-apps-components/dashboards';
import type { StrictDashboardDefinition } from '@mastra/mcp-apps-components/dashboards';
const definition: StrictDashboardDefinition = strictDashboardDefinitionSchema.parse(body.definition);
```
The schema uses each kind's own option schemas and checks from
playground-ui, bundled at build time, and mirrors the renderer's
per-view loop. A parity test runs that loop against playground-ui's
`prepareWidget` for every Metrics dashboard widget and every broken
case, at both scopes, so the two can't drift. A follow-up PR will move
the loop into playground-ui so both use one module. The handwritten
types are pinned to the kinds' inferred types in a `.test-d.ts` file,
run in CI by a new `typecheck:packages/mcp-apps-components` vitest
project. The subpath doesn't load React or the package's bundled app
HTML.
To test, run `pnpm --filter @mastra/mcp-apps-components test` and `pnpm
vitest run --project 'typecheck:packages/mcp-apps-components'`.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## ELI5
This change adds checks for saved dashboards before they are stored. The
checks find problems in built-in widgets and show where each problem is,
so it can be fixed.
## Summary
- Adds the `@mastra/mcp-apps-components/dashboards` subpath with strict
schemas and TypeScript types for dashboards that use the built-in
`kpis`, `table`, `timeseries`, and `scores` widgets.
- Validates view options and table-column options, and runs
widget-specific checks at organization and project scope. The schemas
reject columns on non-table widgets and report issues with paths.
Successful parsing preserves the input without adding defaults.
- Adds schema, type, and renderer-parity tests. Adds the dashboard entry
point to package builds and adds a Vitest project for type tests.
- Documents that these schemas validate stored definitions, not request
bodies or model-generated input. Custom widget kinds should continue to
use core’s schema.
**Change size:** 13 files changed; 885 lines added and 4 removed.
**CI, build, and test results:** not available.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: YJ <yj@example.com>
Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
|
||
|
|
123f0ea4f9 |
feat(mcp-apps-components): export the observability widget's input schema and converter (#29913)
## Summary
`@mastra/mcp-apps-components` exported a schema and converter for a
whole observability dashboard (`showObservabilityDashboard`), but not
for a single widget. A tool that adds one widget to a saved dashboard
(for example the platform's `createDashboard` / `addWidgetToDashboard`)
therefore had to take the stored `DashboardWidget` shape (`id`, `kind`,
`views[].queries`). Models write the authoring shape they learned from
`showObservabilityDashboard` instead (`{ title, table: { groupBy,
columns } }`), and the call fails.
This PR exports the widget-level pieces:
- `createObservabilityWidgetInputSchema(catalog?)`: one widget's input
schema, with metric names limited to the catalog like the dashboard
schema.
- `observabilityWidgetInputSchema`: the same with free metric names.
- `toObservabilityWidget(draft)`: checks one widget and converts it to
the stored `DashboardWidget` the same way `toObservabilityDashboard`
does (reads gathered into queries, fresh id, full width by default). It
throws `The widget is invalid: …` with paths relative to the widget.
The dashboard schema is now built from the widget schema, so the two
can't drift. The JSON schema advertised for `showObservabilityDashboard`
is unchanged.
## Test plan
- [x] New tests: one widget converts like the same widget inside a
dashboard; an invalid widget is refused with a widget-relative path; the
widget schema lists the catalog's metric names.
- [x] `pnpm --filter @mastra/mcp-apps-components test` (61 passed),
`typecheck`, `lint`
Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
|
||
|
|
7c4dd88400 |
chore: version packages (alpha) (#29889)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> |
||
|
|
3f1d3a38df |
fix: transparent menus and blocked pin button in observability widgets (#29906)
Two small bugs in the observability widget.
Menus in the widget (like the chart's view picker) rendered with a
transparent background, so the chart showed through. The widget's
stylesheet strips the card surface from every `.bg-card.rounded-xl`
element, and menus use the same classes. Since popups portal to `body`,
scoping the rule to `#root` fixes it:
```css
/* before */
.bg-card.rounded-xl { background-color: transparent; ... }
/* after */
#root .bg-card.rounded-xl { background-color: transparent; ... }
```
The other one: with the view menu open, you couldn't pin the widget. The
menu was modal, so Base UI drew a full-screen backdrop that swallowed
the click on the pin button. Making it non-modal (same as
`filter-bar-chip` and `sidebar-more-links`) fixes it:
```tsx
<DropdownMenu modal={false}>
```
Added a test in `chart-card.test.tsx` that opens the menu and clicks a
card action (it fails without the fix), and checked both fixes in a
browser against Storybook and the built widget.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## ELI5
The widget’s menus now keep their background, so the chart does not show
through them. You can also pin a chart while its view menu is open.
## Changes
- Scoped the observability widget’s card-surface styles to `#root`.
Portaled menus and popups keep their own backgrounds.
- Set the chart title menu to `modal={false}` so it does not block
clicks on card actions.
- Added a test that opens the menu and confirms the Pin action remains
clickable.
- Added patch changesets for `@mastra/mcp-apps-components` and
`@mastra/playground-ui`.
## Checks
Test and CI results: not available.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
|
||
|
|
6deb16047f |
chore: version packages (alpha) (#29719)
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/slack@1.9.0-alpha.0 ## @mastra/factory@0.28.0-alpha.3 ## @mastra/code-sdk@1.19.0-alpha.3 ## mastracode@0.50.0-alpha.3 ## @mastra/observability@1.24.0-alpha.2 ## @mastra/core@1.83.0-alpha.3 ## @mastra/mcp-apps-components@0.1.0-alpha.3 ## @mastra/playground-ui@69.0.0-alpha.4 ## @mastra/server@1.83.0-alpha.3 ## @mastra/server-adapters-test-suite@0.3.0-alpha.1 ## @mastra/platform-workspace@1.13.0-alpha.0 ## @mastra/auth-better-auth@1.1.11-alpha.1 ## @mastra/client-js@1.60.0-alpha.3 ## @mastra/react@1.15.0-alpha.3 ## @mastra/deployer-cloud@1.83.0-alpha.3 ## @mastra/longmemeval@1.1.42-alpha.3 ## @mastra/opencode@0.1.42-alpha.3 ## create-factory@0.4.3-alpha.3 ## @mastra/arize@1.3.30-alpha.2 ## @mastra/arthur@0.4.30-alpha.2 ## @mastra/braintrust@1.3.27-alpha.2 ## @mastra/datadog@1.4.22-alpha.2 ## @mastra/deepeval@0.1.24-alpha.2 ## @mastra/laminar@1.3.32-alpha.2 ## @mastra/langfuse@1.6.6-alpha.2 ## @mastra/langsmith@1.4.3-alpha.2 ## @mastra/otel-bridge@1.5.22-alpha.2 ## @mastra/otel-exporter@1.5.2-alpha.2 ## @mastra/posthog@1.4.7-alpha.2 ## @mastra/sentry@1.2.32-alpha.2 ## @mastra/agent-builder@1.2.1-alpha.1 ## mastra@1.39.0-alpha.3 ## @mastra/connect@1.3.2-alpha.2 ## @mastra/deployer@1.83.0-alpha.3 ## @mastra/editor@0.17.1-alpha.2 ## @mastra/fastembed@1.3.7-alpha.0 ## @mastra/mcp-docs-server@1.3.13-alpha.6 ## @mastra/memory@1.41.1-alpha.1 ## @mastra/elysia@0.1.23-alpha.3 ## @mastra/express@1.5.27-alpha.3 ## @mastra/fastify@1.5.27-alpha.3 ## @mastra/hono@1.7.25-alpha.3 ## @mastra/koa@1.7.27-alpha.3 ## @mastra/nestjs@0.3.0-alpha.3 ## @mastra/next@0.2.41-alpha.3 ## @mastra/tanstack-start@0.2.41-alpha.3 ## @mastra/convex@1.8.1-alpha.0 ## @mastra/pg@1.36.0-alpha.2 ## @mastra/inngest@1.11.2-alpha.2 ## @mastra/temporal@0.6.0-alpha.3 ## create-mastra@1.39.0-alpha.3 ## @internal/playground@1.39.0-alpha.3 Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> |
||
|
|
f48113de2e |
fix(mcp-apps-components): ship TypeScript types for @mastra/mcp-apps-components/host (#29742)
## Summary `@mastra/mcp-apps-components/host` (added in #29736) shipped without type declarations. `package.json` points the `./host` export's types at `dist/host.d.ts`, but `tsconfig.build.json` only included `src/index.ts`, so the declaration build never emitted it. TypeScript consumers importing `observabilityWidgetHost` got: ``` TS7016: Could not find a declaration file for module '@mastra/mcp-apps-components/host' ``` This adds `src/host.ts` to the build's `include`. ## Test plan - `pnpm build` in `packages/mcp-apps-components` now emits `dist/host.d.ts` - Every file referenced by `package.json` `exports` exists after the build - Swapped the built `host.d.ts` into the platform frontend that imports `observabilityWidgetHost`, and its `tsc --noEmit` went from TS7016 to clean <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## ELI5 The package points users to type information for its `host` export, but the build did not include the file that provides it. This change adds that file to the build so TypeScript can generate its declaration. ## Changes - Added `src/host.ts` to the build configuration alongside `src/index.ts`. - Added a patch changeset for `@mastra/mcp-apps-components` describing the missing declaration fix for `observabilityWidgetHost`. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com> |
||
|
|
889ab644d0 |
feat(mcp-apps-components): let host pages pass project, date range and filters to observability widgets (#29736)
Observability widgets opened in chat only read over the dashboard's own
defaults, so a widget shown on a page like Studio's Metrics page ignored
the project, date range and filters picked there. This adds
`observabilityWidgetHost` to `@mastra/mcp-apps-components/host` so the
host page can pass those down, with or without pinning.
```tsx
import { McpAppHostProvider } from '@mastra/playground-ui/domains/mcps';
import { observabilityWidgetHost } from '@mastra/mcp-apps-components/host';
const { datePreset, customRange, filterTokens } = useMetrics();
const host = observabilityWidgetHost({
resourceUri: 'ui://mastra/observability-widget',
projectId,
datePreset, // '24h' | '3d' | '7d' | '14d' | '30d' | 'custom'
customRange, // { from?, to? }, Dates or ISO strings, used when datePreset is 'custom'
filters: filterTokens,
// pins: { pinnedIds, onPin, onUnpin },
});
<McpAppHostProvider value={host}>{chat}</McpAppHostProvider>;
```
The host's values replace the dashboard's defaults, and the widget reads
again when they change. Windows are computed the same way as on the
Metrics page (a custom range without `from` starts 24h before now,
without `to` ends now), and a pinned widget keeps its custom range.
`projectId` goes out with every `queryObservability` call so the server
can scope reads; servers accept it with `projectId:
z.string().optional()` in the tool's input schema. With a `projectId`
the widgets draw at project scope, without one at org scope.
`observabilityWidgetPins` keeps working as before.
Tested with the existing MCP server + `AppBridge` widget tests: host
values overriding defaults, re-reads on change, custom ranges (full,
open-ended, inverted), pins carrying the range, Date → ISO conversion on
the host, and org vs project scope.
---------
Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
|
||
|
|
1666d54f05 | chore: version packages | ||
|
|
21b6078016 |
feat(mcp-apps-components): draw a whole observability dashboard (#29645)
The observability MCP app used to draw a single widget picked from a few
hard-coded ones, which made it pretty limited on real data. It now draws
a whole dashboard (rows of KPIs, time series, tables and scores), using
the dashboard's default date preset and filters. Each widget loads and
fails on its own.
The model doesn't write the stored dashboard format directly. It writes
a simpler shape where each widget, read and column type is a key, and
each number holds the read it comes from, so nothing points at a query,
series or column by id and a dashboard can't reference something it
lacks. `toObservabilityDashboard` gathers the reads into shared queries,
fills in series keys, totals and default sort, assigns missing widget
ids, and checks the result against `dashboardDefinitionSchema`. A widget
without a `span` fills the row.
```ts
{
span: 6,
timeseries: {
chart: 'stackedBar',
format: 'count',
series: [
{
label: 'Runs',
color: 'green',
value: { metricTimeSeries: { name: ['mastra_agent_duration_ms'], aggregation: 'count' } },
},
],
},
}
```
The schema names the metrics Mastra records so the model doesn't guess
names that read as zero. `createObservabilityDashboardInputSchema({
metricNames })` narrows them to the project's own metrics. The example
server refreshes that list before each run and also exposes a discovery
tool for label keys and values.
```ts
import {
observabilityDashboardInputSchema,
observabilityDashboardOutputSchema,
toObservabilityDashboard,
} from '@mastra/mcp-apps-components';
createTool({
id: 'showObservabilityDashboard',
inputSchema: observabilityDashboardInputSchema,
outputSchema: observabilityDashboardOutputSchema,
execute: async input => toObservabilityDashboard(input),
});
```
Every widget on Studio's metrics dashboard round-trips through the new
shape. On three prompts, gpt-5.5 and gpt-5-mini render every dashboard.
gpt-5.4-mini still struggles with tables.
`@mastra/core` and `zod` are now peer dependencies. To test, run `pnpm
--filter @mastra/mcp-apps-components test`, or run `examples/agent` and
ask the observability agent for a dashboard in Studio.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## ELI5
This PR changes the observability app from showing one widget to showing
a full dashboard. Each widget can load or show an error on its own, so
one failing widget does not block the others.
## Summary
- Add schemas for model-authored dashboards with KPI, time-series,
table, and score widgets. Convert validated input into a stored
dashboard, sharing matching reads and filling in missing widget IDs and
spans.
- Update the app to render dashboard rows and apply the dashboard’s date
preset and default filters. Show widget-level errors independently.
- Add an example dashboard tool and observability discovery tool.
Support metric-name validation against a project’s catalog.
- Update documentation, exports, pin context, and peer dependencies.
Rename the app resource to `observabilityDashboardApp`.
- Add tests for dashboard schemas, conversion, rendering, widget
failures, date ranges, filters, and pinning.
**Diff:** 18 files changed; 1,938 lines added and 304 removed.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
|
||
|
|
f21e0742ce | chore: version packages | ||
|
|
f82c222119 |
feat(playground-ui): pass the widget definition to StatelessWidget's pin callback (#29587)
`DashboardRenderer` already tells the host which widget was pinned, but
`StatelessWidget`'s `pin.onPin` only got the new pinned state. A host
that renders widgets itself, like the observability MCP app, couldn't
tell which chart or widget the click was for.
`StatelessWidget` now takes a `StatelessWidgetPin` (exported) whose
`onPin` gets the widget definition first, in the same order as
`DashboardRenderer`:
```tsx
<StatelessWidget
prepared={prepared}
pin={{
name: 'Agent runs',
isPinned,
onPin: (widget, isPinned) => savePin(widget, isPinned),
}}
{...props}
/>
```
Widget kinds and `PinAction` keep the internal one-argument `WidgetPin`,
so nothing changes for them. In `@mastra/mcp-apps-components`, `usePin`
uses the new type but still sends the host the widget exactly as the
opening tool returned it, not the parsed copy.
Testing: pin and unpin are covered on a chart and a KPI group, both
through `StatelessWidget` directly (playground-ui) and end to end
through the MCP app bridge (mcp-apps-components). Going back to the old
one-argument callback in `usePin` fails the MCP tests for both widget
types. Typecheck and lint are clean on both packages.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## ELI5
When someone pins or unpins a dashboard widget, the callback now
receives the widget and the requested pin state. This helps the host
save which widget changed.
## Changes
- Added and exported `StatelessWidgetPin`. Its `onPin` callback receives
a `DashboardWidget` and the requested pin state.
- Updated `StatelessWidget` to pass the prepared widget definition to
`onPin`.
- Updated `DashboardRenderer` to adapt its callback for
`StatelessWidget` and its error fallback.
- Updated the MCP apps `usePin` hook to use the new callback type. It
continues to send the original widget to the host.
- Added pin and unpin test cases for a chart and a KPI group, both in
`StatelessWidget` and through the MCP app bridge.
- Added a changeset for patch releases of `@mastra/playground-ui` and
`@mastra/mcp-apps-components`.
## Validation
Test, typecheck, and lint results: not available.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
|
||
|
|
d95e580fad |
feat(mcp-apps-components): add an observability widget MCP app (#29557)
Adds `observabilityWidgetApp`, an MCP app that draws one observability
dashboard widget (KPIs, time series…) right in the conversation. It
renders with playground-ui's `StatelessWidget`, so the chart looks and
behaves like the one on the Metrics dashboard.
The app runs sandboxed in the host's iframe and can't reach the Mastra
server, so it reads its data through an app-only `queryObservability`
tool taking `{ action, args }`, where `action` is a `MastraClient`
observability method. That tool lives in the server registering the app,
not in the package, so each deployment chooses its own endpoint and
credentials (local server or a hosted platform):
```ts
import { observabilityWidgetApp, QUERY_OBSERVABILITY_TOOL } from '@mastra/mcp-apps-components';
new MCPServer({
id: 'observability-mcp-server',
appResources: { 'ui://mastra/observability-widget': observabilityWidgetApp },
tools: {
showObservabilityWidget, // model-visible, returns { widget, datePreset }
[QUERY_OBSERVABILITY_TOOL]: queryObservability, // app-only, returns { data }
},
});
```
The app follows the host's light/dark theme. playground-ui exports
`emptyAnswer` so hosts can skip requests whose filters can never match
without calling the server. `examples/agent` gets a full reference
setup: an observability MCP server with preset widgets (overview,
agentRuns, tokenUsage, latency), a read-only `queryObservability` tool
and an observability agent.
Test plan: jsdom tests drive the app through a real MCP server and
`AppBridge`. They cover rendering the server's answer over the preset
window, a failed read, an invalid widget and the light theme. Another
test checks that the built resource is one self-contained HTML page. I
also checked it end to end in Studio against `examples/agent`: the agent
picks the right widget for the question, the chart shows live data and
the tool rejects unknown actions.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## ELI5
This PR lets a chat show one observability dashboard widget and fetch
its data through a tool provided by the host. Hosts can also let users
pin and unpin widgets, while keeping control of which widgets stay
pinned.
## Summary
- Adds `observabilityWidgetApp`, which renders a dashboard widget in a
sandboxed iframe. The app reads metrics through the server’s app-only
`queryObservability` tool and follows the host theme.
- Adds host integration for widget pinning. `observabilityWidgetPins`
provides pinned IDs to the matching app and forwards valid pin and unpin
updates to host callbacks.
- Extends `McpAppViewer` and the chat tool result flow to pass host
context and receive structured model-context updates.
- Exports `emptyAnswer` from playground-ui’s dashboard domain so callers
can represent requests that need no data.
- Adds an `examples/agent` setup with an observability MCP server, read
tool, agent, and preset widgets.
- Adds tests and documentation for widget rendering, data reads, host
context, and pinning.
**Change size:** 35 files changed; 1,501 lines added and 12 removed.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
|
||
|
|
9356f211f3 |
refactor(mcp-apps-components): restart on the MCP Apps spec with a greeting app (#29510)
`@mastra/mcp-apps-components` had grown its own layer on top of the [MCP Apps spec](https://github.com/modelcontextprotocol/ext-apps). The dashboard app read its data through a generic tool that ran the observability routes in-process, which required a Mastra instance and `@mastra/server`. Widget pinning depended on custom host-context keys, which only Studio understood, wired in through an `McpAppHostProvider` in `@mastra/playground-ui`. Every new app would have had to learn this layer, and none of it is part of the spec. This PR restarts the package on the spec alone, with a small app that uses every path an app needs: - **`greetingApp`** (package root) is a React app built into one self-contained HTML page. It reads its tool's arguments from `ui/notifications/tool-input` and gets its data by calling an app-only server tool (`visibility: ['app']`) with `callServerTool`. A button posts a reply to the conversation with `ui/message`. That's everything it does. - **The host writes both tools as regular Mastra tools**: the one the model calls to open the app, and the app-only one that returns the data. Data access and auth stay on the server, so the iframe needs no network access and can't see a token. The package has no peer dependencies anymore. - **Removed:** the dashboard app (`./dashboard-renderer`, `./observability-tools`), widget pinning, the `./host` entry, and `McpAppHostProvider` together with the `onModelContext` and `hostContext` props of `McpAppViewer`. MCP Apps in Studio work as they did before the provider was added. - `examples/agent` replaces the dashboard agent with a greeting agent. Its `getGreeting` tool calls a real remote API on the server side. The README, the MCP docs page and the changeset are updated. Before: ```ts import { dashboardRendererApp } from '@mastra/mcp-apps-components/dashboard-renderer'; import { observabilityAppTools } from '@mastra/mcp-apps-components/observability-tools'; new MCPServer({ appResources: { 'ui://mastra/dashboard': dashboardRendererApp() }, tools: { showDashboard, ...observabilityAppTools }, }); ``` After: ```ts import { greetingApp } from '@mastra/mcp-apps-components'; new MCPServer({ appResources: { 'ui://mastra/greeting': greetingApp }, tools: { showGreeting, getGreeting }, // getGreeting: mcp._meta.ui.visibility = ['app'] }); ``` The package is still in alpha, so the dashboard changesets that were never released are dropped instead of being reverted. ## Test plan - `@mastra/mcp-apps-components`: build, typecheck, lint, tests. - A real `MCPServer` serves the built page over Streamable HTTP. The test checks that the page is a single self-contained document. - The app is rendered against a real `AppBridge` relaying to that server. The tests check that the app greets the name from the tool input with the server's answer, posts the reply message, and shows the tool's error. - `@mastra/playground-ui`: typecheck and the `mcps`/`chat` tests (699 passing). - Manual check in Studio (`examples/agent`): "Greet Ada" opens the app, the app shows the greeting it got from `getGreeting`, and **Say hi back** posts "Ada says hi back!" to the chat, which the agent answers. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## ELI5 This PR replaces the package’s dashboard app with a small greeting app. The app gets a name, asks the server for a greeting, and lets the user send a reply. ## Summary - Export `greetingApp` and `McpAppResource` from the package root. The app reads the opening tool’s input, calls an app-only server tool, and can send a message to the conversation. - Remove the dashboard renderer, its data and pinning tools, the host entry point, and the package’s custom app runtime. The package now has a single root export and no peer dependencies. - Replace the example dashboard agent and server with a greeting agent and MCP server. Update the README, MCP documentation, and changesets. - Remove Playground’s MCP App host provider and the `hostContext` and `onModelContext` viewer props. The viewer still supports model-context updates through `onUpdateModelContext`. ## Validation The supplied PR objectives report package build, typecheck, lint, and test checks, plus Playground typecheck and `mcps`/`chat` tests with 699 passing. They also report a manual Studio check. These results are not independently verified here. Current-head check results: not available. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com> |
||
|
|
fc182d9c14 |
feat(mcp-apps-components): pin dashboard widgets through standard MCP Apps model context (#29488)
This makes dashboard widget pinning work with any MCP Apps host, using
only standard MCP Apps messages, and gives React hosts a small hook to
wire it up.
When the user clicks a pin, the app sends `ui/update-model-context` with
the full list of widgets the user wants pinned under
`mastra.ai/dashboard-pinned-widgets` in `structuredContent` (each entry
is `{ widget, scope, defaults }`), plus a short text block so the model
knows too. The host still owns the state: it sends pinned ids back in
host context and the buttons follow that. Pin and drilldown state go in
the same update, so one never wipes the other, and quick clicks build on
each other until the host answers. Pin buttons only show when the host
holds the ids array and advertises
`updateModelContext.structuredContent`. Hosts parse the payload with
`dashboardPinnedWidgetsSchema`.
On the host side, `@mastra/playground-ui/domains/mcps` gets
`McpAppHostProvider`, which lets a chat add host-context keys per app
instance and receive raw model context with the app it came from,
without reloading the iframe. The existing text model-context path is
unchanged, and without the provider nothing changes.
`@mastra/mcp-apps-components/host` adds `useMcpAppHost`, which parses
and routes pin updates; that subpath doesn't pull in the app's HTML (1.6
KB vs 2.1 MB).
```tsx
import { McpAppHostProvider } from '@mastra/playground-ui/domains/mcps';
import { useMcpAppHost } from '@mastra/mcp-apps-components/host';
const host = useMcpAppHost({ dashboardPins: { pinnedIds, onPinnedChange } });
<McpAppHostProvider value={host}>{chat}</McpAppHostProvider>;
```
`@mastra/mcp-apps-components` is also added to the playground-snapshot
publish job so the platform frontend can pick it up with playground-ui.
Tested with the real app over an in-memory AppBridge (pin/unpin round
trip through `useMcpAppHost`, rapid clicks, host declining a pin,
drilldown + pins coexisting, capability gating, invalid payloads) and
MSW-backed tests for `McpAppToolResult`/`McpAppViewer` (host-context
changes reach the running app without reload, raw params reach
`onModelContext`, read-only and no-provider cases). Key behaviors were
mutation-checked. Typecheck, oxlint and builds pass for both packages.
Also checked by hand in Studio against `examples/agent`'s dashboard
agent, with a temporary `useMcpAppHost` provider around the chat: pin →
unpin → pin sends exactly one host update per click (with the widget's
defaults), the iframe never reloads, and the agent correctly names the
pinned widget from model context alone.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## ELI5
The dashboard can now send its pinned widgets to the app that hosts it.
The host can save those choices and send them back, while apps that do
not use the new host support can continue to work.
## What changed
- Added `McpAppHostProvider` to `@mastra/playground-ui/domains/mcps`. It
provides per-app host context and receives raw model-context updates
while the app is running.
- Added the `@mastra/mcp-apps-components/host` export and
`useMcpAppHost` hook. Hosts can provide pinned widget IDs and handle
validated pin updates.
- Changed dashboard pinning to use `ui/update-model-context`. The app
sends the full requested widget list under
`mastra.ai/dashboard-pinned-widgets`, with a text description and
request number. Pin and drilldown state share an update.
- Pin controls require host-provided pin IDs and support for
`updateModelContext.structuredContent`. The host can disable pinning by
setting the pin context value to `null`.
- Removed the dashboard pin notification API. Hosts now use the
pinned-widget schemas and model-context updates.
- Added `@mastra/mcp-apps-components` to the playground snapshot publish
workflow and updated snapshot release guidance. Snapshot checks and
publishing use production dependency filters.
## Compatibility
Apps can continue to work without `McpAppHostProvider`. The former
dashboard pin notification API was removed and replaced with
model-context updates.
## Tests and validation
Added tests for pin and unpin interactions, pending and declined
requests, host-context updates, model-context handling, capability
gating, and invalid pin data. The PR objectives report typecheck,
oxlint, and builds passing for both packages, plus manual Studio checks.
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>
|
||
|
|
4bb378b97b |
feat(mcp-apps-components): ship one dashboard data tool with the app (#29491)
The dashboard MCP App used to need 11 route-specific tools
(`observabilityAppTools`) registered next to it, and their route list
was defined in the UI package. If you forgot them, the iframe loaded and
every widget failed with a generic error after a few retries.
This replaces them with a single app-only tool, `dashboardDataTool`,
which ships from the same entry point as the app:
```ts
import { dashboardDataTool, dashboardRendererApp } from '@mastra/mcp-apps-components/dashboard-renderer';
new MCPServer({
// ...
appResources: { 'ui://mastra/dashboard': dashboardRendererApp() },
tools: { showDashboard, dashboardDataTool },
});
```
Inside the iframe, each `MastraClient` read (for example
`getMetricAggregate`) becomes a call to that tool with a named
operation. The tool only answers the operations in
`DASHBOARD_DATA_OPERATIONS`, and it runs the matching observability
route in-process with `invokeRoute()` as the signed-in caller, so the
route's own validation, auth, RBAC and FGA checks still apply. Hosts
that want to answer reads themselves can use the exported contract
(`DASHBOARD_DATA_TOOL_NAME`, `DASHBOARD_DATA_OPERATIONS`,
`DASHBOARD_DATA_REQUESTS`, and the input and output schemas).
Widget errors are clearer now too. A missing tool answers 404 with how
to register it, and tool errors answer 400 with the route's message
instead of a serialized `MastraError`. `MastraClient` no longer retries
either one.
The `/observability-tools` entry point is removed, which breaks
compatibility for the alpha (the minor changeset shows the
before/after). This replaces #29449. #29456 will need a rebase onto
this, since `observability-fetch.ts` is gone.
Tested with the package's typecheck, lint and build, and 42 tests,
including integration tests that run a real Mastra server with auth/RBAC
over MCP HTTP, through `AppBridge` and `MastraClient` (allowed read,
403, missing tool, validation errors, no retries).
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## ELI5
The dashboard needs data to show charts and scores. This change gives it
one tool to request that data, while the server applies its existing
checks.
## Summary
- Replaces 11 observability tools with `dashboardDataTool`, which hosts
register alongside `dashboardRendererApp`.
- Defines 11 supported operations and exports the tool name, operation
list, request map, and input and output schemas from
`@mastra/mcp-apps-components/dashboard-renderer`.
- Runs supported requests through `invokeRoute()` with the caller’s
request context, so route validation and access checks apply. The tool
is visible to the app, not the model.
- Adds a fetch adapter that sends dashboard reads through the host’s MCP
connection. It identifies missing tools by JSON-RPC invalid-params code
`-32602`, returns registration guidance, and maps tool errors to HTTP
responses.
- Updates Studio to return JSON-RPC invalid-params errors for
unavailable or model-only tools.
- Removes the `@mastra/mcp-apps-components/observability-tools` package
entry point, breaking alpha compatibility.
## Validation
The PR objectives report that package typecheck, lint, build, and 42
tests passed. 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>
|
||
|
|
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> |
||
|
|
2f0018e13f |
feat(playground-ui): add dashboard widget pinning (#29443)
This lets a host pin single dashboard widgets so it can show them
somewhere else, like a chart the user wants to keep after the chat moves
on.
`DashboardRenderer` gets two optional props, passed together. Each
widget card then shows a pin button named after the widget ("Pin Agent
runs"). The host keeps the pinned state and passes it back through
`isPinned`. A pinned widget keeps its unpin button in view; an unpinned
one shows its pin button on hover.
```tsx
<DashboardRenderer
definition={definition}
scope="project"
isPinned={id => pinnedIds.includes(id)}
onPin={(widget, isPinned) =>
setPinnedIds(ids =>
isPinned ? (ids.includes(widget.id) ? ids : [...ids, widget.id]) : ids.filter(id => id !== widget.id),
)
}
/>
```
The dashboard MCP App connects this to the host over MCP Apps without
adding anything new to the protocol. The host lists its pinned widget
ids under `mastra.ai/dashboard-pinned-widgets` in its host context. When
the user clicks a pin button, the app sends a
`mastra.ai/dashboard-widget-pin` notification with `{ widget, scope,
defaults, isPinned }`, where `defaults` holds the date range and filters
the user had on, so the host can render the widget on its own as the
user saw it. Hosts parse the params with the exported
`dashboardWidgetPinNotificationParamsSchema`, since they come from the
iframe. The buttons only change when the host sends back an updated
list, so the host and the app can't drift apart. If a host doesn't set
the key, no pin buttons show. Studio's own MCP App viewer doesn't handle
this yet, so it doesn't change.
```typescript
bridge.fallbackNotificationHandler = async ({ method, params }) => {
if (method !== DASHBOARD_WIDGET_PIN_NOTIFICATION) return;
const parsed = dashboardWidgetPinNotificationParamsSchema.safeParse(params);
if (!parsed.success) return;
const { widget, isPinned } = parsed.data;
const pinned = hostContext[DASHBOARD_PINNED_WIDGETS_CONTEXT_KEY];
if (isPinned === pinned.includes(widget.id)) return;
const ids = isPinned ? [...pinned, widget.id] : pinned.filter(id => id !== widget.id);
hostContext = { ...hostContext, [DASHBOARD_PINNED_WIDGETS_CONTEXT_KEY]: ids };
bridge.setHostContext(hostContext);
};
```
The package README also covers turning pinning off (set the key to
`null`), keeping pinned ids per dashboard, and unpinning widgets that no
longer parse.
For testing, there are renderer tests for each widget kind, the error
card, a missing kind, titled pin labels, and the pinned button staying
in view. The MCP App tests run against a real `AppBridge` host and check
the notification payload (including defaults and schema validity), the
round trip with the host, the host unpinning a widget itself, and hosts
that can't pin.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## ELI5
Hosts can add pin buttons to dashboard widgets. The host decides which
widgets are pinned, and the dashboard shows the host’s latest state.
## What changed
- `DashboardRenderer` accepts `onPin` and `isPinned` together, or
neither. It passes pin controls to widgets that parse successfully,
including widgets that later show a render-error card.
- Pin buttons use the widget title in their accessible labels. Unpinned
widgets show the pin button on hover; pinned widgets keep the unpin
button visible.
- The dashboard MCP App reads pinned widget IDs from
`mastra.ai/dashboard-pinned-widgets`. When that context value is a
string array, it sends `mastra.ai/dashboard-widget-pin` notifications
with the widget, scope, dashboard defaults, and requested pin state. The
displayed state changes when the host updates its context.
- The MCP Apps package exports the pinning context key, notification
name, and notification-params schema. The README and changesets document
host handling and validation. Studio’s MCP App viewer does not handle
pinning.
## Tests
- Added renderer tests for pin and unpin behavior, host-supplied state,
button labels and visibility, render errors, and widgets that cannot be
read.
- Added MCP App tests for notification payloads, host state updates,
host-initiated unpinning, and hosts without pinning support. The tests
check notification params against the exported schema.
- Test execution results were not provided.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
|
||
|
|
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>
|