From 26ede200beda7d80cd8ea6f1ba25a238ca07768b Mon Sep 17 00:00:00 2001 From: "sentry[bot]" <39604003+sentry[bot]@users.noreply.github.com> Date: Thu, 26 Nov 2026 10:42:15 +0000 Subject: [PATCH 1/3] fix(mcp): Support prebuilt dashboards with unpersisted widgets in schema --- packages/mcp-core/src/api-client/schema.ts | 16 +++-- .../catalog/get-dashboard-details.test.ts | 67 +++++++++++++++++++ 2 files changed, 77 insertions(+), 6 deletions(-) diff --git a/packages/mcp-core/src/api-client/schema.ts b/packages/mcp-core/src/api-client/schema.ts index 31bca87c1..3c2fbea24 100644 --- a/packages/mcp-core/src/api-client/schema.ts +++ b/packages/mcp-core/src/api-client/schema.ts @@ -160,17 +160,19 @@ export const DashboardWidgetPreviewSchema = z export const DashboardWidgetQuerySchema = z .object({ - id: z.union([z.string(), z.number()]), + // Prebuilt dashboards (e.g. `default-overview`) are static definitions + // whose queries have no persisted `id`, `widgetId`, or `fieldAliases`. + id: z.union([z.string(), z.number()]).optional(), name: z.string(), fields: z.array(z.string()), aggregates: z.array(z.string()), // Keyed by aggregate position; omitted by servers that predate the field. transformations: z.record(z.string(), z.array(z.string())).optional(), columns: z.array(z.string()), - fieldAliases: z.array(z.string()), + fieldAliases: z.array(z.string()).optional(), conditions: z.string(), orderby: z.string(), - widgetId: z.union([z.string(), z.number()]), + widgetId: z.union([z.string(), z.number()]).optional(), isHidden: z.boolean().optional(), selectedAggregate: z.number().nullable().optional(), linkedDashboards: z @@ -188,13 +190,15 @@ export const DashboardWidgetQuerySchema = z export const DashboardWidgetSchema = z .object({ - id: z.union([z.string(), z.number()]), + // Prebuilt dashboards (e.g. `default-overview`) return widgets that were + // never persisted, so `id`, `dateCreated`, and `dashboardId` are omitted. + id: z.union([z.string(), z.number()]).optional(), title: z.string(), description: z.string().nullable().optional(), displayType: z.string().nullable(), interval: z.string().nullable().optional(), - dateCreated: z.string(), - dashboardId: z.union([z.string(), z.number()]), + dateCreated: z.string().nullable().optional(), + dashboardId: z.union([z.string(), z.number()]).nullable().optional(), queries: z.array(DashboardWidgetQuerySchema).default([]), limit: z.number().nullable().optional(), widgetType: z.string().nullable().optional(), diff --git a/packages/mcp-core/src/tools/catalog/get-dashboard-details.test.ts b/packages/mcp-core/src/tools/catalog/get-dashboard-details.test.ts index ec873088f..fdfc31af0 100644 --- a/packages/mcp-core/src/tools/catalog/get-dashboard-details.test.ts +++ b/packages/mcp-core/src/tools/catalog/get-dashboard-details.test.ts @@ -230,6 +230,73 @@ describe("get_dashboard_details", () => { }); }); + it("returns prebuilt dashboards whose widgets were never persisted", async () => { + const [listedDashboard] = dashboardListFixture; + assert(listedDashboard, "Expected a fixture dashboard"); + mswServer.use( + http.get( + "https://sentry.io/api/0/organizations/sentry-mcp-evals/dashboards/", + () => + HttpResponse.json([ + { + ...listedDashboard, + id: "default-overview", + title: "General", + projects: [], + }, + ]), + ), + http.get( + "https://sentry.io/api/0/organizations/sentry-mcp-evals/dashboards/default-overview/", + () => + HttpResponse.json({ + id: "default-overview", + title: "General", + dateCreated: "", + createdBy: "", + widgets: [ + { + title: "Number of Errors", + displayType: "big_number", + interval: "5m", + widgetType: "discover", + queries: [ + { + name: "", + conditions: "!event.type:transaction", + fields: ["count()"], + aggregates: ["count()"], + columns: [], + orderby: "", + }, + ], + }, + ], + }), + ), + ); + + const dashboard = getDashboard( + await getDashboardDetails.handler( + { + organizationSlug: "sentry-mcp-evals", + regionUrl: null, + dashboardIdOrTitle: "General", + }, + context, + ), + ); + + expect(dashboard.id).toBe("default-overview"); + expect(dashboard.dateCreated).toBeNull(); + expect(dashboard.widgets).toHaveLength(1); + expect(dashboard.widgets[0]).toMatchObject({ + id: "unknown", + title: "Number of Errors", + queries: [{ aggregates: ["count()"], conditions: "!event.type:transaction" }], + }); + }); + it("returns a null creator when Sentry has no usable identity", async () => { mswServer.use( http.get( From 5e746fd361d955c738a59d1d2f22b36bee5edd43 Mon Sep 17 00:00:00 2001 From: "sentry[bot]" <39604003+sentry[bot]@users.noreply.github.com> Date: Thu, 26 Nov 2026 10:56:55 +0000 Subject: [PATCH 2/3] style(mcp-core): Format queries array in get-dashboard-details test --- .../mcp-core/src/tools/catalog/get-dashboard-details.test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/mcp-core/src/tools/catalog/get-dashboard-details.test.ts b/packages/mcp-core/src/tools/catalog/get-dashboard-details.test.ts index fdfc31af0..3fb5106b3 100644 --- a/packages/mcp-core/src/tools/catalog/get-dashboard-details.test.ts +++ b/packages/mcp-core/src/tools/catalog/get-dashboard-details.test.ts @@ -293,7 +293,9 @@ describe("get_dashboard_details", () => { expect(dashboard.widgets[0]).toMatchObject({ id: "unknown", title: "Number of Errors", - queries: [{ aggregates: ["count()"], conditions: "!event.type:transaction" }], + queries: [ + { aggregates: ["count()"], conditions: "!event.type:transaction" }, + ], }); }); From dd20de8c4a8b8756c8c9ab44fc40de29376f2786 Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Thu, 26 Nov 2026 17:06:41 +0000 Subject: [PATCH 3/3] fix(mcp): Keep omitted widget dateCreated and dashboardId non-null The legacy default-overview response omits these fields; persisted widgets always send a string date and dashboard ID. Accept omission only. --- packages/mcp-core/src/api-client/schema.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/mcp-core/src/api-client/schema.ts b/packages/mcp-core/src/api-client/schema.ts index 3c2fbea24..6c9a23e45 100644 --- a/packages/mcp-core/src/api-client/schema.ts +++ b/packages/mcp-core/src/api-client/schema.ts @@ -197,8 +197,8 @@ export const DashboardWidgetSchema = z description: z.string().nullable().optional(), displayType: z.string().nullable(), interval: z.string().nullable().optional(), - dateCreated: z.string().nullable().optional(), - dashboardId: z.union([z.string(), z.number()]).nullable().optional(), + dateCreated: z.string().optional(), + dashboardId: z.union([z.string(), z.number()]).optional(), queries: z.array(DashboardWidgetQuerySchema).default([]), limit: z.number().nullable().optional(), widgetType: z.string().nullable().optional(),