mirror of
https://github.com/mastra-ai/mastra.git
synced 2026-11-17 08:44:46 +00:00
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>
|
History
|
|
|---|---|---|
| .. | ||
| mastra | ||
| client.ts | ||
| fix-experiment-statuses.ts | ||
| hitl-approval-recall.ts | ||
| index.ts | ||
| model-middleware.ts | ||
| processor-demo.ts | ||
| run-item-scorers.ts | ||
| seed-evaluation.ts | ||
| seed-experiments-direct.ts | ||
| seed-history-traces.ts | ||
| seed-infinite-scroll-traces.ts | ||
| seed-item-scorers.ts | ||
| seed-more-scores.ts | ||
| seed-observability-scores.ts | ||
| seed-review-statuses.ts | ||
| test-code-mode.ts | ||
| test-dynamic-tools.ts | ||