Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
feat(dashboard): period-aware latency charts, monitor pause/resume, and get_workspace MCP tool (#2980)
Maximilian Kaske6dd5c0518ef6
diff --git a/apps/dashboard/src/app/(dashboard)/agents/mcp/page.tsx b/apps/dashboard/src/app/(dashboard)/agents/mcp/page.tsxindex 6cdbc1be4..940152ec9 100644--- a/apps/dashboard/src/app/(dashboard)/agents/mcp/page.tsx+++ b/apps/dashboard/src/app/(dashboard)/agents/mcp/page.tsx@@ -220,6 +220,7 @@ const tools = [{group: "Workspace",items: [+ "get_workspace","list_notifications","list_private_locations","list_audit_logs",diff --git a/apps/dashboard/src/app/(dashboard)/monitors/[id]/nav-actions.tsx b/apps/dashboard/src/app/(dashboard)/monitors/[id]/nav-actions.tsxindex cfcdca253..e6a2b7767 100644--- a/apps/dashboard/src/app/(dashboard)/monitors/[id]/nav-actions.tsx+++ b/apps/dashboard/src/app/(dashboard)/monitors/[id]/nav-actions.tsx@@ -68,6 +68,14 @@ export function NavActions() {}),);+ const updateMonitorsMutation = useMutation(+ trpc.monitor.updateMonitors.mutationOptions({+ onSuccess: () => {+ queryClient.invalidateQueries({ queryKey: trpc.monitor.pathKey() });+ },+ }),+ );+const testHttpMutation = useMutation(trpc.checker.testHttp.mutationOptions());const testTcpMutation = useMutation(trpc.checker.testTcp.mutationOptions());const testDnsMutation = useMutation(trpc.checker.testDns.mutationOptions());@@ -78,8 +86,28 @@ export function NavActions() {const curlCommand =monitor?.jobType === "http" ? buildCurlCommand(monitor) : null;+ function setActive(active: boolean) {+ const promise = updateMonitorsMutation.mutateAsync({+ ids: [Number.parseInt(id)],+ active,+ });+ toast.promise(promise, {+ loading: active ? "Resuming monitor..." : "Pausing monitor...",+ success: active ? "Monitor resumed" : "Monitor paused",+ error: (error) => {+ if (isTRPCClientError(error)) {+ return error.message;+ }+ return active ? "Failed to resume monitor" : "Failed to pause monitor";+ },+ });+ }++ const hiddenAction = monitor?.active ? "resume" : "pause";const actions = getActions({edit: () => router.push(`/monitors/${id}/edit`),+ pause: () => setActive(false),+ resume: () => setActive(true),"copy-id": async () => {await navigator.clipboard.writeText(id);toast.success("Monitor ID copied to clipboard");@@ -105,7 +133,11 @@ export function NavActions() {},});},- }).filter((action) => action.id !== "copy-curl" || Boolean(curlCommand));+ }).filter(+ (action) =>+ action.id !== hiddenAction &&+ (action.id !== "copy-curl" || Boolean(curlCommand)),+ );async function testAction() {if (monitor?.jobType === "http") {diff --git a/apps/dashboard/src/app/(dashboard)/monitors/[id]/overview/client.tsx b/apps/dashboard/src/app/(dashboard)/monitors/[id]/overview/client.tsxindex e058cf554..5eb9b9c5b 100644--- a/apps/dashboard/src/app/(dashboard)/monitors/[id]/overview/client.tsx+++ b/apps/dashboard/src/app/(dashboard)/monitors/[id]/overview/client.tsx@@ -1,10 +1,9 @@"use client";-import { Pause, Play, Trend } from "@openstatus/icons";+import { Pause, Trend } from "@openstatus/icons";import { Button } from "@openstatus/ui/components/ui/button";-import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";+import { useQuery } from "@tanstack/react-query";import { endOfDay } from "date-fns";-import NextLink from "next/link";import { useParams } from "next/navigation";import { useQueryStates } from "nuqs";import React, { useEffect } from "react";@@ -65,15 +64,6 @@ export function Client() {trpc.monitor.get.queryOptions({ id: Number.parseInt(id) }),);const { data: workspace } = useQuery(trpc.workspace.get.queryOptions());- const queryClient = useQueryClient();- const resumeMonitor = useMutation(- trpc.monitor.updateMonitors.mutationOptions({- onSuccess: () => {- queryClient.invalidateQueries({ queryKey: trpc.monitor.pathKey() });- },- onError: () => toast.error("Failed to resume the monitor"),- }),- );const isBlockedPeriod = workspace?.plan === "free" && isPaidPeriod(period);// snap free workspaces back synchronously so charts never fire (and the server@@ -83,8 +73,8 @@ export function Client() {useEffect(() => {if (!isBlockedPeriod) return;const timeout = setTimeout(() => {- toast.error("30 and 90 day windows require a paid plan", {- description: "Showing the last 14 days instead.",+ toast.error("Windows beyond 7 days require a paid plan", {+ description: "Showing the last 7 days instead.",});setSearchParams({ period: FREE_MAX_PERIOD });}, 0);@@ -92,7 +82,7 @@ export function Client() {}, [isBlockedPeriod, setSearchParams]);const selectedRegions = regions ?? undefined;- const fromDate = periodToFromDate[effectivePeriod];+ const fromDate = periodToFromDate(effectivePeriod);const toDate = endOfDay(new Date());const regionTimelineQuery = {@@ -138,7 +128,6 @@ export function Client() {const filtersRegions =workspace?.plan !== "free" && !!selectedRegions?.length;const filteredOut = noData && filtersRegions;- const maxPeriod = workspace?.plan === "free" ? FREE_MAX_PERIOD : "90d";const configuredRegions = React.useMemo(() => [@@ -214,21 +203,6 @@ export function Client() {<Pause /></EmptyStateMedia><EmptyStateTitle>This monitor is paused</EmptyStateTitle>- <EmptyStateActions>- <Button- size="sm"- disabled={resumeMonitor.isPending}- onClick={() =>- resumeMonitor.mutate({ ids: [monitor.id], active: true })- }- >- <Play />- Resume monitor- </Button>- <Button size="sm" variant="outline" asChild>- <NextLink href={`/monitors/${id}/edit`}>Edit monitor</NextLink>- </Button>- </EmptyStateActions></ChartEmpty>) : noData ? (<ChartEmpty className="h-[130px]">@@ -309,6 +283,7 @@ export function Client() {degradedAfter={monitor.degradedAfter}type={monitor.jobType as "http" | "tcp" | "dns" | "icmp" | "grpc"}period={effectivePeriod}+ interval={interval}regions={selectedRegions}/>)}diff --git a/apps/dashboard/src/components/chart/chart-area-latency.tsx b/apps/dashboard/src/components/chart/chart-area-latency.tsxindex c76fe07a0..944391b6a 100644--- a/apps/dashboard/src/components/chart/chart-area-latency.tsx+++ b/apps/dashboard/src/components/chart/chart-area-latency.tsx@@ -21,11 +21,13 @@ import {} from "recharts";import {+ type INTERVALS,type PERCENTILES,type PERIODS,mapLatency,} from "@/data/metrics.client";import { periodToFromDate } from "@/data/metrics.client";+import { formatAxisTick, formatDateTime } from "@/lib/formatter";import { useTRPC } from "@/lib/trpc/client";import { ChartTooltipNumber } from "./chart-tooltip-number";@@ -45,17 +47,19 @@ export function ChartAreaLatency({period,type,percentile,+ interval,regions,}: {monitorId: string;degradedAfter: number | null;percentile: (typeof PERCENTILES)[number];period: (typeof PERIODS)[number];+ interval: (typeof INTERVALS)[number];type: "http" | "tcp" | "dns" | "icmp" | "grpc";regions: string[] | undefined;}) {const trpc = useTRPC();- const fromDate = periodToFromDate[period];+ const fromDate = periodToFromDate(period);const toDate = endOfDay(new Date());const { data: latency } = useQuery(@@ -63,6 +67,7 @@ export function ChartAreaLatency({monitorId,period,type,+ interval,regions,fromDate: fromDate.toISOString(),toDate: toDate.toISOString(),@@ -80,13 +85,18 @@ export function ChartAreaLatency({tickLine={false}axisLine={false}tickMargin={8}- // tickFormatter={(value) => value.slice(0, 3)}+ tickFormatter={(value) =>+ formatAxisTick(new Date(value), period, interval)+ }/><ChartTooltipcursor={false}content={<ChartTooltipContentindicator="dot"+ labelFormatter={(_, payload) =>+ formatDateTime(new Date(payload[0]?.payload.timestamp))+ }formatter={(value, name) => (<ChartTooltipNumberchartConfig={chartConfig}@@ -119,7 +129,14 @@ export function ChartAreaLatency({</ReferenceLine>) : null}<YAxis- domain={["dataMin", "dataMax"]}+ domain={[+ "dataMin",+ // show the degraded line unless it would squash the series below half height+ (dataMax: number) =>+ degradedAfter && degradedAfter <= dataMax * 2+ ? degradedAfter+ : dataMax,+ ]}tickLine={false}axisLine={false}tickMargin={8}diff --git a/apps/dashboard/src/components/chart/chart-area-timing-phases.tsx b/apps/dashboard/src/components/chart/chart-area-timing-phases.tsxindex 3902e2682..fdc42beee 100644--- a/apps/dashboard/src/components/chart/chart-area-timing-phases.tsx+++ b/apps/dashboard/src/components/chart/chart-area-timing-phases.tsx@@ -9,6 +9,7 @@ import {ChartTooltipContent,} from "@openstatus/ui/components/ui/chart";import { useQuery } from "@tanstack/react-query";+import { endOfDay } from "date-fns";import {Area,AreaChart,@@ -24,7 +25,9 @@ import {type PERCENTILES,type PERIODS,mapTimingPhases,+ periodToFromDate,} from "@/data/metrics.client";+import { formatAxisTick, formatDateTime } from "@/lib/formatter";import { useTRPC } from "@/lib/trpc/client";import {@@ -75,6 +78,8 @@ export function ChartAreaTimingPhases({type: "http";}) {const trpc = useTRPC();+ const fromDate = periodToFromDate(period);+ const toDate = endOfDay(new Date());const { data: timingPhases } = useQuery(trpc.tinybird.metricsTimingPhases.queryOptions({@@ -83,6 +88,8 @@ export function ChartAreaTimingPhases({type,interval,regions,+ fromDate: fromDate.toISOString(),+ toDate: toDate.toISOString(),}),);@@ -99,13 +106,18 @@ export function ChartAreaTimingPhases({tickLine={false}axisLine={false}tickMargin={8}- // tickFormatter={(value) => value.slice(0, 3)}+ tickFormatter={(value) =>+ formatAxisTick(new Date(value), period, interval)+ }/><ChartTooltipcursor={false}content={<ChartTooltipContentindicator="dot"+ labelFormatter={(_, payload) =>+ formatDateTime(new Date(payload[0]?.payload.timestamp))+ }formatter={(value, name, item, index) => {if (index !== 4) {return (@@ -196,7 +208,14 @@ export function ChartAreaTimingPhases({</ReferenceLine>) : null}<YAxis- domain={["dataMin", "dataMax"]}+ domain={[+ "dataMin",+ // show the degraded line unless it would squash the series below half height+ (dataMax: number) =>+ degradedAfter && degradedAfter <= dataMax * 2+ ? degradedAfter+ : dataMax,+ ]}tickLine={false}axisLine={false}tickMargin={8}diff --git a/apps/dashboard/src/components/chart/chart-bar-uptime-light.tsx b/apps/dashboard/src/components/chart/chart-bar-uptime-light.tsxindex 86a96c9e9..51fa98764 100644--- a/apps/dashboard/src/components/chart/chart-bar-uptime-light.tsx+++ b/apps/dashboard/src/components/chart/chart-bar-uptime-light.tsx@@ -13,6 +13,7 @@ import { Bar, BarChart, XAxis } from "recharts";import { TableCellEmpty } from "@/components/data-table/table-cell-empty";import { mapUptime } from "@/data/metrics.client";+import { formatDateTime } from "@/lib/formatter";import { useTRPC } from "@/lib/trpc/client";// import { startOfDay, subDays } from "date-fns";@@ -70,7 +71,14 @@ export function ChartBarUptimeLight({cursor={false}allowEscapeViewBox={{ x: false, y: true }}wrapperStyle={{ zIndex: 1 }}- content={<ChartTooltipContent indicator="dot" />}+ content={+ <ChartTooltipContent+ indicator="dot"+ labelFormatter={(_, payload) =>+ formatDateTime(new Date(payload[0]?.payload.interval))+ }+ />+ }/><Bar dataKey="ok" stackId="a" fill="var(--color-ok)" /><Bar dataKey="error" stackId="a" fill="var(--color-error)" />diff --git a/apps/dashboard/src/components/chart/chart-bar-uptime.tsx b/apps/dashboard/src/components/chart/chart-bar-uptime.tsxindex a0d726a80..47a05542f 100644--- a/apps/dashboard/src/components/chart/chart-bar-uptime.tsx+++ b/apps/dashboard/src/components/chart/chart-bar-uptime.tsx@@ -19,6 +19,7 @@ import {periodToFromDate,periodToInterval,} from "@/data/metrics.client";+import { formatAxisTick, formatDateTime } from "@/lib/formatter";import { useTRPC } from "@/lib/trpc/client";const chartConfig = {@@ -49,7 +50,7 @@ export function ChartBarUptime({}) {const isMobile = useIsMobile();const trpc = useTRPC();- const fromDate = periodToFromDate[period];+ const fromDate = periodToFromDate(period);const toDate = endOfDay(new Date());const interval = periodToInterval[period];@@ -78,7 +79,14 @@ export function ChartBarUptime({<CartesianGrid vertical={false} /><ChartTooltipcursor={false}- content={<ChartTooltipContent indicator="dot" />}+ content={+ <ChartTooltipContent+ indicator="dot"+ labelFormatter={(_, payload) =>+ formatDateTime(new Date(payload[0]?.payload.interval))+ }+ />+ }/><Bar dataKey="ok" stackId="a" fill="var(--color-ok)" /><Bar dataKey="error" stackId="a" fill="var(--color-error)" />@@ -96,6 +104,9 @@ export function ChartBarUptime({tickMargin={8}minTickGap={10}axisLine={false}+ tickFormatter={(value) =>+ formatAxisTick(new Date(value), period, interval)+ }/><ChartLegend content={<ChartLegendContent />} /></BarChart>diff --git a/apps/dashboard/src/components/chat/tool-renderers/get-workspace.tsx b/apps/dashboard/src/components/chat/tool-renderers/get-workspace.tsxnew file mode 100644index 000000000..69eca0087--- /dev/null+++ b/apps/dashboard/src/components/chat/tool-renderers/get-workspace.tsx@@ -0,0 +1,58 @@+import type { AgentToolOutput } from "@openstatus/services/agent-tools";++import { TableCellDate } from "@/components/data-table/table-cell-date";+import { TableCellNumber } from "@/components/data-table/table-cell-number";+import { TableCellText } from "@/components/data-table/table-cell-text";++import type { DetailsTableData } from "./details-table";++type Output = AgentToolOutput<"get_workspace">;++export function getWorkspaceDetails(output: Output): DetailsTableData {+ const { usage } = output;+ return {+ sections: [+ {+ title: "Workspace",+ rows: [+ { label: "Name", value: <TableCellText value={output.name} /> },+ { label: "Slug", value: <TableCellText value={output.slug} /> },+ { label: "Plan", value: <TableCellText value={output.plan} /> },+ {+ label: "Trial ends",+ value: (+ <TableCellDate+ value={output.trialEndsAt ? new Date(output.trialEndsAt) : null}+ />+ ),+ },+ ],+ },+ {+ title: "Usage",+ rows: [+ {+ label: "Monitors",+ value: <TableCellNumber value={usage.monitors} />,+ },+ {+ label: "Status pages",+ value: <TableCellNumber value={usage.statusPages} />,+ },+ {+ label: "Page components",+ value: <TableCellNumber value={usage.pageComponents} />,+ },+ {+ label: "Notification channels",+ value: <TableCellNumber value={usage.notificationChannels} />,+ },+ {+ label: "Status reports",+ value: <TableCellNumber value={usage.statusReports} />,+ },+ ],+ },+ ],+ };+}diff --git a/apps/dashboard/src/components/chat/tool-renderers/incidents.test.tsx b/apps/dashboard/src/components/chat/tool-renderers/incidents.test.tsxindex c4eeb8073..cfa8a3ba1 100644--- a/apps/dashboard/src/components/chat/tool-renderers/incidents.test.tsx+++ b/apps/dashboard/src/components/chat/tool-renderers/incidents.test.tsx@@ -100,7 +100,7 @@ describe("listIncidentsTable", () => {expect(table.empty).toBe("No incidents.");});- it("marks closed incidents and falls back for a missing commander", () => {+ it("marks closed incidents", () => {const table = listIncidentsTable(asFixture<Output>({items: [@@ -127,14 +127,15 @@ describe("listIncidentsTable", () => {"title","severity","status",- "commander","id",]);const [closed, open] = table.rows;- expect(text(closed.cells.status)).toBe("resolved · closed");- expect(text(closed.cells.commander)).toBe("Unassigned");- expect(text(open.cells.status)).toBe("open");- expect(text(open.cells.commander)).toBe("Ada");+ expect(renderToStaticMarkup(<>{closed.cells.title}</>)).toContain(+ 'href="/incidents/1"',+ );+ expect(text(closed.cells.severity)).toBe("Major");+ expect(text(closed.cells.status)).toBe("Resolved · closed");+ expect(text(open.cells.status)).toBe("Open");expect(text(open.cells.id)).toBe("2");});});@@ -146,7 +147,8 @@ describe("getIncidentDetails", () => {id: 5,title: "Checkout down",severity: "critical",- status: "open",+ status: "resolved",+ closed: true,commander: null,summary: null,startedAt: "2024-01-01T00:00:00Z",@@ -172,6 +174,7 @@ describe("getIncidentDetails", () => {]);const value = (label: string) =>text(overview.rows.find((r) => r.label === label)?.value);+ expect(value("Status")).toBe("Resolved · closed");expect(value("Commander")).toBe("Unassigned");expect(value("Status report")).toBe("Payments degraded");});diff --git a/apps/dashboard/src/components/chat/tool-renderers/incidents.tsx b/apps/dashboard/src/components/chat/tool-renderers/incidents.tsxindex ab72a9660..c9fdecd99 100644--- a/apps/dashboard/src/components/chat/tool-renderers/incidents.tsx+++ b/apps/dashboard/src/components/chat/tool-renderers/incidents.tsx@@ -6,15 +6,21 @@ import type {import type { ChangeRow } from "@/components/common/changes-table";import { EntityRef } from "@/components/common/entity-ref/entity-ref";import { TableCellDate } from "@/components/data-table/table-cell-date";+import { TableCellLink } from "@/components/data-table/table-cell-link";import { TableCellNumber } from "@/components/data-table/table-cell-number";import { TableCellText } from "@/components/data-table/table-cell-text";+import {+ IncidentSeverityBadge,+ IncidentStatusBadge,+} from "@/components/incidents/incident-badge";+import { entityKinds } from "@/data/entity-refs.client";import type { DetailsTableData } from "./details-table";import type { ResultTableData } from "./result-table";export function listIncidentsTable(output: AgentToolOutput<"list_incidents">,-): ResultTableData<"title" | "severity" | "status" | "commander" | "id"> {+): ResultTableData<"title" | "severity" | "status" | "id"> {const items = output?.items ?? [];return {empty: "No incidents.",@@ -22,20 +28,19 @@ export function listIncidentsTable({ key: "title", header: "Title" },{ key: "severity", header: "Severity" },{ key: "status", header: "Status" },- { key: "commander", header: "Commander" },{ key: "id", header: "ID" },],rows: items.map((i) => ({id: i.id,cells: {- title: <TableCellText value={i.title} />,- severity: <TableCellText value={i.severity} />,- status: (- <TableCellText value={i.closed ? `${i.status} · closed` : i.status} />- ),- commander: (- <TableCellText value={i.commander?.name ?? null} empty="Unassigned" />+ title: (+ <TableCellLink+ href={entityKinds.incident.href({ id: i.id })}+ value={i.title}+ />),+ severity: <IncidentSeverityBadge severity={i.severity} />,+ status: <IncidentStatusBadge status={i.status} closed={i.closed} />,id: <TableCellNumber value={i.id} />,},})),@@ -50,12 +55,28 @@ export function getIncidentDetails({rows: [{ label: "ID", value: <TableCellNumber value={output.id} /> },- { label: "Title", value: <TableCellText value={output.title} /> },+ {+ label: "Title",+ value: (+ <TableCellLink+ href={entityKinds.incident.href({ id: output.id })}+ value={output.title}+ />+ ),+ },{label: "Severity",- value: <TableCellText value={output.severity} />,+ value: <IncidentSeverityBadge severity={output.severity} />,+ },+ {+ label: "Status",+ value: (+ <IncidentStatusBadge+ status={output.status}+ closed={output.closed}+ />+ ),},- { label: "Status", value: <TableCellText value={output.status} /> },{label: "Commander",value: (diff --git a/apps/dashboard/src/components/chat/tool-renderers/index.tsx b/apps/dashboard/src/components/chat/tool-renderers/index.tsxindex 6458574fa..33af64495 100644--- a/apps/dashboard/src/components/chat/tool-renderers/index.tsx+++ b/apps/dashboard/src/components/chat/tool-renderers/index.tsx@@ -20,6 +20,7 @@ import { getMonitorStatusTable } from "./get-monitor-status";import { getMonitorSummaryDetails } from "./get-monitor-summary";import { getResponseLogDetails } from "./get-response-log";import { getStatusReportDetails } from "./get-status-report";+import { getWorkspaceDetails } from "./get-workspace";import {declareIncidentChanges,getIncidentDetails,@@ -318,6 +319,12 @@ export const toolRenderers: ToolRendererRegistry = {),summary: (o) => (o.id ? `log ${o.id}` : undefined),},+ get_workspace: {+ renderResult: ({ output }) => (+ <DetailsTable {...getWorkspaceDetails(output)} />+ ),+ summary: (o) => `${o.slug} · ${o.plan}`,+ },list_audit_logs: {renderResult: ({ output }) => (<ResultTable {...listAuditLogsTable(output)} />diff --git a/apps/dashboard/src/components/controls-search/dropdown-interval.tsx b/apps/dashboard/src/components/controls-search/dropdown-interval.tsxindex 48f938109..4d391e066 100644--- a/apps/dashboard/src/components/controls-search/dropdown-interval.tsx+++ b/apps/dashboard/src/components/controls-search/dropdown-interval.tsx@@ -17,7 +17,12 @@ import {} from "nuqs";import { useEffect } from "react";-import { INTERVALS, PERIODS, periodToMinInterval } from "@/data/metrics.client";+import {+ INTERVALS,+ PERIODS,+ periodToMaxInterval,+ periodToMinInterval,+} from "@/data/metrics.client";const MAPPING = {5: "5 minutes",@@ -38,15 +43,18 @@ export function DropdownInterval() {const [period] = useQueryState("period", parsePeriod);const min = periodToMinInterval[period];- const options = INTERVALS.filter((item) => item >= min);+ const max = periodToMaxInterval[period];+ const options = INTERVALS.filter((item) => item >= min && item <= max);+ const selected = Math.min(+ Math.max(interval, min),+ max,+ ) as (typeof INTERVALS)[number];- // snap a now-too-fine selection up to the period's floor so the dropdown,- // URL, and charts agree (e.g. 5min carried over into the 90d view)+ // snap an out-of-range selection into the period's bounds so the dropdown,+ // URL, and charts agree (e.g. 5min carried into 90d, or 1d carried into 1d)useEffect(() => {- if (interval < min) setInterval(min);- }, [interval, min, setInterval]);-- const selected = Math.max(interval, min) as (typeof INTERVALS)[number];+ if (interval !== selected) setInterval(selected);+ }, [interval, selected, setInterval]);return (<Selectdiff --git a/apps/dashboard/src/components/controls-search/dropdown-period.tsx b/apps/dashboard/src/components/controls-search/dropdown-period.tsxindex e53d8bae2..d22f8e952 100644--- a/apps/dashboard/src/components/controls-search/dropdown-period.tsx+++ b/apps/dashboard/src/components/controls-search/dropdown-period.tsx@@ -84,7 +84,10 @@ export function DropdownPeriod() {className="data-[locked=true]:opacity-70">{label}- {locked ? <Lock className="ml-auto shrink-0" /> : null}+ {/* children sit inside ItemText, so take the indicator's slot instead of ml-auto */}+ {locked && period !== value ? (+ <Lock className="absolute right-2" />+ ) : null}</SelectItem>);})}diff --git a/apps/dashboard/src/components/data-table/incidents/data-table-row-actions.tsx b/apps/dashboard/src/components/data-table/incidents/data-table-row-actions.tsxindex 026ca5722..001746175 100644--- a/apps/dashboard/src/components/data-table/incidents/data-table-row-actions.tsx+++ b/apps/dashboard/src/components/data-table/incidents/data-table-row-actions.tsx@@ -47,7 +47,7 @@ export function IncidentRowActions({ incident }: { incident: Incident }) {<QuickActionsactions={actions}deleteAction={{- confirmationValue: incident.title || "incident",+ confirmationValue: incident.title || "downtime",submitAction: async () => {await deleteIncidentMutation.mutateAsync({id: incident.id,diff --git a/apps/dashboard/src/components/data-table/incidents/dialog-confirm.tsx b/apps/dashboard/src/components/data-table/incidents/dialog-confirm.tsxindex 2abe68535..b88bb1021 100644--- a/apps/dashboard/src/components/data-table/incidents/dialog-confirm.tsx+++ b/apps/dashboard/src/components/data-table/incidents/dialog-confirm.tsx@@ -89,7 +89,7 @@ export function DialogConfirmIncident({<AlertDialogTitle>Confirm your action</AlertDialogTitle><AlertDialogDescription>You are about to <span className="font-semibold">{type}</span> this- incident.+ downtime.</AlertDialogDescription></AlertDialogHeader><AlertDialogFooter>diff --git a/apps/dashboard/src/components/data-table/monitors/data-table-row-actions.tsx b/apps/dashboard/src/components/data-table/monitors/data-table-row-actions.tsxindex 41d53cc73..438903d3b 100644--- a/apps/dashboard/src/components/data-table/monitors/data-table-row-actions.tsx+++ b/apps/dashboard/src/components/data-table/monitors/data-table-row-actions.tsx@@ -4,6 +4,7 @@ import type { RouterOutputs } from "@openstatus/api";import { buildCurlCommand } from "@openstatus/utils";import { useMutation, useQueryClient } from "@tanstack/react-query";import type { Row } from "@tanstack/react-table";+import { isTRPCClientError } from "@trpc/client";import { useRouter } from "next/navigation";import { useState } from "react";import { toast } from "sonner";@@ -29,11 +30,38 @@ export function DataTableRowActions({ row }: DataTableRowActionsProps) {},}),);+ const updateMonitorsMutation = useMutation(+ trpc.monitor.updateMonitors.mutationOptions({+ onSuccess: () => {+ queryClient.invalidateQueries(trpc.monitor.list.queryOptions());+ },+ }),+ );const router = useRouter();++ function setActive(active: boolean) {+ const promise = updateMonitorsMutation.mutateAsync({+ ids: [row.original.id],+ active,+ });+ toast.promise(promise, {+ loading: active ? "Resuming monitor..." : "Pausing monitor...",+ success: active ? "Monitor resumed" : "Monitor paused",+ error: (error) => {+ if (isTRPCClientError(error)) {+ return error.message;+ }+ return active ? "Failed to resume monitor" : "Failed to pause monitor";+ },+ });+ }// curl only speaks HTTP — the action is hidden for tcp/dns monitorsconst isHttp = row.original.jobType === "http";+ const hiddenAction = row.original.active ? "resume" : "pause";const actions = getActions({edit: () => router.push(`/monitors/${row.original.id}/edit`),+ pause: () => setActive(false),+ resume: () => setActive(true),"copy-id": () => {navigator.clipboard.writeText(row.original.id.toString());toast.success("Monitor ID copied to clipboard");@@ -45,7 +73,10 @@ export function DataTableRowActions({ row }: DataTableRowActionsProps) {}: undefined,// export: () => setOpenDialog(true),- }).filter((action) => action.id !== "copy-curl" || isHttp);+ }).filter(+ (action) =>+ action.id !== hiddenAction && (action.id !== "copy-curl" || isHttp),+ );return (<>diff --git a/apps/dashboard/src/components/nav/nav-monitors.tsx b/apps/dashboard/src/components/nav/nav-monitors.tsxindex ad80e2bb6..cb98c1a57 100644--- a/apps/dashboard/src/components/nav/nav-monitors.tsx+++ b/apps/dashboard/src/components/nav/nav-monitors.tsx@@ -66,6 +66,13 @@ export function NavMonitors() {},}),);+ const updateMonitorsMutation = useMutation(+ trpc.monitor.updateMonitors.mutationOptions({+ onSuccess: () => {+ queryClient.invalidateQueries({ queryKey: trpc.monitor.pathKey() });+ },+ }),+ );const cloneMonitorMutation = useMutation(trpc.monitor.clone.mutationOptions({onSuccess: (newMonitor) => {@@ -135,8 +142,29 @@ export function NavMonitors() {const isActive = pathname.startsWith(`/monitors/${item.id}/`);// curl only speaks HTTP — the action is hidden for tcp/dns monitorsconst isHttp = item.jobType === "http";+ const hiddenAction = item.active ? "resume" : "pause";+ const setActive = (active: boolean) => {+ const promise = updateMonitorsMutation.mutateAsync({+ ids: [item.id],+ active,+ });+ toast.promise(promise, {+ loading: active ? "Resuming monitor..." : "Pausing monitor...",+ success: active ? "Monitor resumed" : "Monitor paused",+ error: (error) => {+ if (isTRPCClientError(error)) {+ return error.message;+ }+ return active+ ? "Failed to resume monitor"+ : "Failed to pause monitor";+ },+ });+ };const actions = getActions({edit: () => router.push(`/monitors/${item.id}/edit`),+ pause: () => setActive(false),+ resume: () => setActive(true),"copy-id": () => {navigator.clipboard.writeText(item.id.toString());toast.success("Monitor ID copied to clipboard");@@ -165,7 +193,11 @@ export function NavMonitors() {});},// export: () => setOpenDialog(true),- }).filter((action) => action.id !== "copy-curl" || isHttp);+ }).filter(+ (action) =>+ action.id !== hiddenAction &&+ (action.id !== "copy-curl" || isHttp),+ );return (<SidebarMenuItem key={item.id}><SidebarMenuButtondiff --git a/apps/dashboard/src/data/metrics.client.test.ts b/apps/dashboard/src/data/metrics.client.test.tsindex bb4c1c666..4e276f9a9 100644--- a/apps/dashboard/src/data/metrics.client.test.ts+++ b/apps/dashboard/src/data/metrics.client.test.ts@@ -17,7 +17,8 @@ describe("isPaidPeriod", () => {it("gates only the long periods", () => {expect(isPaidPeriod("30d")).toBe(true);expect(isPaidPeriod("90d")).toBe(true);- expect(isPaidPeriod("14d")).toBe(false);+ expect(isPaidPeriod("14d")).toBe(true);+ expect(isPaidPeriod("7d")).toBe(false);expect(isPaidPeriod("1d")).toBe(false);});});diff --git a/apps/dashboard/src/data/metrics.client.ts b/apps/dashboard/src/data/metrics.client.tsindex c6075e65e..72a33c898 100644--- a/apps/dashboard/src/data/metrics.client.ts+++ b/apps/dashboard/src/data/metrics.client.ts@@ -5,17 +5,17 @@ import { monitorRegions } from "@openstatus/db/src/schema/constants";import { startOfDay, subDays } from "date-fns";import type { MetricCard } from "@/components/metric/metric-card";-import { formatDateTime, formatMilliseconds } from "@/lib/formatter";+import { formatMilliseconds } from "@/lib/formatter";import type { RegionMetric } from "./region-metrics";export const STATUS = ["success", "error", "degraded"] as const;export const PERIODS = ["1d", "7d", "14d", "30d", "90d"] as const;-// 30d/90d require a paid plan; the dropdown gates them for free workspaces.-export const PAID_PERIODS = ["30d", "90d"] as const;+// 14d+ require a paid plan; the dropdown gates them for free workspaces.+export const PAID_PERIODS = ["14d", "30d", "90d"] as const;// longest window a free workspace may view; paid periods snap back to this.-export const FREE_MAX_PERIOD = "14d" as const;+export const FREE_MAX_PERIOD = "7d" as const;export type Period = (typeof PERIODS)[number];export type PaidPeriod = (typeof PAID_PERIODS)[number];@@ -118,7 +118,7 @@ export function mapUptime(status: RouterOutputs["tinybird"]["uptime"]) {return {...status,ok: status.success,- interval: formatDateTime(status.interval),+ interval: status.interval.getTime(),total: status.success + status.error + status.degraded,};})@@ -310,12 +310,16 @@ export function mapLatency(latency: RouterOutputs["tinybird"]["metricsLatency"],percentile: (typeof PERCENTILES)[number],) {- return latency.data?.map((metric) => {- return {- timestamp: formatDateTime(new Date(metric.timestamp)),+ // pipes disagree on ORDER BY; the chart needs oldest → newest+ return [...(latency.data ?? [])]+ .sort(+ (a, b) =>+ new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime(),+ )+ .map((metric) => ({+ timestamp: metric.timestamp,latency: metric[PERCENTILE_MAP[percentile]],- };- });+ }));}export function mapTimingPhases(@@ -324,7 +328,7 @@ export function mapTimingPhases() {return timingPhases.data?.map((metric) => {return {- timestamp: formatDateTime(new Date(metric.timestamp)),+ timestamp: metric.timestamp,dns: metric[`${percentile}Dns`],ttfb: metric[`${percentile}Ttfb`],transfer: metric[`${percentile}Transfer`],@@ -342,13 +346,18 @@ export const periodToInterval = {"90d": 1440,} satisfies Record<(typeof PERIODS)[number], number>;-export const periodToFromDate = {- "1d": startOfDay(subDays(new Date(), 1)),- "7d": startOfDay(subDays(new Date(), 7)),- "14d": startOfDay(subDays(new Date(), 14)),- "30d": startOfDay(subDays(new Date(), 30)),- "90d": startOfDay(subDays(new Date(), 90)),-} satisfies Record<(typeof PERIODS)[number], Date>;+const periodToDays = {+ "1d": 1,+ "7d": 7,+ "14d": 14,+ "30d": 30,+ "90d": 90,+} satisfies Record<(typeof PERIODS)[number], number>;++// computed per call so a tab left open past midnight keeps sliding its window+export function periodToFromDate(period: (typeof PERIODS)[number]) {+ return startOfDay(subDays(new Date(), periodToDays[period]));+}// Minimum selectable resolution (minutes) per period. Long windows floor the// interval so charts stay readable and queries bounded. Mirrors the server-side@@ -360,3 +369,12 @@ export const periodToMinInterval = {"30d": 240,"90d": 1440,} satisfies Record<(typeof PERIODS)[number], (typeof INTERVALS)[number]>;++// Coarsest useful resolution per period: a 1d window at 8h/1d buckets is 1–3 points.+export const periodToMaxInterval = {+ "1d": 240,+ "7d": 1440,+ "14d": 1440,+ "30d": 1440,+ "90d": 1440,+} satisfies Record<(typeof PERIODS)[number], (typeof INTERVALS)[number]>;diff --git a/apps/dashboard/src/data/monitors.client.ts b/apps/dashboard/src/data/monitors.client.tsindex 7ebcc4595..5fe392887 100644--- a/apps/dashboard/src/data/monitors.client.ts+++ b/apps/dashboard/src/data/monitors.client.ts@@ -6,6 +6,8 @@ import {Duplicate,Globe,Network,+ Pause,+ Play,Speed,Server,Terminal,@@ -65,6 +67,19 @@ export const actions = [icon: Duplicate,variant: "default" as const,},+ // mutually exclusive: callers keep the one matching `monitor.active`+ {+ id: "pause",+ label: "Pause",+ icon: Pause,+ variant: "default" as const,+ },+ {+ id: "resume",+ label: "Resume",+ icon: Play,+ variant: "default" as const,+ },// {// id: "export",// label: "Export Code",diff --git a/apps/dashboard/src/lib/formatter.test.ts b/apps/dashboard/src/lib/formatter.test.tsindex 4255fd71c..31a712172 100644--- a/apps/dashboard/src/lib/formatter.test.ts+++ b/apps/dashboard/src/lib/formatter.test.ts@@ -1,6 +1,7 @@import { describe, expect, it, vi } from "vitest";import {+ formatAxisTick,formatDateForInput,formatDateRange,formatDistanceToNowShort,@@ -122,3 +123,25 @@ describe("formatDateForInput", () => {);});});++describe("formatAxisTick", () => {+ // local-time constructors so the midnight branch is independent of TZ+ const midnight = new Date(2026, 9, 23, 0, 0);+ const afternoon = new Date(2026, 9, 22, 14, 30);+ const evenHour = new Date(2026, 9, 22, 16, 0);++ it("shows only the time on 1d, with the date at midnight", () => {+ expect(formatAxisTick(afternoon, "1d", 30)).toBe("2:30 PM");+ expect(formatAxisTick(midnight, "1d", 30)).toBe("Oct 23");+ });++ it("shows short date and hour for multi-day sub-daily buckets", () => {+ expect(formatAxisTick(evenHour, "7d", 240)).toBe("Oct 22, 4 PM");+ expect(formatAxisTick(afternoon, "7d", 30)).toBe("Oct 22, 2:30 PM");+ });++ it("shows only the date for daily buckets", () => {+ expect(formatAxisTick(midnight, "30d", 1440)).toBe("Oct 23");+ expect(formatAxisTick(afternoon, "90d", 1440)).toBe("Oct 22");+ });+});diff --git a/apps/dashboard/src/lib/formatter.ts b/apps/dashboard/src/lib/formatter.tsindex a2b4e0762..2459c8f68 100644--- a/apps/dashboard/src/lib/formatter.ts+++ b/apps/dashboard/src/lib/formatter.ts@@ -1,5 +1,7 @@import { endOfDay, isSameDay, startOfDay } from "date-fns";+import type { PERIODS } from "@/data/metrics.client";+export function formatMilliseconds(ms: number) {if (ms > 1000) {return `${Intl.NumberFormat("en-US", {@@ -54,6 +56,26 @@ export function formatTime(date: Date) {});}+// Axis ticks only carry what the range can't imply (tooltip has the full date):+// time of day on 1d, the date at midnight and for daily buckets, both otherwise.+export function formatAxisTick(+ date: Date,+ period: (typeof PERIODS)[number],+ interval: number,+) {+ const midnight = date.getHours() === 0 && date.getMinutes() === 0;+ if (interval >= 1440 || (period === "1d" && midnight)) {+ return date.toLocaleDateString("en-US", { month: "short", day: "numeric" });+ }+ if (period === "1d") return formatTime(date);+ return date.toLocaleString("en-US", {+ month: "short",+ day: "numeric",+ hour: "numeric",+ ...(date.getMinutes() ? { minute: "numeric" } : {}),+ });+}+export function formatDateRange(from?: Date, to?: Date) {const sameDay = from && to && isSameDay(from, to);const isFromStartDay = from && startOfDay(from).getTime() === from.getTime();diff --git a/apps/server/src/routes/mcp/evals/cases.ts b/apps/server/src/routes/mcp/evals/cases.tsindex 5508816f7..8bd9f7b99 100644--- a/apps/server/src/routes/mcp/evals/cases.ts+++ b/apps/server/src/routes/mcp/evals/cases.ts@@ -170,4 +170,9 @@ export const cases: EvalCase[] = [prompt: "Is our on-prem checker agent still reporting in?",expectedTool: "list_private_locations",},+ {+ id: "select.get_workspace",+ prompt: "What plan are we on, and how many monitors do we have?",+ expectedTool: "get_workspace",+ },];diff --git a/apps/server/src/routes/mcp/evals/run.ts b/apps/server/src/routes/mcp/evals/run.tsindex d49903800..c42e5ef7d 100644--- a/apps/server/src/routes/mcp/evals/run.ts+++ b/apps/server/src/routes/mcp/evals/run.ts@@ -16,6 +16,7 @@* - apps/server/src/routes/mcp/tools/status-report.ts* - apps/server/src/routes/mcp/tools/maintenance.ts* - apps/server/src/routes/mcp/tools/incident.ts+ * - packages/services/src/agent-tools/workspace.ts (get_workspace)** When you edit a description, input shape, or required field in any* of those files, edit it here too — drift is silent because evals@@ -53,6 +54,25 @@ const statusEnum = z.enum([]);const tools = {+ get_workspace: tool({+ description:+ "The current workspace: name, slug, plan, trial end and usage counts for monitors, status pages, components, notification channels and status reports. Use to answer which-plan or how-many questions. Plan limits and billing identifiers are NOT exposed.",+ inputSchema: z.object({}),+ execute: async () => ({+ id: 1,+ slug: "acme",+ name: "Acme",+ plan: "team",+ trialEndsAt: null,+ usage: {+ monitors: 0,+ statusPages: 0,+ pageComponents: 0,+ notificationChannels: 0,+ statusReports: 0,+ },+ }),+ }),list_status_pages: tool({description:"List status pages in this workspace with their slug and ids. Use to discover the pageId required by create_status_report and create_maintenance.",diff --git a/apps/server/src/routes/mcp/handler.test.ts b/apps/server/src/routes/mcp/handler.test.tsindex a271967de..abb08373a 100644--- a/apps/server/src/routes/mcp/handler.test.ts+++ b/apps/server/src/routes/mcp/handler.test.ts@@ -139,6 +139,7 @@ describe("MCP transport", () => {"get_postmortem","get_response_log","get_status_report",+ "get_workspace","list_audit_logs","list_incidents","list_maintenances",diff --git a/apps/server/src/routes/mcp/server.ts b/apps/server/src/routes/mcp/server.tsindex ec14c2b1f..d0b03f123 100644--- a/apps/server/src/routes/mcp/server.ts+++ b/apps/server/src/routes/mcp/server.ts@@ -12,6 +12,7 @@ import { registerNotificationTools } from "./tools/notification";import { registerPageTools } from "./tools/page";import { registerPrivateLocationTools } from "./tools/private-location";import { registerStatusReportTools } from "./tools/status-report";+import { registerWorkspaceTools } from "./tools/workspace";/*** Build a fresh `McpServer` for this request. Each tool registration@@ -37,6 +38,7 @@ export function createMcpServer(ctx: ServiceContext): McpServer {registerMonitorTools(server, ctx);registerNotificationTools(server, ctx);registerPrivateLocationTools(server, ctx);+ registerWorkspaceTools(server, ctx);registerAuditTools(server, ctx);registerContentTools(server, ctx);return server;diff --git a/apps/server/src/routes/mcp/tools/tools.test.ts b/apps/server/src/routes/mcp/tools/tools.test.tsindex 0c321ccd4..76c9d6137 100644--- a/apps/server/src/routes/mcp/tools/tools.test.ts+++ b/apps/server/src/routes/mcp/tools/tools.test.ts@@ -1,6 +1,7 @@import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";import { db, eq } from "@openstatus/db";import {+ monitor,page,pageComponent,pageSubscriber,@@ -24,6 +25,7 @@ import { registerMaintenanceTools } from "./maintenance";import { registerPageTools } from "./page";import { registerPrivateLocationTools } from "./private-location";import { registerStatusReportTools } from "./status-report";+import { registerWorkspaceTools } from "./workspace";/*** Build an MCP-flavoured `ServiceContext` for a workspace, optionally@@ -105,7 +107,12 @@ afterAll(async () => {/** Build a fresh McpServer + register a tool group, return the tool map. */function registered(- group: "page" | "status-report" | "maintenance" | "private-location",+ group:+ | "page"+ | "status-report"+ | "maintenance"+ | "private-location"+ | "workspace",ctx: ServiceContext,) {const server = new McpServer(@@ -119,6 +126,8 @@ function registered(return registerStatusReportTools(server, ctx);case "maintenance":return registerMaintenanceTools(server, ctx);+ case "workspace":+ return registerWorkspaceTools(server, ctx);case "private-location":return registerPrivateLocationTools(server, ctx);}@@ -884,6 +893,66 @@ describe("list_private_locations", () => {});});+describe("get_workspace", () => {+ test("returns plan and usage without billing identifiers", async () => {+ await withTestTransaction(async (tx) => {+ // fixture workspace already holds one page + one component; a+ // soft-deleted monitor must not count+ await tx.insert(monitor).values([+ {+ workspaceId: teamWorkspace.id,+ url: "https://example.openstatus.dev",+ name: `${TEST_PREFIX}-monitor`,+ },+ {+ workspaceId: teamWorkspace.id,+ url: "https://example.openstatus.dev",+ name: `${TEST_PREFIX}-monitor-deleted`,+ deletedAt: new Date(),+ },+ ]);+ const ctx = makeMcpToolCtx(teamWorkspace, { db: tx });+ const tools = registered("workspace", ctx);+ const result = await callTool(tools, "get_workspace", {});++ expect(result.isError).toBeFalsy();+ const structured = result.structuredContent as {+ id: number;+ slug: string;+ name: string | null;+ plan: string;+ trialEndsAt: string | null;+ usage: {+ monitors: number;+ statusPages: number;+ pageComponents: number;+ notificationChannels: number;+ statusReports: number;+ };+ };+ expect(structured.id).toBe(teamWorkspace.id);+ expect(structured.slug).toBe(teamWorkspace.slug);+ expect(structured.name).toBe(teamWorkspace.name ?? null);+ expect(structured.plan).toBe(teamWorkspace.plan);+ expect(structured.trialEndsAt).toBe(+ teamWorkspace.trialEndsAt?.toISOString() ?? null,+ );+ expect(structured.usage).toEqual({+ monitors: 1,+ statusPages: 1,+ pageComponents: 1,+ notificationChannels: 0,+ statusReports: 0,+ });++ const serialized = JSON.stringify(result);+ expect(serialized).not.toContain("stripe");+ expect(serialized).not.toContain("subscription");+ expect(serialized).not.toContain('"limits"');+ });+ });+});+describe("scope filter", () => {test("read-only key sees read tools, no write tools", async () => {const ctx = makeMcpToolCtx(teamWorkspace, { scopes: ["read"] });diff --git a/apps/server/src/routes/mcp/tools/workspace.ts b/apps/server/src/routes/mcp/tools/workspace.tsnew file mode 100644index 000000000..b4382643b--- /dev/null+++ b/apps/server/src/routes/mcp/tools/workspace.ts@@ -0,0 +1,15 @@+import type {+ McpServer,+ RegisteredTool,+} from "@modelcontextprotocol/sdk/server/mcp.js";+import type { ServiceContext } from "@openstatus/services";+import { getWorkspaceTool } from "@openstatus/services/agent-tools";++import { registerRegistryTools } from "./registry-adapter";++export function registerWorkspaceTools(+ server: McpServer,+ ctx: ServiceContext,+): Map<string, RegisteredTool> {+ return registerRegistryTools(server, ctx, [getWorkspaceTool]);+}diff --git a/apps/server/src/routes/slack/system-prompt.ts b/apps/server/src/routes/slack/system-prompt.tsindex a8124250b..51bf20e44 100644--- a/apps/server/src/routes/slack/system-prompt.ts+++ b/apps/server/src/routes/slack/system-prompt.ts@@ -64,6 +64,7 @@ IMPORTANT: You have NO knowledge of this workspace's data. NEVER guess or make u- Questions about a monitor, including by name ("the API monitor") -> call list_monitors FIRST to get its id- Questions about a notification channel, including by name ("PagerDuty") -> call list_notifications FIRST- Questions about a private location / on-prem checker -> call list_private_locations FIRST+- Questions about the plan or how many monitors/pages/channels exist -> call get_workspace FIRST- Questions about who changed what -> call list_audit_logs FIRST; use get_audit_log only with an id it returned- Details of a single check -> get_response_log only with an id returned by list_response_logs- Creating a report -> you MUST call list_status_pages first to get the real pageId, then call create_status_report with that pageId@@ -89,6 +90,7 @@ Monitoring (read-only):- Individual check results, e.g. recent failures (list_response_logs, get_response_log)- Notification channels and which monitors they're wired to (list_notifications)- Private locations and whether their checkers are reporting (list_private_locations)+- Workspace plan and usage counts (get_workspace)- Audit trail of workspace changes (list_audit_logs, get_audit_log)openstatus knowledge (read-only):- Product docs (search_docs, get_doc_page)diff --git a/apps/status-page/src/components/status-page/floating-button.tsx b/apps/status-page/src/components/status-page/floating-button.tsxindex 4361f4b9f..3b8c3baaa 100644--- a/apps/status-page/src/components/status-page/floating-button.tsx+++ b/apps/status-page/src/components/status-page/floating-button.tsx@@ -59,6 +59,16 @@ export type CommunityTheme = (typeof COMMUNITY_THEME)[number];export const NUMBER_OF_DAYS = [30, 45] as const;export type NumberOfDays = (typeof NUMBER_OF_DAYS)[number];+// mirrors `configurationLabels` in the dashboard's form-configuration.tsx+const LABELS = {+ type: { absolute: "Monitor checks", manual: "Reports only" },+ value: {+ duration: "Time per status",+ requests: "Number of checks",+ manual: "Worst status of the day",+ },+} as const;+interface StatusPageContextType {cardType: CardType;setCardType: (cardType: CardType) => void;@@ -237,7 +247,7 @@ export function FloatingButton({</div><div className="grid grid-cols-2 gap-4"><div className="space-y-2">- <Label htmlFor="bar-type">Bar Type</Label>+ <Label htmlFor="bar-type">Status source</Label><Selectvalue={barType}onValueChange={(v) => {@@ -249,39 +259,46 @@ export function FloatingButton({}}}>- <SelectTrigger id="bar-type" className="w-full capitalize">+ <SelectTrigger id="bar-type" className="w-full"><SelectValue /></SelectTrigger><SelectContent>{BAR_TYPE.map((v) => (- <SelectItem key={v} value={v} className="capitalize">- {v}+ <SelectItem key={v} value={v}>+ {LABELS.type[v]}</SelectItem>))}</SelectContent></Select></div><div className="space-y-2">- <Label htmlFor="card-type">Card Type</Label>+ <Label htmlFor="card-type">Card shows</Label><Selectvalue={cardType}onValueChange={(v) => setCardType(v as CardType)}disabled={barType !== "absolute"}>- <SelectTrigger id="card-type" className="w-full capitalize">- <SelectValue />+ <SelectTrigger id="card-type" className="w-full">+ {barType === "manual" ? (+ <span className="text-muted-foreground truncate">+ Not available for reports only+ </span>+ ) : (+ <SelectValue />+ )}</SelectTrigger><SelectContent>- {CARD_TYPE.map((v) => (- <SelectItem- key={v}- value={v}- className="capitalize"- disabled={["dominant", "manual"].includes(v)}- >- {v}+ {(["duration", "requests"] as const).map((v) => (+ <SelectItem key={v} value={v}>+ {LABELS.value[v]}</SelectItem>))}+ {/* stored configs may pair an absolute source with a manual value */}+ {cardType === "manual" ? (+ <SelectItem value="manual" disabled>+ {LABELS.value.manual}+ </SelectItem>+ ) : null}</SelectContent></Select></div>diff --git a/apps/web/src/content/pages/docs/reference/mcp-server.mdx b/apps/web/src/content/pages/docs/reference/mcp-server.mdxindex c0e3600a1..e1d240f0f 100644--- a/apps/web/src/content/pages/docs/reference/mcp-server.mdx+++ b/apps/web/src/content/pages/docs/reference/mcp-server.mdx@@ -62,7 +62,7 @@ For AI agents that should only observe state — health summaries, paging on-cal## Tools-The server exposes 39 tools (37 on plans without the `audit-log` feature), grouped by resource: 35 scoped to the workspace tied to your credential, plus 4 public content tools that read openstatus.dev pages on any credential and any scope (see [Content](#content)). Mutations write to the audit log with `actor_type = "mcp"` (see [Audit log](#audit-log)).+The server exposes 40 tools (38 on plans without the `audit-log` feature), grouped by resource: 36 scoped to the workspace tied to your credential, plus 4 public content tools that read openstatus.dev pages on any credential and any scope (see [Content](#content)). Mutations write to the audit log with `actor_type = "mcp"` (see [Audit log](#audit-log)).### Pages@@ -134,6 +134,12 @@ These tools act on declared incidents, not on monitor downtime, and are internal|--------------------------|------|---------|| `list_private_locations` | read | List the workspace's private locations with their name, status (`active` / `error`), metadata, and `lastSeenAt`. Agent tokens are never exposed. |+### Workspace++| Tool | Type | Purpose |+|-----------------|------|---------|+| `get_workspace` | read | The workspace's name, slug, plan, trial end, and usage counts (monitors, status pages, components, notification channels, status reports). Plan limits and billing identifiers are never exposed. |+### AuditRegistered only when the workspace plan includes the `audit-log` feature — otherwise these tools are absent from `tools/list`.diff --git a/packages/api/src/router/tinybird/index.ts b/packages/api/src/router/tinybird/index.tsindex e9928a4f2..7d5ccc1fb 100644--- a/packages/api/src/router/tinybird/index.ts+++ b/packages/api/src/router/tinybird/index.ts@@ -18,12 +18,12 @@ const types = ["http", "tcp", "dns", "icmp", "grpc"] as const;type Period = (typeof periods)[number];type Type = (typeof types)[number];-// 30d/90d windows are paid-only; free workspaces are blocked server-side.+// Free workspaces only get up to 7d; longer windows are blocked server-side.function assertPaidPeriod(plan: string, period: Period) {- if (plan === "free" && (period === "30d" || period === "90d")) {+ if (plan === "free" && period !== "1d" && period !== "7d") {throw new TRPCError({code: "FORBIDDEN",- message: "Upgrade to a paid plan to access 30d and 90d data",+ message: "Upgrade to a paid plan to access more than 7 days of data",});}}@@ -40,9 +40,37 @@ const periodToMinInterval: Record<Period, number> = {"90d": 1440,};+// Coarsest useful resolution per period — mirrors the dashboard's periodToMaxInterval.+const periodToMaxInterval: Record<Period, number> = {+ "1d": 240,+ "7d": 1440,+ "14d": 1440,+ "30d": 1440,+ "90d": 1440,+};+function clampInterval(period: Period, interval?: number) {if (interval == null) return interval;- return Math.max(interval, periodToMinInterval[period]);+ return Math.min(+ Math.max(interval, periodToMinInterval[period]),+ periodToMaxInterval[period],+ );+}++// latency pipes read fixed-window MVs (14d → 30d, 1d/7d → 14d, dns 1d → 7d)+// and ignore the dates, so trim to the requested window here+function trimToWindow<T extends { timestamp: number }>(+ rows: T[],+ fromDate?: string,+ toDate?: string,+) {+ const from = fromDate ? new Date(fromDate).getTime() : undefined;+ const to = toDate ? new Date(toDate).getTime() : undefined;+ return rows.filter(+ (row) =>+ (from === undefined || row.timestamp >= from) &&+ (to === undefined || row.timestamp <= to),+ );}// NEW: workspace-level counters helper@@ -563,8 +591,9 @@ export const tinybirdRouter = createTRPCRouter({period: z.enum(periods),regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),type: z.enum(types).prefault("http"),- fromDate: z.string().optional(),- toDate: z.string().optional(),+ interval: z.int().optional(),+ fromDate: z.iso.datetime().optional(),+ toDate: z.iso.datetime().optional(),}),).query(async (opts) => {@@ -590,11 +619,20 @@ export const tinybirdRouter = createTRPCRouter({assertPaidPeriod(opts.ctx.workspace.plan, opts.input.period);+ opts.input.interval = clampInterval(+ opts.input.period,+ opts.input.interval,+ );+const procedure = getMetricsLatencyProcedure(opts.input.period,opts.input.type,);- return await procedure(opts.input);+ const result = await procedure(opts.input);+ return {+ ...result,+ data: trimToWindow(result.data, opts.input.fromDate, opts.input.toDate),+ };}),metricsTimingPhases: protectedProcedure@@ -605,6 +643,8 @@ export const tinybirdRouter = createTRPCRouter({interval: z.int().optional(),regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),type: z.literal("http"),+ fromDate: z.iso.datetime().optional(),+ toDate: z.iso.datetime().optional(),}),).query(async (opts) => {@@ -647,7 +687,11 @@ export const tinybirdRouter = createTRPCRouter({});}- return await procedure(opts.input);+ const result = await procedure(opts.input);+ return {+ ...result,+ data: trimToWindow(result.data, opts.input.fromDate, opts.input.toDate),+ };}),workspace30d: protectedProcedurediff --git a/packages/services/src/agent-tools/index.ts b/packages/services/src/agent-tools/index.tsindex 90516666c..bd354a46a 100644--- a/packages/services/src/agent-tools/index.ts+++ b/packages/services/src/agent-tools/index.ts@@ -47,6 +47,7 @@ import {updateStatusReportUpdateTool,} from "./status-report";import type { AnyAgentTool } from "./types";+import { getWorkspaceTool } from "./workspace";export { getAuditLogTool, listAuditLogsTool } from "./audit";export { getContentPageTool, searchContentTool } from "./content";@@ -82,6 +83,7 @@ export { listNotificationsTool } from "./notification";export { listStatusPagesTool } from "./page";export { listPageComponentsTool } from "./page-component";export { listPrivateLocationsTool } from "./private-location";+export { getWorkspaceTool } from "./workspace";export {addStatusReportUpdateTool,createStatusReportTool,@@ -152,6 +154,7 @@ export const agentTools = {get_response_log: getResponseLogTool,list_notifications: listNotificationsTool,list_private_locations: listPrivateLocationsTool,+ get_workspace: getWorkspaceTool,list_audit_logs: listAuditLogsTool,get_audit_log: getAuditLogTool,search_docs: searchDocsTool,diff --git a/packages/services/src/agent-tools/workspace.ts b/packages/services/src/agent-tools/workspace.tsnew file mode 100644index 000000000..2ab130f07--- /dev/null+++ b/packages/services/src/agent-tools/workspace.ts@@ -0,0 +1,51 @@+import { z } from "zod";++import { getWorkspaceUsage } from "../workspace";+import type { AgentTool } from "./types";++const GetWorkspaceInput = z.object({}).strict();+const GetWorkspaceOutput = z.object({+ id: z.number().int(),+ slug: z.string(),+ name: z.string().nullable(),+ plan: z.string(),+ trialEndsAt: z.string().nullable(),+ usage: z.object({+ monitors: z.number().int(),+ statusPages: z.number().int(),+ pageComponents: z.number().int(),+ notificationChannels: z.number().int(),+ statusReports: z.number().int(),+ }),+});++export const getWorkspaceTool: AgentTool<+ z.infer<typeof GetWorkspaceInput>,+ z.infer<typeof GetWorkspaceOutput>+> = {+ name: "get_workspace",+ description:+ "The current workspace: name, slug, plan, trial end and usage counts for monitors, status pages, components, notification channels and status reports. Use to answer which-plan or how-many questions. Plan limits and billing identifiers are NOT exposed.",+ scope: "read",+ destructive: false,+ inputSchema: GetWorkspaceInput,+ outputSchema: GetWorkspaceOutput,+ async run({ ctx }) {+ const { workspace } = ctx;+ const usage = await getWorkspaceUsage({ ctx });+ return {+ id: workspace.id,+ slug: workspace.slug,+ name: workspace.name ?? null,+ plan: workspace.plan ?? "free",+ trialEndsAt: workspace.trialEndsAt?.toISOString() ?? null,+ usage: {+ monitors: usage.monitors,+ statusPages: usage.pages,+ pageComponents: usage.pageComponents,+ notificationChannels: usage.notifications,+ statusReports: usage.statusReports,+ },+ };+ },+};diff --git a/packages/tinybird/src/client.ts b/packages/tinybird/src/client.tsindex fde1f7af5..8f4634b01 100644--- a/packages/tinybird/src/client.ts+++ b/packages/tinybird/src/client.ts@@ -1781,6 +1781,7 @@ export class OSTinybird {parameters: z.object({monitorId: z.string(),regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),+ interval: z.int().optional(),fromDate: z.string().optional(),toDate: z.string().optional(),}),@@ -1794,6 +1795,7 @@ export class OSTinybird {parameters: z.object({monitorId: z.string(),regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),+ interval: z.int().optional(),fromDate: z.string().optional(),toDate: z.string().optional(),}),@@ -1807,6 +1809,7 @@ export class OSTinybird {parameters: z.object({monitorId: z.string(),regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),+ interval: z.int().optional(),fromDate: z.string().optional(),toDate: z.string().optional(),}),@@ -1820,6 +1823,7 @@ export class OSTinybird {parameters: z.object({monitorId: z.string(),regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),+ interval: z.int().optional(),fromDate: z.string().optional(),toDate: z.string().optional(),}),@@ -2265,6 +2269,7 @@ export class OSTinybird {parameters: z.object({monitorId: z.string(),regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),+ interval: z.int().optional(),fromDate: z.string().optional(),toDate: z.string().optional(),}),@@ -2278,6 +2283,7 @@ export class OSTinybird {parameters: z.object({monitorId: z.string(),regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),+ interval: z.int().optional(),fromDate: z.string().optional(),toDate: z.string().optional(),}),@@ -2291,6 +2297,7 @@ export class OSTinybird {parameters: z.object({monitorId: z.string(),regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),+ interval: z.int().optional(),fromDate: z.string().optional(),toDate: z.string().optional(),}),@@ -2304,6 +2311,7 @@ export class OSTinybird {parameters: z.object({monitorId: z.string(),regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),+ interval: z.int().optional(),fromDate: z.string().optional(),toDate: z.string().optional(),}),@@ -2781,6 +2789,7 @@ export class OSTinybird {parameters: z.object({monitorId: z.string(),regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),+ interval: z.int().optional(),fromDate: z.string().optional(),toDate: z.string().optional(),}),@@ -2801,6 +2810,7 @@ export class OSTinybird {parameters: z.object({monitorId: z.string(),regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),+ interval: z.int().optional(),fromDate: z.string().optional(),toDate: z.string().optional(),}),@@ -2842,6 +2852,7 @@ export class OSTinybird {parameters: z.object({monitorId: z.string(),regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),+ interval: z.int().optional(),fromDate: z.string().optional(),toDate: z.string().optional(),}),@@ -2862,6 +2873,7 @@ export class OSTinybird {parameters: z.object({monitorId: z.string(),regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),+ interval: z.int().optional(),fromDate: z.string().optional(),toDate: z.string().optional(),}),@@ -3069,6 +3081,7 @@ export class OSTinybird {parameters: z.object({monitorId: z.string(),regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),+ interval: z.int().optional(),fromDate: z.string().optional(),toDate: z.string().optional(),}),@@ -3444,6 +3457,7 @@ export class OSTinybird {parameters: z.object({monitorId: z.string(),regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),+ interval: z.int().optional(),fromDate: z.string().optional(),toDate: z.string().optional(),}),@@ -3464,6 +3478,7 @@ export class OSTinybird {parameters: z.object({monitorId: z.string(),regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),+ interval: z.int().optional(),fromDate: z.string().optional(),toDate: z.string().optional(),}),@@ -3484,6 +3499,7 @@ export class OSTinybird {parameters: z.object({monitorId: z.string(),regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),+ interval: z.int().optional(),fromDate: z.string().optional(),toDate: z.string().optional(),}),@@ -3504,6 +3520,7 @@ export class OSTinybird {parameters: z.object({monitorId: z.string(),regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),+ interval: z.int().optional(),fromDate: z.string().optional(),toDate: z.string().optional(),}),@@ -3524,6 +3541,7 @@ export class OSTinybird {parameters: z.object({monitorId: z.string(),regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),+ interval: z.int().optional(),fromDate: z.string().optional(),toDate: z.string().optional(),}),@@ -3544,6 +3562,7 @@ export class OSTinybird {parameters: z.object({monitorId: z.string(),regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),+ interval: z.int().optional(),fromDate: z.string().optional(),toDate: z.string().optional(),}),