: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(billing): add the product catalog to the organization billing api and mcp (#104817)
Alex Mays1a55ad5e8c96
diff --git a/ee/api/organization_billing.py b/ee/api/organization_billing.pyindex 09110df08c79..a2f911cdd32f 100644--- a/ee/api/organization_billing.py+++ b/ee/api/organization_billing.py@@ -257,6 +257,48 @@ class BillingProductsSerializer(serializers.Serializer):results = BillingProductSerializer(many=True)+class BillingProductsSummaryFeatureSerializer(serializers.Serializer):+ key = serializers.CharField(help_text="The feature key.")+ name = serializers.CharField(help_text="The feature name, as the billing page shows it.")+ included = serializers.BooleanField(+ help_text="Whether the feature is available to the organization, trials and overrides included."+ )+ addon_keys = serializers.ListField(+ child=serializers.CharField(),+ help_text="The add-ons of this product that carry the feature. Empty when only the product carries it.",+ )+++class BillingProductsSummaryAddonSerializer(serializers.Serializer):+ key = serializers.CharField(help_text="The add-on key.")+ name = serializers.CharField(help_text="The add-on name, as the billing page shows it.")+ description = serializers.CharField(allow_blank=True, help_text="What the add-on does.")+ subscribed = serializers.BooleanField(+ allow_null=True, help_text="Whether the organization subscribes to the add-on."+ )+++class BillingProductsSummaryProductSerializer(BillingProductsSummaryAddonSerializer):+ key = serializers.CharField(help_text="The product key. Pass it to the product route for prices and plans.")+ name = serializers.CharField(help_text="The product name, as the billing page shows it.")+ description = serializers.CharField(allow_blank=True, help_text="What the product does.")+ subscribed = serializers.BooleanField(+ allow_null=True,+ help_text=(+ "Whether the organization subscribes to the product. Null for an inclusion-only product that carries no "+ "price of its own, such as Platform and support, where the plan the organization is on is what counts."+ ),+ )+ addons = BillingProductsSummaryAddonSerializer(many=True, help_text="The product's add-ons.")+ features = BillingProductsSummaryFeatureSerializer(+ many=True, help_text="The features the product and its add-ons carry, each one listed once."+ )+++class BillingProductsSummarySerializer(serializers.Serializer):+ results = BillingProductsSummaryProductSerializer(many=True, help_text="Every product, add-ons included.")++class UsageKeySummarySerializer(serializers.Serializer):usage_key = serializers.CharField()usage = serializers.IntegerField(allow_null=True)@@ -513,6 +555,7 @@ class OrganizationBillingViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet"features","products","product",+ "summary","usage","usage_status","spend",@@ -710,6 +753,19 @@ class OrganizationBillingViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSetdata = self._manager().get_organization_features(organization, grants)return Response({"available_product_features": data.get("available_product_features", [])})+ @extend_schema(+ operation_id="billing_products_summary_retrieve",+ summary="Get every product in summary",+ description=BETA_NOTICE,+ responses={200: OpenApiResponse(response=BillingProductsSummarySerializer)},+ )+ @action(methods=["GET"], detail=False, url_path="products/summary")+ def summary(self, request: Request, *args: Any, **kwargs: Any) -> Response:+ organization = self.organization+ grants = self._grants(request, organization)+ data = self._manager().get_organization_products_summary(organization, grants)+ return Response({"results": data.get("products", [])})+@extend_schema(operation_id="billing_products_list",summary="List the organization's products",@@ -736,7 +792,9 @@ class OrganizationBillingViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet],responses={200: OpenApiResponse(response=BillingProductSerializer)},)- @action(methods=["GET"], detail=False, url_path=r"products/(?P<product_key>[^/.]+)")+ # The product route takes any word after products/, so it has to leave summary/ to the+ # summary action, which the router registers after it.+ @action(methods=["GET"], detail=False, url_path=r"products/(?P<product_key>(?!summary/?$)[^/.]+)")def product(self, request: Request, *args: Any, product_key: str = "", **kwargs: Any) -> Response:organization = self.organizationgrants = self._grants(request, organization)diff --git a/ee/api/test/test_organization_billing.py b/ee/api/test/test_organization_billing.pyindex 1ed73e7a5643..09f7823605d3 100644--- a/ee/api/test/test_organization_billing.py+++ b/ee/api/test/test_organization_billing.py@@ -284,6 +284,24 @@ class TestOrganizationBillingAPI(OrganizationBillingTestMixin, APILicensedTest):self.assertEqual(response.json()["key"], "product_analytics")self.assertTrue(mock_get.call_args.args[0].endswith("/api/v2/billing/products/product_analytics/"))+ @patch("ee.billing.billing_manager.http_session.get")+ def test_summary_reaches_billings_summary_and_not_a_product_named_summary(self, mock_get):+ product = {+ "key": "platform_and_support",+ "name": "Platform and support",+ "description": "SSO, permission management, and support.",+ "subscribed": None,+ "addons": [{"key": "teams", "name": "Teams", "description": "", "subscribed": False}],+ "features": [+ {"key": "sso_enforcement", "name": "Enforce SSO login", "included": True, "addon_keys": ["teams"]}+ ],+ }+ mock_get.return_value = _response({"status": "ok", "customer_id": 42, "products": [product]})+ response = self.client.get(self._url("products/summary/"))+ self.assertEqual(response.status_code, status.HTTP_200_OK, response.content)+ self.assertEqual(response.json(), {"results": [product]})+ self.assertTrue(mock_get.call_args.args[0].endswith("/api/v2/billing/products/catalog/"))+@patch("ee.billing.billing_manager.http_session.get")def test_billings_refusals_come_back_as_the_matching_errors(self, mock_get):mock_get.return_value = _response({"detail": "No product time_travel."}, 404)@@ -293,6 +311,12 @@ class TestOrganizationBillingAPI(OrganizationBillingTestMixin, APILicensedTest):response = self.client.get(self._url("usage/"))self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)+ # A failure inside billing is not the caller's to fix, so it never reads as a bad request.+ mock_get.return_value = _response({"type": "server_error", "code": "response_invalid"}, 500)+ response = self.client.get(self._url("features/"))+ self.assertEqual(response.status_code, status.HTTP_502_BAD_GATEWAY)+ self.assertEqual(response.json()["code"], "billing_service_error")+# A proxy in front of billing answers HTML, not JSON. The refusal still maps to itself# rather than becoming a 500 on the way through.not_json = MagicMock(status_code=403)diff --git a/ee/billing/billing_manager.py b/ee/billing/billing_manager.pyindex 885d7aee834b..c1aa99db747a 100644--- a/ee/billing/billing_manager.py+++ b/ee/billing/billing_manager.py@@ -247,6 +247,17 @@ def _raise_for_organization_error(res: requests.Response, *, map_not_found: boolThe body is read defensively for the same reason. A non-JSON error, from billing or from aproxy in front of it, must not turn a mapped refusal into a 500."""+ from ee.api.billing import ( # noqa: PLC0415 - circular import+ BILLING_GUIDANCE_ERRORS,+ BillingQueryRejected,+ BillingServiceError,+ )++ if res.status_code >= 500:+ # A billing failure, including a response billing could not build. It is not the caller's+ # to fix, so it never maps to a refusal that tells them to change the request.+ logger.warning("billing_organization_error", upstream_status=res.status_code)+ raise BillingServiceError()if res.status_code not in (400, 403, 404):returntry:@@ -262,8 +273,6 @@ def _raise_for_organization_error(res: requests.Response, *, map_not_found: boolif not map_not_found:returnraise NotFound("Not found.")- from ee.api.billing import BILLING_GUIDANCE_ERRORS, BillingQueryRejected # noqa: PLC0415 - circular import-if code in BILLING_GUIDANCE_ERRORS:raise BILLING_GUIDANCE_ERRORS[code]()raise BillingQueryRejected()@@ -827,6 +836,12 @@ class BillingManager:path = f"products/{product_key}/" if product_key else "products/"return self._organization_get(organization, grants, path, {"include_plans": "true"} if include_plans else None)+ def get_organization_products_summary(+ self, organization: Organization, grants: EffectiveBillingGrants+ ) -> dict[str, Any]:+ # Billing serves this as products/catalog/, the name it shipped with.+ return self._organization_get(organization, grants, "products/catalog/")+def get_organization_usage(self, organization: Organization, grants: EffectiveBillingGrants) -> dict[str, Any]:return self._organization_get(organization, grants, "usage/")diff --git a/products/billing/frontend/e2e/organization-billing-api.spec.ts b/products/billing/frontend/e2e/organization-billing-api.spec.tsindex 5302ae874d0e..cc0c2d19e33f 100644--- a/products/billing/frontend/e2e/organization-billing-api.spec.ts+++ b/products/billing/frontend/e2e/organization-billing-api.spec.ts@@ -56,12 +56,26 @@ test.describe('Organization billing API', () => {expect(product.kind).toBe('product')expect(product).toHaveProperty('key')expect(product).not.toHaveProperty('type')+ for (const entry of [product, ...product.addons]) {+ expect(entry.image_url, entry.key).not.toBe('None')+ expect(entry.docs_url, entry.key).not.toBe('None')+ }for (const addon of product.addons) {expect(addon.kind).toBe('addon')}}expect((await (await get('products/product_analytics/')).json()).key).toBe('product_analytics')+ const summary = (await (await get('products/summary/')).json()).results+ expect(summary.map((product: { key: string }) => product.key)).toEqual(+ products.results.map((product: { key: string }) => product.key)+ )+ for (const product of summary) {+ expect(product).not.toHaveProperty('tiers')+ expect(product).not.toHaveProperty('plans')+ expect(Array.isArray(product.features)).toBe(true)+ }+const usage = await (await get('usage/')).json()expect(usage).toHaveProperty('usage_summary')expect(usage).toHaveProperty('usage_reported_through')@@ -161,6 +175,7 @@ test.describe('Organization billing API', () => {for (const path of ['subscription/', 'features/', 'products/', 'usage/status/']) {expect((await get(path)).status(), path).toBe(200)}+ expect((await get('products/summary/')).status()).toBe(200)for (const path of ['forecast/', 'invoices/', 'limits/']) {expect((await get(path)).status(), path).toBe(403)}diff --git a/products/billing/frontend/generated/api.schemas.ts b/products/billing/frontend/generated/api.schemas.tsindex 4cc60ff0152d..daa20d03b7c3 100644--- a/products/billing/frontend/generated/api.schemas.ts+++ b/products/billing/frontend/generated/api.schemas.ts@@ -971,6 +971,54 @@ export interface BillingProductsApi {results: BillingProductApi[]}+export interface BillingProductsSummaryAddonApi {+ /** The add-on key. */+ key: string+ /** The add-on name, as the billing page shows it. */+ name: string+ /** What the add-on does. */+ description: string+ /**+ * Whether the organization subscribes to the add-on.+ * @nullable+ */+ subscribed: boolean | null+}++export interface BillingProductsSummaryFeatureApi {+ /** The feature key. */+ key: string+ /** The feature name, as the billing page shows it. */+ name: string+ /** Whether the feature is available to the organization, trials and overrides included. */+ included: boolean+ /** The add-ons of this product that carry the feature. Empty when only the product carries it. */+ addon_keys: string[]+}++export interface BillingProductsSummaryProductApi {+ /** The product key. Pass it to the product route for prices and plans. */+ key: string+ /** The product name, as the billing page shows it. */+ name: string+ /** What the product does. */+ description: string+ /**+ * Whether the organization subscribes to the product. Null for an inclusion-only product that carries no price of its own, such as Platform and support, where the plan the organization is on is what counts.+ * @nullable+ */+ subscribed: boolean | null+ /** The product's add-ons. */+ addons: BillingProductsSummaryAddonApi[]+ /** The features the product and its add-ons carry, each one listed once. */+ features: BillingProductsSummaryFeatureApi[]+}++export interface BillingProductsSummaryApi {+ /** Every product, add-ons included. */+ results: BillingProductsSummaryProductApi[]+}+export interface BillingProjectApi {id: number/**diff --git a/products/billing/frontend/generated/api.ts b/products/billing/frontend/generated/api.tsindex 73065c403c36..44477ba2d270 100644--- a/products/billing/frontend/generated/api.ts+++ b/products/billing/frontend/generated/api.ts@@ -28,6 +28,7 @@ import type {BillingProductsApi,BillingProductsListParams,BillingProductsRetrieveParams,+ BillingProductsSummaryApi,BillingProjectsApi,BillingSpendExportRetrieveParams,BillingSpendRetrieveParams,@@ -790,6 +791,24 @@ export const billingProductsRetrieve = async (})}+export const getBillingProductsSummaryRetrieveUrl = (organizationId: string) => {+ return `/api/organizations/${organizationId}/billing/products/summary/`+}++/**+ * In beta: the organization billing API is behind the organization-billing-api feature flag and answers 403 without it, so ask support for access. Its shapes may change while it is in beta.+ * @summary Get every product in summary+ */+export const billingProductsSummaryRetrieve = async (+ organizationId: string,+ options?: RequestInit+): Promise<BillingProductsSummaryApi> => {+ return apiMutator<BillingProductsSummaryApi>(getBillingProductsSummaryRetrieveUrl(organizationId), {+ ...options,+ method: 'GET',+ })+}+export const getBillingProjectListUrl = (organizationId: string) => {return `/api/organizations/${organizationId}/billing/projects/`}diff --git a/products/billing/mcp/tools.yaml b/products/billing/mcp/tools.yamlindex 6e60de58b352..b20daa03a865 100644--- a/products/billing/mcp/tools.yaml+++ b/products/billing/mcp/tools.yaml@@ -192,12 +192,16 @@ tools:idempotent: truetitle: Get one productdescription: >- One product by key, for example product_analytics or session_replay, with its add-ons, price schedule and- subscribed state. Same fields as billing-products-list for a single product. Readable by any member. Beta:- behind the organization-billing-api flag, and the output shape may change while it is.+ One product by key, for example product_analytics or session_replay, with its add-ons, features, price+ schedule and subscribed state. Call billing-products-summary-get first to find the key. Pass+ include_plans=true for the plan list. Readable by any member. Beta: behind the organization-billing-api+ flag, and the output shape may change while it is.feature_flag: organization-billing-apibilling-products-list:operation: billing_products_list+ enabled: false+ billing-products-summary-get:+ operation: billing_products_summary_retrieveenabled: truescopes:- billing:read@@ -205,17 +209,13 @@ tools:readOnly: truedestructive: falseidempotent: true- title: List products+ title: Get every product in summarydescription: >- Every product and add-on with its features, price schedule, allocation, current plan and subscribed state.- Catalog only: usage, spend and forecast live on their own tools. Pass include_plans=true to add each entry's- plan list, which is most of the payload; leave it off unless the question is about plans. Readable by any- member. Beta: behind the organization-billing-api flag, and the output shape may change while it is.- param_overrides:- include_plans:- description: >- Add the plan list to each product and add-on. Most of the payload; pass true only when the question- is about plans or upgrades.+ Every product with its add-ons and the names of its features, without prices or plans. Use it to find the+ product, add-on or feature a question is about. A product or add-on says whether the organization subscribes+ to it. A feature says whether it is available to the organization, trials and overrides included, and lists+ the add-ons that carry it. For prices and plans, pass the product key to billing-product-get. Readable by+ any member. Beta: behind the organization-billing-api flag, and the output shape may change while it is.feature_flag: organization-billing-apiurl_prefix: /organization/billing/overviewbilling-projects-list:@@ -307,9 +307,9 @@ tools:description: >Amounts accrued so far this billing period, before and after discount, per product, add-on and tier, withthe two totals. An organization total, so it needs full billing access: owners always, and admins when- owner-only billing is off. Use it for "what have we spent so far this month"; for the projection to the end- of the period call billing-forecast-get, for history call billing-spend-get. Beta: behind the- organization-billing-api flag, and the output shape may change while it is.+ owner-only billing is off. Use it for "what have we spent so far this month". For the projection to the end+ of the period call billing-forecast-get, and for spend over time call billing-spend-timeseries-get. Beta:+ behind the organization-billing-api flag, and the output shape may change while it is.feature_flag: organization-billing-apiurl_prefix: /organization/billing/spendbilling-spend-timeseries-get:@@ -323,14 +323,14 @@ tools:idempotent: truetitle: Get spend over time by projectdescription: >- Spend over time on the organization billing API, the counterpart of billing-spend-get on the legacy route:- the same series, paged by limit and cursor and clipped to the projects the caller can see. Same dimensional- parameters as billing-usage-get, but values are dollar amounts rather than usage volumes. Requires billing- usage/spend read access: owners always, admins when owner-only billing is off, or members only when- owner-only billing is off and the org has the member read-only billing usage/spend flag enabled. This member- 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.- Beta: behind the organization-billing-api flag, and the output shape may change while it is.+ Spend over time as dollar amounts, per product and per project. Pages by limit and cursor, and returns only+ the projects the caller can see. Needs usage read access. Owners always have it, and admins have it when+ owner-only billing is off. Members have it when owner-only billing is off and the organization allows member+ usage and spend reads. That member grant covers the series only, not the totals on+ billing-spend-summary-get. Use it to investigate a cost spike, compare periods, or attribute spend to+ products or projects. For spend so far this period call billing-spend-summary-get, and for quantities call+ 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: >@@ -392,9 +392,9 @@ tools:The organization's subscription: plan, subscription flag and level, billing period, trial, discounts,startup program labels and billing provider. One small read, readable by any member. Use it to answer "whatplan is this organization on", "when does the billing period end" or "is there an active trial". For usage- against limits call billing-usage-summary-get; for the product catalog call billing-products-list; for- feature access call billing-features-get. Beta: behind the organization-billing-api flag, and the output- shape may change while it is.+ against limits call billing-usage-summary-get; to find a product, add-on or feature call+ billing-products-summary-get; for feature access call billing-features-get. Beta: behind the+ organization-billing-api flag, and the output shape may change while it is.feature_flag: organization-billing-apiurl_prefix: /organization/billing/overviewbilling-subscription-switch-plan-create:@@ -499,12 +499,13 @@ tools:idempotent: truetitle: Get usage this billing perioddescription: >- Usage so far this billing period: per usage key the usage, the limit in effect, today's usage where PostHog- tracks it and whether the resource is being limited right now, and per product and add-on the current usage,- limit, ratio and over-limit flag. Quantities only, with the date the usage was reported through. An- organization total, so it needs full billing access; billing-usage-timeseries-get reads the same numbers per- project with usage read, and billing-usage-status-get is the member's read. Use it for "how many events have- we used"; for amounts call billing-overview-get, for history call billing-usage-get. Beta: behind the+ Usage so far this billing period. Per usage key it returns the usage, the limit in effect and today's usage+ where PostHog tracks it. It also says whether PostHog is limiting the resource right now. Per product and+ add-on it returns the current usage, limit, ratio and over-limit flag. It returns quantities only, with the+ last date the usage reports cover. It is an organization total, so it needs full billing access.+ billing-usage-timeseries-get reads the same numbers per project with usage read access, and+ billing-usage-status-get is the read for members. Use it for "how many events have we used". For amounts+ call billing-spend-summary-get, and for usage over time call billing-usage-timeseries-get. Beta: behind theorganization-billing-api flag, and the output shape may change while it is.feature_flag: organization-billing-apiurl_prefix: /organization/billing/usage@@ -522,15 +523,14 @@ tools:idempotent: truetitle: Get usage over time by projectdescription: >- Usage over time on the organization billing API, the counterpart of billing-usage-get on the legacy route:- the same series, paged by limit and cursor and clipped to the projects the caller can see. Supports per-team- (project) and per-usage-type dimensions. Requires billing usage/spend read access: owners always, admins- when owner-only billing is off, or members only when owner-only billing is off and the org has the member- read-only billing usage/spend flag enabled. This member grant applies only to usage/spend, not- billing-overview-get or billing admin actions. Use this to investigate usage spikes, compare periods, or- attribute usage to specific 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. Beta: behind the- organization-billing-api flag, and the output shape may change while it is.+ Usage over time as quantities, per usage type and per project. Pages by limit and cursor, and returns only+ the projects the caller can see. Needs usage read access. Owners always have it, and admins have it when+ owner-only billing is off. Members have it when owner-only billing is off and the organization allows member+ usage and spend reads. That member grant covers the series only, not the totals on+ billing-usage-summary-get. Use it to investigate a usage spike, compare periods, or attribute usage to+ projects. For usage so far this period call billing-usage-summary-get, and for dollar amounts call+ 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: >diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.jsonindex 712a8bc83fad..2994fff588fe 100644--- a/services/mcp/schema/generated-tool-definitions.json+++ b/services/mcp/schema/generated-tool-definitions.json@@ -1160,7 +1160,7 @@"feature_flag": "billing-mcp-read-tools"},"billing-product-get": {- "description": "One product by key, for example product_analytics or session_replay, with its add-ons, price schedule and subscribed state. Same fields as billing-products-list for a single product. Readable by any member. Beta: behind the organization-billing-api flag, and the output shape may change while it is.",+ "description": "One product by key, for example product_analytics or session_replay, with its add-ons, features, price schedule and subscribed state. Call billing-products-summary-get first to find the key. Pass include_plans=true for the plan list. Readable by any member. Beta: behind the organization-billing-api flag, and the output shape may change while it is.","category": "Billing","feature": "billing","summary": "Get one product",@@ -1174,12 +1174,12 @@},"feature_flag": "organization-billing-api"},- "billing-products-list": {- "description": "Every product and add-on with its features, price schedule, allocation, current plan and subscribed state. Catalog only: usage, spend and forecast live on their own tools. Pass include_plans=true to add each entry's plan list, which is most of the payload; leave it off unless the question is about plans. Readable by any member. Beta: behind the organization-billing-api flag, and the output shape may change while it is.",+ "billing-products-summary-get": {+ "description": "Every product with its add-ons and the names of its features, without prices or plans. Use it to find the product, add-on or feature a question is about. A product or add-on says whether the organization subscribes to it. A feature says whether it is available to the organization, trials and overrides included, and lists the add-ons that carry it. For prices and plans, pass the product key to billing-product-get. Readable by any member. Beta: behind the organization-billing-api flag, and the output shape may change while it is.","category": "Billing","feature": "billing",- "summary": "List products",- "title": "List products",+ "summary": "Get every product in summary",+ "title": "Get every product in summary","required_scopes": ["billing:read"],"annotations": {"destructiveHint": false,@@ -1220,7 +1220,7 @@"feature_flag": "billing-mcp-read-tools"},"billing-spend-summary-get": {- "description": "Amounts accrued so far this billing period, before and after discount, per product, add-on and tier, with the two totals. An organization total, so it needs full billing access: owners always, and admins when owner-only billing is off. Use it for \"what have we spent so far this month\"; for the projection to the end of the period call billing-forecast-get, for history call billing-spend-get. Beta: behind the organization-billing-api flag, and the output shape may change while it is.",+ "description": "Amounts accrued so far this billing period, before and after discount, per product, add-on and tier, with the two totals. An organization total, so it needs full billing access: owners always, and admins when owner-only billing is off. Use it for \"what have we spent so far this month\". For the projection to the end of the period call billing-forecast-get, and for spend over time call billing-spend-timeseries-get. Beta: behind the organization-billing-api flag, and the output shape may change while it is.","category": "Billing","feature": "billing","summary": "Get spend this billing period",@@ -1235,7 +1235,7 @@"feature_flag": "organization-billing-api"},"billing-spend-timeseries-get": {- "description": "Spend over time on the organization billing API, the counterpart of billing-spend-get on the legacy route: the same series, paged by limit and cursor and clipped to the projects the caller can see. Same dimensional parameters as billing-usage-get, but values are dollar amounts rather than usage volumes. Requires billing usage/spend read access: owners always, admins when owner-only billing is off, or members only when owner-only billing is off and the org has the member read-only billing usage/spend flag enabled. This member 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. Beta: behind the organization-billing-api flag, and the output shape may change while it is.",+ "description": "Spend over time as dollar amounts, per product and per project. Pages by limit and cursor, and returns only the projects the caller can see. Needs usage read access. Owners always have it, and admins have it when owner-only billing is off. Members have it when owner-only billing is off and the organization allows member usage and spend reads. That member grant covers the series only, not the totals on billing-spend-summary-get. Use it to investigate a cost spike, compare periods, or attribute spend to products or projects. For spend so far this period call billing-spend-summary-get, and for quantities call billing-usage-timeseries-get. Beta: behind the organization-billing-api flag, and the output shape may change while it is.","category": "Billing","feature": "billing","summary": "Get spend over time by project",@@ -1250,7 +1250,7 @@"feature_flag": "organization-billing-api"},"billing-subscription-get": {- "description": "The organization's subscription: plan, subscription flag and level, billing period, trial, discounts, startup program labels and billing provider. One small read, readable by any member. Use it to answer \"what plan is this organization on\", \"when does the billing period end\" or \"is there an active trial\". For usage against limits call billing-usage-summary-get; for the product catalog call billing-products-list; for feature access call billing-features-get. Beta: behind the organization-billing-api flag, and the output shape may change while it is.",+ "description": "The organization's subscription: plan, subscription flag and level, billing period, trial, discounts, startup program labels and billing provider. One small read, readable by any member. Use it to answer \"what plan is this organization on\", \"when does the billing period end\" or \"is there an active trial\". For usage against limits call billing-usage-summary-get; to find a product, add-on or feature call billing-products-summary-get; for feature access call billing-features-get. Beta: behind the organization-billing-api flag, and the output shape may change while it is.","category": "Billing","feature": "billing","summary": "Get subscription",@@ -1295,7 +1295,7 @@"feature_flag": "organization-billing-api"},"billing-usage-summary-get": {- "description": "Usage so far this billing period: per usage key the usage, the limit in effect, today's usage where PostHog tracks it and whether the resource is being limited right now, and per product and add-on the current usage, limit, ratio and over-limit flag. Quantities only, with the date the usage was reported through. An organization total, so it needs full billing access; billing-usage-timeseries-get reads the same numbers per project with usage read, and billing-usage-status-get is the member's read. Use it for \"how many events have we used\"; for amounts call billing-overview-get, for history call billing-usage-get. Beta: behind the organization-billing-api flag, and the output shape may change while it is.",+ "description": "Usage so far this billing period. Per usage key it returns the usage, the limit in effect and today's usage where PostHog tracks it. It also says whether PostHog is limiting the resource right now. Per product and add-on it returns the current usage, limit, ratio and over-limit flag. It returns quantities only, with the last date the usage reports cover. It is an organization total, so it needs full billing access. billing-usage-timeseries-get reads the same numbers per project with usage read access, and billing-usage-status-get is the read for members. Use it for \"how many events have we used\". For amounts call billing-spend-summary-get, and for usage over time call billing-usage-timeseries-get. Beta: behind the organization-billing-api flag, and the output shape may change while it is.","category": "Billing","feature": "billing","summary": "Get usage this billing period",@@ -1310,7 +1310,7 @@"feature_flag": "organization-billing-api"},"billing-usage-timeseries-get": {- "description": "Usage over time on the organization billing API, the counterpart of billing-usage-get on the legacy route: the same series, paged by limit and cursor and clipped to the projects the caller can see. Supports per-team (project) and per-usage-type dimensions. Requires billing usage/spend read access: owners always, admins when owner-only billing is off, or members only when owner-only billing is off and the org has the member read-only billing usage/spend flag enabled. This member grant applies only to usage/spend, not billing-overview-get or billing admin actions. Use this to investigate usage spikes, compare periods, or attribute usage to specific 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. Beta: behind the organization-billing-api flag, and the output shape may change while it is.",+ "description": "Usage over time as quantities, per usage type and per project. Pages by limit and cursor, and returns only the projects the caller can see. Needs usage read access. Owners always have it, and admins have it when owner-only billing is off. Members have it when owner-only billing is off and the organization allows member usage and spend reads. That member grant covers the series only, not the totals on billing-usage-summary-get. Use it to investigate a usage spike, compare periods, or attribute usage to projects. For usage so far this period call billing-usage-summary-get, and for dollar amounts call billing-spend-timeseries-get. Beta: behind the organization-billing-api flag, and the output shape may change while it is.","category": "Billing","feature": "billing","summary": "Get usage over time by project",diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.jsonindex 77b0545a8613..e8943ba72d7b 100644--- a/services/mcp/schema/tool-definitions-all.json+++ b/services/mcp/schema/tool-definitions-all.json@@ -1175,7 +1175,7 @@"feature_flag": "billing-mcp-read-tools"},"billing-product-get": {- "description": "One product by key, for example product_analytics or session_replay, with its add-ons, price schedule and subscribed state. Same fields as billing-products-list for a single product. Readable by any member. Beta: behind the organization-billing-api flag, and the output shape may change while it is.",+ "description": "One product by key, for example product_analytics or session_replay, with its add-ons, features, price schedule and subscribed state. Call billing-products-summary-get first to find the key. Pass include_plans=true for the plan list. Readable by any member. Beta: behind the organization-billing-api flag, and the output shape may change while it is.","category": "Billing","feature": "billing","summary": "Get one product",@@ -1189,12 +1189,12 @@},"feature_flag": "organization-billing-api"},- "billing-products-list": {- "description": "Every product and add-on with its features, price schedule, allocation, current plan and subscribed state. Catalog only: usage, spend and forecast live on their own tools. Pass include_plans=true to add each entry's plan list, which is most of the payload; leave it off unless the question is about plans. Readable by any member. Beta: behind the organization-billing-api flag, and the output shape may change while it is.",+ "billing-products-summary-get": {+ "description": "Every product with its add-ons and the names of its features, without prices or plans. Use it to find the product, add-on or feature a question is about. A product or add-on says whether the organization subscribes to it. A feature says whether it is available to the organization, trials and overrides included, and lists the add-ons that carry it. For prices and plans, pass the product key to billing-product-get. Readable by any member. Beta: behind the organization-billing-api flag, and the output shape may change while it is.","category": "Billing","feature": "billing",- "summary": "List products",- "title": "List products",+ "summary": "Get every product in summary",+ "title": "Get every product in summary","required_scopes": ["billing:read"],"annotations": {"destructiveHint": false,@@ -1235,7 +1235,7 @@"feature_flag": "billing-mcp-read-tools"},"billing-spend-summary-get": {- "description": "Amounts accrued so far this billing period, before and after discount, per product, add-on and tier, with the two totals. An organization total, so it needs full billing access: owners always, and admins when owner-only billing is off. Use it for \"what have we spent so far this month\"; for the projection to the end of the period call billing-forecast-get, for history call billing-spend-get. Beta: behind the organization-billing-api flag, and the output shape may change while it is.",+ "description": "Amounts accrued so far this billing period, before and after discount, per product, add-on and tier, with the two totals. An organization total, so it needs full billing access: owners always, and admins when owner-only billing is off. Use it for \"what have we spent so far this month\". For the projection to the end of the period call billing-forecast-get, and for spend over time call billing-spend-timeseries-get. Beta: behind the organization-billing-api flag, and the output shape may change while it is.","category": "Billing","feature": "billing","summary": "Get spend this billing period",@@ -1250,7 +1250,7 @@"feature_flag": "organization-billing-api"},"billing-spend-timeseries-get": {- "description": "Spend over time on the organization billing API, the counterpart of billing-spend-get on the legacy route: the same series, paged by limit and cursor and clipped to the projects the caller can see. Same dimensional parameters as billing-usage-get, but values are dollar amounts rather than usage volumes. Requires billing usage/spend read access: owners always, admins when owner-only billing is off, or members only when owner-only billing is off and the org has the member read-only billing usage/spend flag enabled. This member 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. Beta: behind the organization-billing-api flag, and the output shape may change while it is.",+ "description": "Spend over time as dollar amounts, per product and per project. Pages by limit and cursor, and returns only the projects the caller can see. Needs usage read access. Owners always have it, and admins have it when owner-only billing is off. Members have it when owner-only billing is off and the organization allows member usage and spend reads. That member grant covers the series only, not the totals on billing-spend-summary-get. Use it to investigate a cost spike, compare periods, or attribute spend to products or projects. For spend so far this period call billing-spend-summary-get, and for quantities call billing-usage-timeseries-get. Beta: behind the organization-billing-api flag, and the output shape may change while it is.","category": "Billing","feature": "billing","summary": "Get spend over time by project",@@ -1265,7 +1265,7 @@"feature_flag": "organization-billing-api"},"billing-subscription-get": {- "description": "The organization's subscription: plan, subscription flag and level, billing period, trial, discounts, startup program labels and billing provider. One small read, readable by any member. Use it to answer \"what plan is this organization on\", \"when does the billing period end\" or \"is there an active trial\". For usage against limits call billing-usage-summary-get; for the product catalog call billing-products-list; for feature access call billing-features-get. Beta: behind the organization-billing-api flag, and the output shape may change while it is.",+ "description": "The organization's subscription: plan, subscription flag and level, billing period, trial, discounts, startup program labels and billing provider. One small read, readable by any member. Use it to answer \"what plan is this organization on\", \"when does the billing period end\" or \"is there an active trial\". For usage against limits call billing-usage-summary-get; to find a product, add-on or feature call billing-products-summary-get; for feature access call billing-features-get. Beta: behind the organization-billing-api flag, and the output shape may change while it is.","category": "Billing","feature": "billing","summary": "Get subscription",@@ -1310,7 +1310,7 @@"feature_flag": "organization-billing-api"},"billing-usage-summary-get": {- "description": "Usage so far this billing period: per usage key the usage, the limit in effect, today's usage where PostHog tracks it and whether the resource is being limited right now, and per product and add-on the current usage, limit, ratio and over-limit flag. Quantities only, with the date the usage was reported through. An organization total, so it needs full billing access; billing-usage-timeseries-get reads the same numbers per project with usage read, and billing-usage-status-get is the member's read. Use it for \"how many events have we used\"; for amounts call billing-overview-get, for history call billing-usage-get. Beta: behind the organization-billing-api flag, and the output shape may change while it is.",+ "description": "Usage so far this billing period. Per usage key it returns the usage, the limit in effect and today's usage where PostHog tracks it. It also says whether PostHog is limiting the resource right now. Per product and add-on it returns the current usage, limit, ratio and over-limit flag. It returns quantities only, with the last date the usage reports cover. It is an organization total, so it needs full billing access. billing-usage-timeseries-get reads the same numbers per project with usage read access, and billing-usage-status-get is the read for members. Use it for \"how many events have we used\". For amounts call billing-spend-summary-get, and for usage over time call billing-usage-timeseries-get. Beta: behind the organization-billing-api flag, and the output shape may change while it is.","category": "Billing","feature": "billing","summary": "Get usage this billing period",@@ -1325,7 +1325,7 @@"feature_flag": "organization-billing-api"},"billing-usage-timeseries-get": {- "description": "Usage over time on the organization billing API, the counterpart of billing-usage-get on the legacy route: the same series, paged by limit and cursor and clipped to the projects the caller can see. Supports per-team (project) and per-usage-type dimensions. Requires billing usage/spend read access: owners always, admins when owner-only billing is off, or members only when owner-only billing is off and the org has the member read-only billing usage/spend flag enabled. This member grant applies only to usage/spend, not billing-overview-get or billing admin actions. Use this to investigate usage spikes, compare periods, or attribute usage to specific 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. Beta: behind the organization-billing-api flag, and the output shape may change while it is.",+ "description": "Usage over time as quantities, per usage type and per project. Pages by limit and cursor, and returns only the projects the caller can see. Needs usage read access. Owners always have it, and admins have it when owner-only billing is off. Members have it when owner-only billing is off and the organization allows member usage and spend reads. That member grant covers the series only, not the totals on billing-usage-summary-get. Use it to investigate a usage spike, compare periods, or attribute usage to projects. For usage so far this period call billing-usage-summary-get, and for dollar amounts call billing-spend-timeseries-get. Beta: behind the organization-billing-api flag, and the output shape may change while it is.","category": "Billing","feature": "billing","summary": "Get usage over time by project",diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 5c33da6b782e..0f6747488141 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -15779,6 +15779,54 @@ export namespace Schemas {results: BillingProduct[];}+ export interface BillingProductsSummaryAddon {+ /** The add-on key. */+ key: string;+ /** The add-on name, as the billing page shows it. */+ name: string;+ /** What the add-on does. */+ description: string;+ /**+ * Whether the organization subscribes to the add-on.+ * @nullable+ */+ subscribed: boolean | null;+ }++ export interface BillingProductsSummaryFeature {+ /** The feature key. */+ key: string;+ /** The feature name, as the billing page shows it. */+ name: string;+ /** Whether the feature is available to the organization, trials and overrides included. */+ included: boolean;+ /** The add-ons of this product that carry the feature. Empty when only the product carries it. */+ addon_keys: string[];+ }++ export interface BillingProductsSummaryProduct {+ /** The product key. Pass it to the product route for prices and plans. */+ key: string;+ /** The product name, as the billing page shows it. */+ name: string;+ /** What the product does. */+ description: string;+ /**+ * Whether the organization subscribes to the product. Null for an inclusion-only product that carries no price of its own, such as Platform and support, where the plan the organization is on is what counts.+ * @nullable+ */+ subscribed: boolean | null;+ /** The product's add-ons. */+ addons: BillingProductsSummaryAddon[];+ /** The features the product and its add-ons carry, each one listed once. */+ features: BillingProductsSummaryFeature[];+ }++ export interface BillingProductsSummary {+ /** Every product, add-ons included. */+ results: BillingProductsSummaryProduct[];+ }+export interface BillingProject {id: number;/**diff --git a/services/mcp/src/generated/billing/api.ts b/services/mcp/src/generated/billing/api.tsindex 7861d4409aca..39b522660834 100644--- a/services/mcp/src/generated/billing/api.ts+++ b/services/mcp/src/generated/billing/api.ts@@ -151,45 +151,36 @@ export const BillingLimitsRetrieveParams = () => zod.object({/*** In beta: the organization billing API is behind the organization-billing-api feature flag and answers 403 without it, so ask support for access. Its shapes may change while it is in beta.- * @summary List the organization's products+ * @summary Get one product*/-export const BillingProductsListParams = () => zod.object({+export const BillingProductsRetrieveParams = () => zod.object({organization_id: zod.string().describe("ID of the organization you're trying to access. To find the ID of the organization, make a call to \/api\/organizations\/."),+ product_key: zod.string().describe("The product's key."),})-export const billingProductsListQueryIncludePlansDefault = false+export const billingProductsRetrieveQueryIncludePlansDefault = false-export const BillingProductsListQueryParams = () => zod.object({+export const BillingProductsRetrieveQueryParams = () => zod.object({include_plans: zod.boolean()- .default(billingProductsListQueryIncludePlansDefault)+ .default(billingProductsRetrieveQueryIncludePlansDefault).describe('Add the `plans` list to each product and add-on. Most of the payload.'),})/*** In beta: the organization billing API is behind the organization-billing-api feature flag and answers 403 without it, so ask support for access. Its shapes may change while it is in beta.- * @summary Get one product+ * @summary Get every product in summary*/-export const BillingProductsRetrieveParams = () => zod.object({+export const BillingProductsSummaryRetrieveParams = () => zod.object({organization_id: zod.string().describe("ID of the organization you're trying to access. To find the ID of the organization, make a call to \/api\/organizations\/."),- product_key: zod.string().describe("The product's key."),-})--export const billingProductsRetrieveQueryIncludePlansDefault = false--export const BillingProductsRetrieveQueryParams = () => zod.object({- include_plans: zod- .boolean()- .default(billingProductsRetrieveQueryIncludePlansDefault)- .describe('Add the `plans` list to each product and add-on. Most of the payload.'),})/**diff --git a/services/mcp/src/tools/generated/billing.ts b/services/mcp/src/tools/generated/billing.tsindex dd860b3364ac..207b00a786de 100644--- a/services/mcp/src/tools/generated/billing.ts+++ b/services/mcp/src/tools/generated/billing.ts@@ -127,26 +127,19 @@ const billingProductGet = (): ToolBase<ReturnType<typeof BillingProductGetSchema},})-const BillingProductsListSchema = () => {- const BillingProductsListQueryParams = orvalSchemas.BillingProductsListQueryParams()- return BillingProductsListQueryParams.extend({- include_plans: BillingProductsListQueryParams.shape['include_plans'].describe(- 'Add the plan list to each product and add-on. Most of the payload; pass true only when the question is about plans or upgrades.'- ),- })-}+const BillingProductsSummaryGetSchema = () => z.object({})-const billingProductsList = (): ToolBase<ReturnType<typeof BillingProductsListSchema>, Schemas.BillingProducts> => ({- name: 'billing-products-list',- schema: BillingProductsListSchema(),- handler: async (context: Context, params: z.infer<ReturnType<typeof BillingProductsListSchema>>) => {+const billingProductsSummaryGet = (): ToolBase<+ ReturnType<typeof BillingProductsSummaryGetSchema>,+ Schemas.BillingProductsSummary+> => ({+ name: 'billing-products-summary-get',+ schema: BillingProductsSummaryGetSchema(),+ handler: async (context: Context, _params: z.infer<ReturnType<typeof BillingProductsSummaryGetSchema>>) => {const orgId = await context.stateManager.getOrgID()- const result = await context.api.request<Schemas.BillingProducts>({+ const result = await context.api.request<Schemas.BillingProductsSummary>({method: 'GET',- path: `/api/organizations/${encodeURIComponent(String(orgId))}/billing/products/`,- query: {- include_plans: params.include_plans,- },+ path: `/api/organizations/${encodeURIComponent(String(orgId))}/billing/products/summary/`,})return result},@@ -482,7 +475,7 @@ export const GENERATED_TOOLS: Record<string, () => ToolBase<ZodObjectAny>> = {'billing-limits-get': billingLimitsGet,'billing-overview-get': billingOverviewGet,'billing-product-get': billingProductGet,- 'billing-products-list': billingProductsList,+ 'billing-products-summary-get': billingProductsSummaryGet,'billing-projects-list': billingProjectsList,'billing-spend-get': billingSpendGet,'billing-spend-summary-get': billingSpendSummaryGet,