0
Fork 0
mirror of https://github.com/mastra-ai/mastra.git synced 2026-11-17 08:44:46 +00:00
mastra/examples/agent/src
Marvin Frachet 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>
History 2026-11-07 09:33:22 -08:00
..
mastra feat(mcp-apps-components): draw a whole observability dashboard (#29645) 2026-11-07 09:33:22 -08:00
client.ts feat(mcp)!: adopt the native 2026-07-28 request lifecycle (#23876) 2026-09-18 09:53:38 -04:00
fix-experiment-statuses.ts feat(playground): migrate to Tailwind CSS v4 (#14772) 2026-03-30 10:49:00 +02:00
hitl-approval-recall.ts mastracode web: React Router routing with auth-aware sign-in flow (#18912) 2026-07-03 17:56:43 +02:00
index.ts Compare two dataset experiments side by side in Studio (#22527) 2026-08-28 12:41:11 +02:00
model-middleware.ts chore: setup e2e tests for tools (#9036) 2025-10-21 16:21:14 +02:00
processor-demo.ts feat: enhanced processor system with retry, workflow orchestration, and tripwire improvements (#10947) 2025-12-10 16:43:41 -05:00
run-item-scorers.ts feat(playground): configure scorers per dataset item (#20034) 2026-08-14 16:28:33 -07:00
seed-evaluation.ts feat(playground): migrate to Tailwind CSS v4 (#14772) 2026-03-30 10:49:00 +02:00
seed-experiments-direct.ts feat(playground): migrate to Tailwind CSS v4 (#14772) 2026-03-30 10:49:00 +02:00
seed-history-traces.ts feat(playground-ui): make span details say what each span did (#28687) 2026-10-28 16:27:58 +01:00
seed-infinite-scroll-traces.ts feat(react,playground-ui): live-update the traces list with delta polling (#27967) 2026-10-21 12:53:03 +02:00
seed-item-scorers.ts feat(playground): configure scorers per dataset item (#20034) 2026-08-14 16:28:33 -07:00
seed-more-scores.ts feat(playground): evaluation dashboard, review pipeline & sidebar restructure (#14649) 2026-03-26 13:23:59 -05:00
seed-observability-scores.ts feat(playground): evaluation dashboard, review pipeline & sidebar restructure (#14649) 2026-03-26 13:23:59 -05:00
seed-review-statuses.ts feat(playground): evaluation dashboard, review pipeline & sidebar restructure (#14649) 2026-03-26 13:23:59 -05:00
test-code-mode.ts feat(firecrawl): integrate Firecrawl Browser Sandbox with Mastra (#15724) 2026-05-30 23:40:42 -05:00
test-dynamic-tools.ts feat(tools): implement dynamic tool search pattern (#12290) 2026-01-31 09:18:07 -08:00