Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(billing): default usage and spend to the last 30 complete days (#107531)

Pawel Cebula8c06f93e4756
diff --git a/docs/published/handbook/engineering/ai/implementing-mcp-tools.md b/docs/published/handbook/engineering/ai/implementing-mcp-tools.md
index 8ecf7e7a7906..8a1737a12682 100644
--- a/docs/published/handbook/engineering/ai/implementing-mcp-tools.md
+++ b/docs/published/handbook/engineering/ai/implementing-mcp-tools.md
@@ -142,6 +142,9 @@ a billing-specific tool wrapper.
The billing usage/spend tools accept `usage_types` as an array of strings.
Their field description lists the accepted identifiers from `ee/billing/billing_types.py`, through the generated API schema.
The MCP client JSON-encodes the array for the HTTP API.
+When both dates are omitted, the shared billing request serializer defaults usage/spend reads to the last 30 complete UTC days, ending yesterday.
+Explicit date ranges are unchanged; a start date without an end date still ends today.
+This also applies to the organization usage/spend time-series endpoints and CSV exports.
The billing overview, usage, and spend tools do not need a rollout flag.
API scopes and billing access checks still apply.
diff --git a/ee/api/billing.py b/ee/api/billing.py
index c24c3fd6e9e2..d1aabb45b28c 100644
--- a/ee/api/billing.py
+++ b/ee/api/billing.py
@@ -1,6 +1,7 @@
import re
import json
from collections.abc import Callable, Sequence
+from datetime import timedelta
from typing import Any, NoReturn, Optional, cast
from zoneinfo import ZoneInfo
@@ -351,8 +352,23 @@ class BillingUsageRequestSerializer(serializers.Serializer):
Only responsible for parsing dates, passes through other params.
"""
- start_date = serializers.CharField(required=False, allow_blank=True, allow_null=True)
- end_date = serializers.CharField(required=False, allow_blank=True, allow_null=True)
+ start_date = serializers.CharField(
+ required=False,
+ allow_blank=True,
+ allow_null=True,
+ help_text=(
+ 'Start date (YYYY-MM-DD, UTC), or "all" for 2020-01-01. If both dates are omitted, defaults to 30 days ago.'
+ ),
+ )
+ end_date = serializers.CharField(
+ required=False,
+ allow_blank=True,
+ allow_null=True,
+ help_text=(
+ "End date (YYYY-MM-DD, UTC), inclusive. Defaults to yesterday if both dates are omitted, "
+ "or today if only start_date is provided."
+ ),
+ )
usage_types = serializers.CharField(
required=False,
allow_blank=True,
@@ -436,8 +452,12 @@ class BillingUsageRequestSerializer(serializers.Serializer):
return self._parse_date(value, "end_date")
def validate(self, attrs: dict[str, Any]) -> dict[str, Any]:
- if attrs.get("start_date") and not attrs.get("end_date"):
- attrs["end_date"] = timezone.now().date().isoformat()
+ today_utc = timezone.now().astimezone(ZoneInfo("UTC")).date()
+ if not attrs.get("start_date") and not attrs.get("end_date"):
+ attrs["start_date"] = (today_utc - timedelta(days=30)).isoformat()
+ attrs["end_date"] = (today_utc - timedelta(days=1)).isoformat()
+ elif attrs.get("start_date") and not attrs.get("end_date"):
+ attrs["end_date"] = today_utc.isoformat()
return attrs
def validate_usage_types(self, value: Optional[str]) -> Optional[str]:
diff --git a/ee/api/test/test_billing.py b/ee/api/test/test_billing.py
index 33b272d49d13..c40e8b811a03 100644
--- a/ee/api/test/test_billing.py
+++ b/ee/api/test/test_billing.py
@@ -1348,7 +1348,7 @@ class TestPartnerBillingLockCoverage(SimpleTestCase):
assert unlocked == self.READ_ONLY_ACTIONS | self.UNLOCKED_WRITE_ACTIONS
-class TestBillingUsageRequestSerializer(TestCase):
+class TestBillingUsageRequestSerializer(SimpleTestCase):
def test_valid_dates(self):
serializer = BillingUsageRequestSerializer(data={"start_date": "2025-01-01", "end_date": "2025-01-31"})
self.assertTrue(serializer.is_valid(), serializer.errors)
@@ -1423,11 +1423,30 @@ class TestBillingUsageRequestSerializer(TestCase):
serializer = BillingUsageRequestSerializer(data={"breakdowns": value})
self.assertTrue(serializer.is_valid(), serializer.errors)
- def test_empty_and_null_dates_are_valid(self):
- serializer = BillingUsageRequestSerializer(data={"start_date": "", "end_date": None})
+ @parameterized.expand(
+ [
+ ("missing", {}),
+ ("empty", {"start_date": "", "end_date": ""}),
+ ("null", {"start_date": None, "end_date": None}),
+ ("empty_start", {"start_date": ""}),
+ ("null_end", {"end_date": None}),
+ ]
+ )
+ @time_machine.travel("2025-02-15T00:30:00+14:00", tick=False)
+ def test_missing_empty_and_null_dates_default_to_last_30_complete_utc_days(
+ self, _case_name: str, data: dict[str, str | None]
+ ) -> None:
+ serializer = BillingUsageRequestSerializer(data=data)
+ self.assertTrue(serializer.is_valid(), serializer.errors)
+ self.assertEqual(serializer.validated_data["start_date"], "2025-01-15")
+ self.assertEqual(serializer.validated_data["end_date"], "2025-02-13")
+
+ @time_machine.travel("2025-02-15", tick=False)
+ def test_end_date_without_start_date_is_preserved(self) -> None:
+ serializer = BillingUsageRequestSerializer(data={"end_date": "2025-02-14"})
self.assertTrue(serializer.is_valid(), serializer.errors)
- self.assertIsNone(serializer.validated_data.get("start_date"))
- self.assertIsNone(serializer.validated_data.get("end_date"))
+ self.assertNotIn("start_date", serializer.validated_data)
+ self.assertEqual(serializer.validated_data["end_date"], "2025-02-14")
class TestBillingUpstreamValidationErrors(SimpleTestCase):
@@ -1617,6 +1636,21 @@ class TestBillingUsageAndSpendAPI(APILicensedTest):
# No teams_map: names are put into the response on the way out.
self.assertNotIn("teams_map", passed_params)
+ @parameterized.expand([("usage",), ("spend",)])
+ @time_machine.travel("2025-02-15T00:30:00+14:00", tick=False)
+ def test_usage_and_spend_default_date_range_is_sent_to_billing(self, endpoint: str) -> None:
+ manager_method = f"ee.billing.billing_manager.BillingManager.get_{endpoint}_data"
+ mock_data = self.MOCK_USAGE_DATA if endpoint == "usage" else self.MOCK_SPEND_DATA
+
+ with patch(manager_method, return_value=mock_data) as mock_fetch:
+ response = self.client.get(f"/api/billing/{endpoint}/")
+
+ self.assertEqual(response.status_code, status.HTTP_200_OK)
+ mock_fetch.assert_called_once()
+ passed_params = mock_fetch.call_args[0][1]
+ self.assertEqual(passed_params["start_date"], "2025-01-15")
+ self.assertEqual(passed_params["end_date"], "2025-02-13")
+
@staticmethod
def _billing_refusal(upstream_status: int, body: object) -> Exception:
# The shape handle_billing_service_error raises: the status in the message, the parsed body third.
diff --git a/products/billing/frontend/generated/api.schemas.ts b/products/billing/frontend/generated/api.schemas.ts
index 8405c01d11a9..f023453c7ee5 100644
--- a/products/billing/frontend/generated/api.schemas.ts
+++ b/products/billing/frontend/generated/api.schemas.ts
@@ -1262,6 +1262,7 @@ export type BillingSpendRetrieveParams = {
*/
breakdowns?: string | null
/**
+ * End date (YYYY-MM-DD, UTC), inclusive. Defaults to yesterday if both dates are omitted, or today if only start_date is provided.
* @nullable
*/
end_date?: string | null
@@ -1277,6 +1278,7 @@ export type BillingSpendRetrieveParams = {
*/
page_size?: number | null
/**
+ * Start date (YYYY-MM-DD, UTC), or "all" for 2020-01-01. If both dates are omitted, defaults to 30 days ago.
* @nullable
*/
start_date?: string | null
@@ -1312,6 +1314,7 @@ export type BillingSpendExportRetrieveParams = {
*/
breakdowns?: string | null
/**
+ * End date (YYYY-MM-DD, UTC), inclusive. Defaults to yesterday if both dates are omitted, or today if only start_date is provided.
* @nullable
*/
end_date?: string | null
@@ -1327,6 +1330,7 @@ export type BillingSpendExportRetrieveParams = {
*/
page_size?: number | null
/**
+ * Start date (YYYY-MM-DD, UTC), or "all" for 2020-01-01. If both dates are omitted, defaults to 30 days ago.
* @nullable
*/
start_date?: string | null
@@ -1362,6 +1366,7 @@ export type BillingUsageRetrieveParams = {
*/
breakdowns?: string | null
/**
+ * End date (YYYY-MM-DD, UTC), inclusive. Defaults to yesterday if both dates are omitted, or today if only start_date is provided.
* @nullable
*/
end_date?: string | null
@@ -1377,6 +1382,7 @@ export type BillingUsageRetrieveParams = {
*/
page_size?: number | null
/**
+ * Start date (YYYY-MM-DD, UTC), or "all" for 2020-01-01. If both dates are omitted, defaults to 30 days ago.
* @nullable
*/
start_date?: string | null
@@ -1412,6 +1418,7 @@ export type BillingUsageExportRetrieveParams = {
*/
breakdowns?: string | null
/**
+ * End date (YYYY-MM-DD, UTC), inclusive. Defaults to yesterday if both dates are omitted, or today if only start_date is provided.
* @nullable
*/
end_date?: string | null
@@ -1427,6 +1434,7 @@ export type BillingUsageExportRetrieveParams = {
*/
page_size?: number | null
/**
+ * Start date (YYYY-MM-DD, UTC), or "all" for 2020-01-01. If both dates are omitted, defaults to 30 days ago.
* @nullable
*/
start_date?: string | null
@@ -1525,6 +1533,7 @@ export type BillingSpendExportDownloadParams = {
*/
breakdowns?: string | null
/**
+ * End date (YYYY-MM-DD, UTC), inclusive. Defaults to yesterday if both dates are omitted, or today if only start_date is provided.
* @nullable
*/
end_date?: string | null
@@ -1533,6 +1542,7 @@ export type BillingSpendExportDownloadParams = {
*/
interval?: string | null
/**
+ * Start date (YYYY-MM-DD, UTC), or "all" for 2020-01-01. If both dates are omitted, defaults to 30 days ago.
* @nullable
*/
start_date?: string | null
@@ -1568,6 +1578,7 @@ export type BillingSpendTimeseriesRetrieveParams = {
*/
cursor?: string | null
/**
+ * End date (YYYY-MM-DD, UTC), inclusive. Defaults to yesterday if both dates are omitted, or today if only start_date is provided.
* @nullable
*/
end_date?: string | null
@@ -1583,6 +1594,7 @@ export type BillingSpendTimeseriesRetrieveParams = {
*/
limit?: number | null
/**
+ * Start date (YYYY-MM-DD, UTC), or "all" for 2020-01-01. If both dates are omitted, defaults to 30 days ago.
* @nullable
*/
start_date?: string | null
@@ -1612,6 +1624,7 @@ export type BillingUsageExportDownloadParams = {
*/
breakdowns?: string | null
/**
+ * End date (YYYY-MM-DD, UTC), inclusive. Defaults to yesterday if both dates are omitted, or today if only start_date is provided.
* @nullable
*/
end_date?: string | null
@@ -1620,6 +1633,7 @@ export type BillingUsageExportDownloadParams = {
*/
interval?: string | null
/**
+ * Start date (YYYY-MM-DD, UTC), or "all" for 2020-01-01. If both dates are omitted, defaults to 30 days ago.
* @nullable
*/
start_date?: string | null
@@ -1655,6 +1669,7 @@ export type BillingUsageTimeseriesRetrieveParams = {
*/
cursor?: string | null
/**
+ * End date (YYYY-MM-DD, UTC), inclusive. Defaults to yesterday if both dates are omitted, or today if only start_date is provided.
* @nullable
*/
end_date?: string | null
@@ -1670,6 +1685,7 @@ export type BillingUsageTimeseriesRetrieveParams = {
*/
limit?: number | null
/**
+ * Start date (YYYY-MM-DD, UTC), or "all" for 2020-01-01. If both dates are omitted, defaults to 30 days ago.
* @nullable
*/
start_date?: string | null
diff --git a/products/billing/mcp/tools.yaml b/products/billing/mcp/tools.yaml
index ebef462cd846..a2703c7c3cb6 100644
--- a/products/billing/mcp/tools.yaml
+++ b/products/billing/mcp/tools.yaml
@@ -264,14 +264,6 @@ tools:
grant applies only to usage/spend, not billing-overview-get or billing admin actions. Use this to
investigate cost spikes, compare spend across periods, or attribute spend to specific products or teams.
param_overrides:
- start_date:
- description: >
- Start date (YYYY-MM-DD). For open-ended investigations, choose an explicit recent window such as the
- last 30 days. If you use "all", also pass end_date.
- end_date:
- description: >
- End date (YYYY-MM-DD), inclusive. Pass this whenever start_date is set; use today's date if the user
- did not name one.
team_ids:
input_schema: BillingTeamIdsSchema
usage_types:
@@ -333,14 +325,6 @@ tools:
billing-usage-timeseries-get. Beta: behind the organization-billing-api flag, and the output shape may
change while it is.
param_overrides:
- start_date:
- description: >
- Start date (YYYY-MM-DD). For open-ended investigations, choose an explicit recent window such as the
- last 30 days. If you use "all", also pass end_date.
- end_date:
- description: >
- End date (YYYY-MM-DD), inclusive. Pass this whenever start_date is set; use today's date if the user
- did not name one.
team_ids:
description: >
JSON-encoded array of numeric team (project) IDs to filter by, NOT a comma-separated string. Pass as
@@ -432,14 +416,6 @@ tools:
projects. For a single-snapshot aggregate view call billing-overview-get when the caller has full billing
access; for cost (spend) breakdowns call billing-spend-get.
param_overrides:
- start_date:
- description: >
- Start date (YYYY-MM-DD). For open-ended investigations, choose an explicit recent window such as the
- last 30 days. If you use "all", also pass end_date.
- end_date:
- description: >
- End date (YYYY-MM-DD), inclusive. Pass this whenever start_date is set; use today's date if the user
- did not name one.
team_ids:
input_schema: BillingTeamIdsSchema
usage_types:
@@ -535,14 +511,6 @@ tools:
billing-spend-timeseries-get. Beta: behind the organization-billing-api flag, and the output shape may
change while it is.
param_overrides:
- start_date:
- description: >
- Start date (YYYY-MM-DD). For open-ended investigations, choose an explicit recent window such as the
- last 30 days. If you use "all", also pass end_date.
- end_date:
- description: >
- End date (YYYY-MM-DD), inclusive. Pass this whenever start_date is set; use today's date if the user
- did not name one.
team_ids:
description: >
JSON-encoded array of numeric team (project) IDs to filter by, NOT a comma-separated string. Pass as
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 31c210d14587..36c91ae9687e 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -109857,6 +109857,7 @@ export namespace Schemas {
*/
breakdowns?: string | null;
/**
+ * End date (YYYY-MM-DD, UTC), inclusive. Defaults to yesterday if both dates are omitted, or today if only start_date is provided.
* @nullable
*/
end_date?: string | null;
@@ -109872,6 +109873,7 @@ export namespace Schemas {
*/
page_size?: number | null;
/**
+ * Start date (YYYY-MM-DD, UTC), or "all" for 2020-01-01. If both dates are omitted, defaults to 30 days ago.
* @nullable
*/
start_date?: string | null;
@@ -109907,6 +109909,7 @@ export namespace Schemas {
*/
breakdowns?: string | null;
/**
+ * End date (YYYY-MM-DD, UTC), inclusive. Defaults to yesterday if both dates are omitted, or today if only start_date is provided.
* @nullable
*/
end_date?: string | null;
@@ -109922,6 +109925,7 @@ export namespace Schemas {
*/
page_size?: number | null;
/**
+ * Start date (YYYY-MM-DD, UTC), or "all" for 2020-01-01. If both dates are omitted, defaults to 30 days ago.
* @nullable
*/
start_date?: string | null;
@@ -109957,6 +109961,7 @@ export namespace Schemas {
*/
breakdowns?: string | null;
/**
+ * End date (YYYY-MM-DD, UTC), inclusive. Defaults to yesterday if both dates are omitted, or today if only start_date is provided.
* @nullable
*/
end_date?: string | null;
@@ -109972,6 +109977,7 @@ export namespace Schemas {
*/
page_size?: number | null;
/**
+ * Start date (YYYY-MM-DD, UTC), or "all" for 2020-01-01. If both dates are omitted, defaults to 30 days ago.
* @nullable
*/
start_date?: string | null;
@@ -110007,6 +110013,7 @@ export namespace Schemas {
*/
breakdowns?: string | null;
/**
+ * End date (YYYY-MM-DD, UTC), inclusive. Defaults to yesterday if both dates are omitted, or today if only start_date is provided.
* @nullable
*/
end_date?: string | null;
@@ -110022,6 +110029,7 @@ export namespace Schemas {
*/
page_size?: number | null;
/**
+ * Start date (YYYY-MM-DD, UTC), or "all" for 2020-01-01. If both dates are omitted, defaults to 30 days ago.
* @nullable
*/
start_date?: string | null;
@@ -110440,6 +110448,7 @@ export namespace Schemas {
*/
breakdowns?: string | null;
/**
+ * End date (YYYY-MM-DD, UTC), inclusive. Defaults to yesterday if both dates are omitted, or today if only start_date is provided.
* @nullable
*/
end_date?: string | null;
@@ -110448,6 +110457,7 @@ export namespace Schemas {
*/
interval?: string | null;
/**
+ * Start date (YYYY-MM-DD, UTC), or "all" for 2020-01-01. If both dates are omitted, defaults to 30 days ago.
* @nullable
*/
start_date?: string | null;
@@ -110483,6 +110493,7 @@ export namespace Schemas {
*/
cursor?: string | null;
/**
+ * End date (YYYY-MM-DD, UTC), inclusive. Defaults to yesterday if both dates are omitted, or today if only start_date is provided.
* @nullable
*/
end_date?: string | null;
@@ -110498,6 +110509,7 @@ export namespace Schemas {
*/
limit?: number | null;
/**
+ * Start date (YYYY-MM-DD, UTC), or "all" for 2020-01-01. If both dates are omitted, defaults to 30 days ago.
* @nullable
*/
start_date?: string | null;
@@ -110527,6 +110539,7 @@ export namespace Schemas {
*/
breakdowns?: string | null;
/**
+ * End date (YYYY-MM-DD, UTC), inclusive. Defaults to yesterday if both dates are omitted, or today if only start_date is provided.
* @nullable
*/
end_date?: string | null;
@@ -110535,6 +110548,7 @@ export namespace Schemas {
*/
interval?: string | null;
/**
+ * Start date (YYYY-MM-DD, UTC), or "all" for 2020-01-01. If both dates are omitted, defaults to 30 days ago.
* @nullable
*/
start_date?: string | null;
@@ -110570,6 +110584,7 @@ export namespace Schemas {
*/
cursor?: string | null;
/**
+ * End date (YYYY-MM-DD, UTC), inclusive. Defaults to yesterday if both dates are omitted, or today if only start_date is provided.
* @nullable
*/
end_date?: string | null;
@@ -110585,6 +110600,7 @@ export namespace Schemas {
*/
limit?: number | null;
/**
+ * Start date (YYYY-MM-DD, UTC), or "all" for 2020-01-01. If both dates are omitted, defaults to 30 days ago.
* @nullable
*/
start_date?: string | null;
diff --git a/services/mcp/src/generated/billing/api.ts b/services/mcp/src/generated/billing/api.ts
index 39b522660834..e20d71de48ce 100644
--- a/services/mcp/src/generated/billing/api.ts
+++ b/services/mcp/src/generated/billing/api.ts
@@ -29,7 +29,12 @@ export const BillingSpendRetrieveQueryParams = () => zod.object({
.describe(
'JSON-encoded array of breakdown dimensions. Valid values are \"type\" and \"team\", for example [\"type\",\"team\"]. Omit for a single aggregate series.'
),
- end_date: zod.string().nullish(),
+ end_date: zod
+ .string()
+ .nullish()
+ .describe(
+ 'End date (YYYY-MM-DD, UTC), inclusive. Defaults to yesterday if both dates are omitted, or today if only start_date is provided.'
+ ),
interval: zod.string().nullish(),
page_size: zod
.number()
@@ -39,7 +44,12 @@ export const BillingSpendRetrieveQueryParams = () => zod.object({
.describe(
'Return at most this many series, ranked by total, with a `next` cursor for the page after. A caller that pages never approaches the size this endpoint refuses oversized breakdowns at. Requires a project breakdown.'
),
- start_date: zod.string().nullish(),
+ start_date: zod
+ .string()
+ .nullish()
+ .describe(
+ 'Start date (YYYY-MM-DD, UTC), or \"all\" for 2020-01-01. If both dates are omitted, defaults to 30 days ago.'
+ ),
team_ids: zod
.string()
.nullish()
@@ -80,7 +90,12 @@ export const BillingUsageRetrieveQueryParams = () => zod.object({
.describe(
'JSON-encoded array of breakdown dimensions. Valid values are \"type\" and \"team\", for example [\"type\",\"team\"]. Omit for a single aggregate series.'
),
- end_date: zod.string().nullish(),
+ end_date: zod
+ .string()
+ .nullish()
+ .describe(
+ 'End date (YYYY-MM-DD, UTC), inclusive. Defaults to yesterday if both dates are omitted, or today if only start_date is provided.'
+ ),
interval: zod.string().nullish(),
page_size: zod
.number()
@@ -90,7 +105,12 @@ export const BillingUsageRetrieveQueryParams = () => zod.object({
.describe(
'Return at most this many series, ranked by total, with a `next` cursor for the page after. A caller that pages never approaches the size this endpoint refuses oversized breakdowns at. Requires a project breakdown.'
),
- start_date: zod.string().nullish(),
+ start_date: zod
+ .string()
+ .nullish()
+ .describe(
+ 'Start date (YYYY-MM-DD, UTC), or \"all\" for 2020-01-01. If both dates are omitted, defaults to 30 days ago.'
+ ),
team_ids: zod
.string()
.nullish()
@@ -237,7 +257,12 @@ export const BillingSpendTimeseriesRetrieveQueryParams = () => zod.object({
.max(billingSpendTimeseriesRetrieveQueryCursorMax)
.nullish()
.describe("The cursor from a previous page's `next` link. Opaque. Ignored without `limit`."),
- end_date: zod.string().nullish(),
+ end_date: zod
+ .string()
+ .nullish()
+ .describe(
+ 'End date (YYYY-MM-DD, UTC), inclusive. Defaults to yesterday if both dates are omitted, or today if only start_date is provided.'
+ ),
interval: zod.string().nullish(),
limit: zod
.number()
@@ -247,7 +272,12 @@ export const BillingSpendTimeseriesRetrieveQueryParams = () => zod.object({
.describe(
'Series per page, ranked by total, with a `next` link for the page after. Requires a project breakdown and is ignored without one. Omit it to get every series at once.'
),
- start_date: zod.string().nullish(),
+ start_date: zod
+ .string()
+ .nullish()
+ .describe(
+ 'Start date (YYYY-MM-DD, UTC), or \"all\" for 2020-01-01. If both dates are omitted, defaults to 30 days ago.'
+ ),
team_ids: zod
.string()
.nullish()
@@ -336,7 +366,12 @@ export const BillingUsageTimeseriesRetrieveQueryParams = () => zod.object({
.max(billingUsageTimeseriesRetrieveQueryCursorMax)
.nullish()
.describe("The cursor from a previous page's `next` link. Opaque. Ignored without `limit`."),
- end_date: zod.string().nullish(),
+ end_date: zod
+ .string()
+ .nullish()
+ .describe(
+ 'End date (YYYY-MM-DD, UTC), inclusive. Defaults to yesterday if both dates are omitted, or today if only start_date is provided.'
+ ),
interval: zod.string().nullish(),
limit: zod
.number()
@@ -346,7 +381,12 @@ export const BillingUsageTimeseriesRetrieveQueryParams = () => zod.object({
.describe(
'Series per page, ranked by total, with a `next` link for the page after. Requires a project breakdown and is ignored without one. Omit it to get every series at once.'
),
- start_date: zod.string().nullish(),
+ start_date: zod
+ .string()
+ .nullish()
+ .describe(
+ 'Start date (YYYY-MM-DD, UTC), or \"all\" for 2020-01-01. If both dates are omitted, defaults to 30 days ago.'
+ ),
team_ids: zod
.string()
.nullish()
diff --git a/services/mcp/src/tools/generated/billing.ts b/services/mcp/src/tools/generated/billing.ts
index 207b00a786de..5bc8f2507b18 100644
--- a/services/mcp/src/tools/generated/billing.ts
+++ b/services/mcp/src/tools/generated/billing.ts
@@ -170,12 +170,6 @@ const billingProjectsList = (): ToolBase<
const BillingSpendGetSchema = () => {
const BillingSpendRetrieveQueryParams = orvalSchemas.BillingSpendRetrieveQueryParams()
return BillingSpendRetrieveQueryParams.extend({
- start_date: BillingSpendRetrieveQueryParams.shape['start_date'].describe(
- 'Start date (YYYY-MM-DD). For open-ended investigations, choose an explicit recent window such as the last 30 days. If you use "all", also pass end_date.'
- ),
- end_date: BillingSpendRetrieveQueryParams.shape['end_date'].describe(
- "End date (YYYY-MM-DD), inclusive. Pass this whenever start_date is set; use today's date if the user did not name one."
- ),
team_ids: BillingTeamIdsSchema,
usage_types: BillingUsageTypesSchema,
breakdowns: BillingSpendBreakdownsSchema,
@@ -239,12 +233,6 @@ const billingSpendSummaryGet = (): ToolBase<
const BillingSpendTimeseriesGetSchema = () => {
const BillingSpendTimeseriesRetrieveQueryParams = orvalSchemas.BillingSpendTimeseriesRetrieveQueryParams()
return BillingSpendTimeseriesRetrieveQueryParams.extend({
- start_date: BillingSpendTimeseriesRetrieveQueryParams.shape['start_date'].describe(
- 'Start date (YYYY-MM-DD). For open-ended investigations, choose an explicit recent window such as the last 30 days. If you use "all", also pass end_date.'
- ),
- end_date: BillingSpendTimeseriesRetrieveQueryParams.shape['end_date'].describe(
- "End date (YYYY-MM-DD), inclusive. Pass this whenever start_date is set; use today's date if the user did not name one."
- ),
team_ids: BillingSpendTimeseriesRetrieveQueryParams.shape['team_ids'].describe(
"JSON-encoded array of numeric team (project) IDs to filter by, NOT a comma-separated string. Pass as e.g. `[1,2]`. Omit for every project this request can see: all org teams for full billing-access callers, or the member's visible/project-scoped teams for member read-only callers."
),
@@ -315,12 +303,6 @@ const billingSubscriptionGet = (): ToolBase<
const BillingUsageGetSchema = () => {
const BillingUsageRetrieveQueryParams = orvalSchemas.BillingUsageRetrieveQueryParams()
return BillingUsageRetrieveQueryParams.extend({
- start_date: BillingUsageRetrieveQueryParams.shape['start_date'].describe(
- 'Start date (YYYY-MM-DD). For open-ended investigations, choose an explicit recent window such as the last 30 days. If you use "all", also pass end_date.'
- ),
- end_date: BillingUsageRetrieveQueryParams.shape['end_date'].describe(
- "End date (YYYY-MM-DD), inclusive. Pass this whenever start_date is set; use today's date if the user did not name one."
- ),
team_ids: BillingTeamIdsSchema,
usage_types: BillingUsageTypesSchema,
breakdowns: BillingUsageBreakdownsSchema,
@@ -408,12 +390,6 @@ const billingUsageSummaryGet = (): ToolBase<
const BillingUsageTimeseriesGetSchema = () => {
const BillingUsageTimeseriesRetrieveQueryParams = orvalSchemas.BillingUsageTimeseriesRetrieveQueryParams()
return BillingUsageTimeseriesRetrieveQueryParams.extend({
- start_date: BillingUsageTimeseriesRetrieveQueryParams.shape['start_date'].describe(
- 'Start date (YYYY-MM-DD). For open-ended investigations, choose an explicit recent window such as the last 30 days. If you use "all", also pass end_date.'
- ),
- end_date: BillingUsageTimeseriesRetrieveQueryParams.shape['end_date'].describe(
- "End date (YYYY-MM-DD), inclusive. Pass this whenever start_date is set; use today's date if the user did not name one."
- ),
team_ids: BillingUsageTimeseriesRetrieveQueryParams.shape['team_ids'].describe(
"JSON-encoded array of numeric team (project) IDs to filter by, NOT a comma-separated string. Pass as e.g. `[1,2]`. Omit for every project this request can see: all org teams for full billing-access callers, or the member's visible/project-scoped teams for member read-only callers."
),
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/billing-spend-get.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/billing-spend-get.json
index 2f16f5da6410..f8a5cc9e0729 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/billing-spend-get.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/billing-spend-get.json
@@ -37,7 +37,7 @@
"type": "null"
}
],
- "description": "End date (YYYY-MM-DD), inclusive. Pass this whenever start_date is set; use today's date if the user did not name one."
+ "description": "End date (YYYY-MM-DD, UTC), inclusive. Defaults to yesterday if both dates are omitted, or today if only start_date is provided."
},
"interval": {
"anyOf": [
@@ -72,7 +72,7 @@
"type": "null"
}
],
- "description": "Start date (YYYY-MM-DD). For open-ended investigations, choose an explicit recent window such as the last 30 days. If you use \"all\", also pass end_date."
+ "description": "Start date (YYYY-MM-DD, UTC), or \"all\" for 2020-01-01. If both dates are omitted, defaults to 30 days ago."
},
"team_ids": {
"anyOf": [
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/billing-usage-get.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/billing-usage-get.json
index 3266a9951df0..06f53e9652e3 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/billing-usage-get.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/billing-usage-get.json
@@ -37,7 +37,7 @@
"type": "null"
}
],
- "description": "End date (YYYY-MM-DD), inclusive. Pass this whenever start_date is set; use today's date if the user did not name one."
+ "description": "End date (YYYY-MM-DD, UTC), inclusive. Defaults to yesterday if both dates are omitted, or today if only start_date is provided."
},
"interval": {
"anyOf": [
@@ -72,7 +72,7 @@
"type": "null"
}
],
- "description": "Start date (YYYY-MM-DD). For open-ended investigations, choose an explicit recent window such as the last 30 days. If you use \"all\", also pass end_date."
+ "description": "Start date (YYYY-MM-DD, UTC), or \"all\" for 2020-01-01. If both dates are omitted, defaults to 30 days ago."
},
"team_ids": {
"anyOf": [