: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(flags): expose evaluation_runtime and bucketing_identifier in MCP flag tools (#64120)
Phil Haack4f4beaef6978
diff --git a/products/feature_flags/backend/api/feature_flag.py b/products/feature_flags/backend/api/feature_flag.pyindex cf0d1577bc3c..04aad64686c5 100644--- a/products/feature_flags/backend/api/feature_flag.py+++ b/products/feature_flags/backend/api/feature_flag.py@@ -644,6 +644,20 @@ class FeatureFlagCreateRequestSchemaSerializer(serializers.Serializer):help_text="Whether to persist a user's flag value across the anonymous-to-identified transition ""(the 'persist across authentication steps' option). Incompatible with device_id bucketing.",)+ evaluation_runtime = serializers.ChoiceField(+ choices=FeatureFlag.EVALUATION_RUNTIME_CHOICES,+ required=False,+ allow_null=True,+ help_text="Where this flag is allowed to evaluate: 'server' (server-side SDKs only), "+ "'client' (client-side SDKs only), or 'all' (both). Defaults to 'all'.",+ )+ bucketing_identifier = serializers.ChoiceField(+ choices=FeatureFlag.BUCKETING_IDENTIFIER_CHOICES,+ required=False,+ allow_null=True,+ help_text="Identifier used to bucket users into rollout percentages and variants: 'distinct_id' "+ "(user ID, the default) or 'device_id'. Using 'device_id' is incompatible with ensure_experience_continuity=True.",+ )class FeatureFlagPartialUpdateRequestSchemaSerializer(serializers.Serializer):@@ -676,6 +690,20 @@ class FeatureFlagPartialUpdateRequestSchemaSerializer(serializers.Serializer):help_text="Whether to persist a user's flag value across the anonymous-to-identified transition ""(the 'persist across authentication steps' option). Incompatible with device_id bucketing.",)+ evaluation_runtime = serializers.ChoiceField(+ choices=FeatureFlag.EVALUATION_RUNTIME_CHOICES,+ required=False,+ allow_null=True,+ help_text="Where this flag is allowed to evaluate: 'server' (server-side SDKs only), "+ "'client' (client-side SDKs only), or 'all' (both). Defaults to 'all'.",+ )+ bucketing_identifier = serializers.ChoiceField(+ choices=FeatureFlag.BUCKETING_IDENTIFIER_CHOICES,+ required=False,+ allow_null=True,+ help_text="Identifier used to bucket users into rollout percentages and variants: 'distinct_id' "+ "(user ID, the default) or 'device_id'. Using 'device_id' is incompatible with ensure_experience_continuity=True.",+ )class FeatureFlagExperimentSetMetadataSerializer(serializers.Serializer):diff --git a/products/feature_flags/backend/api/test/feature_flag_openapi_test_helpers.py b/products/feature_flags/backend/api/test/feature_flag_openapi_test_helpers.pyindex 04c0be2d46e3..0c17b3290527 100644--- a/products/feature_flags/backend/api/test/feature_flag_openapi_test_helpers.py+++ b/products/feature_flags/backend/api/test/feature_flag_openapi_test_helpers.py@@ -14,11 +14,9 @@ FEATURE_FLAG_REQUEST_SCHEMA_EXCLUDED_RUNTIME_FIELDS: frozenset[str] = frozenset("_create_in_folder", # create-only write_only helper for folder placement"_should_create_usage_dashboard", # create-only write_only internal toggle"analytics_dashboards", # relational link managed via dashboards, not the flag create/update surface- "bucketing_identifier", # runtime-writable but not yet on the agent-facing MCP contract; candidate for future exposure (#63823)"created_at", # server-managed timestamp, not agent-facing"creation_context", # write_only origin-product marker set by internal callers"deleted", # soft-delete handled via the DELETE endpoint, not the create/update body- "evaluation_runtime", # runtime-writable but not yet on the agent-facing MCP contract; candidate for future exposure (#63823)"has_encrypted_payloads", # server-managed, derived from payload encryption"has_enriched_analytics", # internal analytics flag, not agent-facing"last_called_at", # server-managed usage timestamp, not agent-facingdiff --git a/products/feature_flags/frontend/generated/api.schemas.ts b/products/feature_flags/frontend/generated/api.schemas.tsindex 8b8320eefe7d..f9f21a06fc88 100644--- a/products/feature_flags/frontend/generated/api.schemas.ts+++ b/products/feature_flags/frontend/generated/api.schemas.ts@@ -706,6 +706,17 @@ export interface FeatureFlagCreateRequestSchemaApi {* @nullable*/ensure_experience_continuity?: boolean | null+ /** Where this flag is allowed to evaluate: 'server' (server-side SDKs only), 'client' (client-side SDKs only), or 'all' (both). Defaults to 'all'.+ *+ * * `server` - Server+ * * `client` - Client+ * * `all` - All */+ evaluation_runtime?: EvaluationRuntimeEnumApi | null+ /** Identifier used to bucket users into rollout percentages and variants: 'distinct_id' (user ID, the default) or 'device_id'. Using 'device_id' is incompatible with ensure_experience_continuity=True.+ *+ * * `distinct_id` - User ID (default)+ * * `device_id` - Device ID */+ bucketing_identifier?: BucketingIdentifierEnumApi | null}export interface PatchedFeatureFlagPartialUpdateRequestSchemaApi {@@ -731,6 +742,17 @@ export interface PatchedFeatureFlagPartialUpdateRequestSchemaApi {* @nullable*/ensure_experience_continuity?: boolean | null+ /** Where this flag is allowed to evaluate: 'server' (server-side SDKs only), 'client' (client-side SDKs only), or 'all' (both). Defaults to 'all'.+ *+ * * `server` - Server+ * * `client` - Client+ * * `all` - All */+ evaluation_runtime?: EvaluationRuntimeEnumApi | null+ /** Identifier used to bucket users into rollout percentages and variants: 'distinct_id' (user ID, the default) or 'device_id'. Using 'device_id' is incompatible with ensure_experience_continuity=True.+ *+ * * `distinct_id` - User ID (default)+ * * `device_id` - Device ID */+ bucketing_identifier?: BucketingIdentifierEnumApi | null}export interface ChangeApi {diff --git a/products/feature_flags/frontend/generated/api.zod.ts b/products/feature_flags/frontend/generated/api.zod.tsindex 4d48e13d4eed..9271ad4f4d2c 100644--- a/products/feature_flags/frontend/generated/api.zod.ts+++ b/products/feature_flags/frontend/generated/api.zod.ts@@ -378,6 +378,28 @@ export const FeatureFlagsCreateBody = /* @__PURE__ */ zod.object({.describe("Whether to persist a user's flag value across the anonymous-to-identified transition (the 'persist across authentication steps' option). Incompatible with device_id bucketing."),+ evaluation_runtime: zod+ .union([+ zod+ .enum(['server', 'client', 'all'])+ .describe('\* `server` - Server\n\* `client` - Client\n\* `all` - All'),+ zod.null(),+ ])+ .optional()+ .describe(+ "Where this flag is allowed to evaluate: 'server' (server-side SDKs only), 'client' (client-side SDKs only), or 'all' (both). Defaults to 'all'.\n\n\* `server` - Server\n\* `client` - Client\n\* `all` - All"+ ),+ bucketing_identifier: zod+ .union([+ zod+ .enum(['distinct_id', 'device_id'])+ .describe('\* `distinct_id` - User ID (default)\n\* `device_id` - Device ID'),+ zod.null(),+ ])+ .optional()+ .describe(+ "Identifier used to bucket users into rollout percentages and variants: 'distinct_id' (user ID, the default) or 'device_id'. Using 'device_id' is incompatible with ensure_experience_continuity=True.\n\n\* `distinct_id` - User ID (default)\n\* `device_id` - Device ID"+ ),})/**@@ -771,6 +793,28 @@ export const FeatureFlagsPartialUpdateBody = /* @__PURE__ */ zod.object({.describe("Whether to persist a user's flag value across the anonymous-to-identified transition (the 'persist across authentication steps' option). Incompatible with device_id bucketing."),+ evaluation_runtime: zod+ .union([+ zod+ .enum(['server', 'client', 'all'])+ .describe('\* `server` - Server\n\* `client` - Client\n\* `all` - All'),+ zod.null(),+ ])+ .optional()+ .describe(+ "Where this flag is allowed to evaluate: 'server' (server-side SDKs only), 'client' (client-side SDKs only), or 'all' (both). Defaults to 'all'.\n\n\* `server` - Server\n\* `client` - Client\n\* `all` - All"+ ),+ bucketing_identifier: zod+ .union([+ zod+ .enum(['distinct_id', 'device_id'])+ .describe('\* `distinct_id` - User ID (default)\n\* `device_id` - Device ID'),+ zod.null(),+ ])+ .optional()+ .describe(+ "Identifier used to bucket users into rollout percentages and variants: 'distinct_id' (user ID, the default) or 'device_id'. Using 'device_id' is incompatible with ensure_experience_continuity=True.\n\n\* `distinct_id` - User ID (default)\n\* `device_id` - Device ID"+ ),})/**diff --git a/products/feature_flags/mcp/tools.yaml b/products/feature_flags/mcp/tools.yamlindex 6b1e356ff4ce..c828bdc4c2c3 100644--- a/products/feature_flags/mcp/tools.yaml+++ b/products/feature_flags/mcp/tools.yaml@@ -43,6 +43,8 @@ tools:- evaluation_contexts- is_remote_configuration- ensure_experience_continuity+ - evaluation_runtime+ - bucketing_identifierparam_overrides:is_remote_configuration:description:@@ -54,6 +56,14 @@ tools:Whether to persist the flag's value for a user across the anonymous-to-identified transition (the "persistacross authentication steps" option in the UI). Keeps a user's evaluated value stable once they login. Incompatible with `device_id` bucketing.+ evaluation_runtime:+ description:+ Where this flag is allowed to evaluate — `server` (server-side SDKs only), `client` (client-side SDKs+ only), or `all` (both). Defaults to `all`.+ bucketing_identifier:+ description:+ Identifier used to bucket users into rollout percentages and variants — `distinct_id` (user ID, the+ default) or `device_id`. Using `device_id` is incompatible with `ensure_experience_continuity=true`.delete-feature-flag:operation: feature_flags_destroyenabled: true@@ -433,6 +443,8 @@ tools:- evaluation_contexts- is_remote_configuration- ensure_experience_continuity+ - evaluation_runtime+ - bucketing_identifierparam_overrides:id:cast: string-int@@ -446,3 +458,11 @@ tools:Whether to persist the flag's value for a user across the anonymous-to-identified transition (the "persistacross authentication steps" option in the UI). Keeps a user's evaluated value stable once they login. Incompatible with `device_id` bucketing.+ evaluation_runtime:+ description:+ Where this flag is allowed to evaluate — `server` (server-side SDKs only), `client` (client-side SDKs+ only), or `all` (both). Defaults to `all`.+ bucketing_identifier:+ description:+ Identifier used to bucket users into rollout percentages and variants — `distinct_id` (user ID, the+ default) or `device_id`. Using `device_id` is incompatible with `ensure_experience_continuity=true`.diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 4475d5e26fc7..2dffd6d76e4b 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -21781,6 +21781,17 @@ export namespace Schemas {* @nullable*/ensure_experience_continuity?: boolean | null;+ /** Where this flag is allowed to evaluate: 'server' (server-side SDKs only), 'client' (client-side SDKs only), or 'all' (both). Defaults to 'all'.+ *+ * * `server` - Server+ * * `client` - Client+ * * `all` - All */+ evaluation_runtime?: EvaluationRuntimeEnum | null;+ /** Identifier used to bucket users into rollout percentages and variants: 'distinct_id' (user ID, the default) or 'device_id'. Using 'device_id' is incompatible with ensure_experience_continuity=True.+ *+ * * `distinct_id` - User ID (default)+ * * `device_id` - Device ID */+ bucketing_identifier?: BucketingIdentifierEnum | null;}export interface FeatureFlagStatusResponse {@@ -34244,6 +34255,17 @@ export namespace Schemas {* @nullable*/ensure_experience_continuity?: boolean | null;+ /** Where this flag is allowed to evaluate: 'server' (server-side SDKs only), 'client' (client-side SDKs only), or 'all' (both). Defaults to 'all'.+ *+ * * `server` - Server+ * * `client` - Client+ * * `all` - All */+ evaluation_runtime?: EvaluationRuntimeEnum | null;+ /** Identifier used to bucket users into rollout percentages and variants: 'distinct_id' (user ID, the default) or 'device_id'. Using 'device_id' is incompatible with ensure_experience_continuity=True.+ *+ * * `distinct_id` - User ID (default)+ * * `device_id` - Device ID */+ bucketing_identifier?: BucketingIdentifierEnum | null;}/**diff --git a/services/mcp/src/generated/feature_flags/api.ts b/services/mcp/src/generated/feature_flags/api.tsindex 4388d419869d..7cb2f1411722 100644--- a/services/mcp/src/generated/feature_flags/api.ts+++ b/services/mcp/src/generated/feature_flags/api.ts@@ -396,6 +396,26 @@ export const FeatureFlagsCreateBody = /* @__PURE__ */ zod.object({.describe("Whether to persist a user's flag value across the anonymous-to-identified transition (the 'persist across authentication steps' option). Incompatible with device_id bucketing."),+ evaluation_runtime: zod+ .union([+ zod.enum(['server', 'client', 'all']).describe('* `server` - Server\n* `client` - Client\n* `all` - All'),+ zod.null(),+ ])+ .optional()+ .describe(+ "Where this flag is allowed to evaluate: 'server' (server-side SDKs only), 'client' (client-side SDKs only), or 'all' (both). Defaults to 'all'.\n\n* `server` - Server\n* `client` - Client\n* `all` - All"+ ),+ bucketing_identifier: zod+ .union([+ zod+ .enum(['distinct_id', 'device_id'])+ .describe('* `distinct_id` - User ID (default)\n* `device_id` - Device ID'),+ zod.null(),+ ])+ .optional()+ .describe(+ "Identifier used to bucket users into rollout percentages and variants: 'distinct_id' (user ID, the default) or 'device_id'. Using 'device_id' is incompatible with ensure_experience_continuity=True.\n\n* `distinct_id` - User ID (default)\n* `device_id` - Device ID"+ ),})/**@@ -732,6 +752,26 @@ export const FeatureFlagsPartialUpdateBody = /* @__PURE__ */ zod.object({.describe("Whether to persist a user's flag value across the anonymous-to-identified transition (the 'persist across authentication steps' option). Incompatible with device_id bucketing."),+ evaluation_runtime: zod+ .union([+ zod.enum(['server', 'client', 'all']).describe('* `server` - Server\n* `client` - Client\n* `all` - All'),+ zod.null(),+ ])+ .optional()+ .describe(+ "Where this flag is allowed to evaluate: 'server' (server-side SDKs only), 'client' (client-side SDKs only), or 'all' (both). Defaults to 'all'.\n\n* `server` - Server\n* `client` - Client\n* `all` - All"+ ),+ bucketing_identifier: zod+ .union([+ zod+ .enum(['distinct_id', 'device_id'])+ .describe('* `distinct_id` - User ID (default)\n* `device_id` - Device ID'),+ zod.null(),+ ])+ .optional()+ .describe(+ "Identifier used to bucket users into rollout percentages and variants: 'distinct_id' (user ID, the default) or 'device_id'. Using 'device_id' is incompatible with ensure_experience_continuity=True.\n\n* `distinct_id` - User ID (default)\n* `device_id` - Device ID"+ ),})/**diff --git a/services/mcp/src/tools/generated/feature_flags.ts b/services/mcp/src/tools/generated/feature_flags.tsindex 585737440cb8..352d3b815ae8 100644--- a/services/mcp/src/tools/generated/feature_flags.ts+++ b/services/mcp/src/tools/generated/feature_flags.ts@@ -42,6 +42,12 @@ const CreateFeatureFlagSchema = FeatureFlagsCreateBody.extend({ensure_experience_continuity: FeatureFlagsCreateBody.shape['ensure_experience_continuity'].describe('Whether to persist the flag\'s value for a user across the anonymous-to-identified transition (the "persist across authentication steps" option in the UI). Keeps a user\'s evaluated value stable once they log in. Incompatible with `device_id` bucketing.'),+ evaluation_runtime: FeatureFlagsCreateBody.shape['evaluation_runtime'].describe(+ 'Where this flag is allowed to evaluate — `server` (server-side SDKs only), `client` (client-side SDKs only), or `all` (both). Defaults to `all`.'+ ),+ bucketing_identifier: FeatureFlagsCreateBody.shape['bucketing_identifier'].describe(+ 'Identifier used to bucket users into rollout percentages and variants — `distinct_id` (user ID, the default) or `device_id`. Using `device_id` is incompatible with `ensure_experience_continuity=true`.'+ ),})const createFeatureFlag = (): ToolBase<typeof CreateFeatureFlagSchema, WithPostHogUrl<Schemas.FeatureFlag>> => ({@@ -74,6 +80,12 @@ const createFeatureFlag = (): ToolBase<typeof CreateFeatureFlagSchema, WithPostHif (params.ensure_experience_continuity !== undefined) {body['ensure_experience_continuity'] = params.ensure_experience_continuity}+ if (params.evaluation_runtime !== undefined) {+ body['evaluation_runtime'] = params.evaluation_runtime+ }+ if (params.bucketing_identifier !== undefined) {+ body['bucketing_identifier'] = params.bucketing_identifier+ }const result = await context.api.request<Schemas.FeatureFlag>({method: 'POST',path: `/api/projects/${encodeURIComponent(String(projectId))}/feature_flags/`,@@ -609,6 +621,12 @@ const UpdateFeatureFlagSchema = FeatureFlagsPartialUpdateParams.omit({ project_iensure_experience_continuity: FeatureFlagsPartialUpdateBody.shape['ensure_experience_continuity'].describe('Whether to persist the flag\'s value for a user across the anonymous-to-identified transition (the "persist across authentication steps" option in the UI). Keeps a user\'s evaluated value stable once they log in. Incompatible with `device_id` bucketing.'),+ evaluation_runtime: FeatureFlagsPartialUpdateBody.shape['evaluation_runtime'].describe(+ 'Where this flag is allowed to evaluate — `server` (server-side SDKs only), `client` (client-side SDKs only), or `all` (both). Defaults to `all`.'+ ),+ bucketing_identifier: FeatureFlagsPartialUpdateBody.shape['bucketing_identifier'].describe(+ 'Identifier used to bucket users into rollout percentages and variants — `distinct_id` (user ID, the default) or `device_id`. Using `device_id` is incompatible with `ensure_experience_continuity=true`.'+ ),})const updateFeatureFlag = (): ToolBase<typeof UpdateFeatureFlagSchema, WithPostHogUrl<Schemas.FeatureFlag>> => ({@@ -641,6 +659,12 @@ const updateFeatureFlag = (): ToolBase<typeof UpdateFeatureFlagSchema, WithPostHif (params.ensure_experience_continuity !== undefined) {body['ensure_experience_continuity'] = params.ensure_experience_continuity}+ if (params.evaluation_runtime !== undefined) {+ body['evaluation_runtime'] = params.evaluation_runtime+ }+ if (params.bucketing_identifier !== undefined) {+ body['bucketing_identifier'] = params.bucketing_identifier+ }const result = await context.api.request<Schemas.FeatureFlag>({method: 'PATCH',path: `/api/projects/${encodeURIComponent(String(projectId))}/feature_flags/${encodeURIComponent(String(params.id))}/`,diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/create-feature-flag.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/create-feature-flag.jsonindex 5daf1e140e2f..6c47dcec234c 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/create-feature-flag.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/create-feature-flag.json@@ -5,6 +5,19 @@"description": "Whether the feature flag is active.","type": "boolean"},+ "bucketing_identifier": {+ "anyOf": [+ {+ "description": "* `distinct_id` - User ID (default)\n* `device_id` - Device ID",+ "enum": ["distinct_id", "device_id"],+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "description": "Identifier used to bucket users into rollout percentages and variants — `distinct_id` (user ID, the default) or `device_id`. Using `device_id` is incompatible with `ensure_experience_continuity=true`."+ },"ensure_experience_continuity": {"anyOf": [{@@ -23,6 +36,19 @@},"type": "array"},+ "evaluation_runtime": {+ "anyOf": [+ {+ "description": "* `server` - Server\n* `client` - Client\n* `all` - All",+ "enum": ["server", "client", "all"],+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "description": "Where this flag is allowed to evaluate — `server` (server-side SDKs only), `client` (client-side SDKs only), or `all` (both). Defaults to `all`."+ },"filters": {"description": "Feature flag targeting configuration.","properties": {diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/update-feature-flag.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/update-feature-flag.jsonindex cd38b9d62a64..d02d402c6856 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/update-feature-flag.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/update-feature-flag.json@@ -5,6 +5,19 @@"description": "Whether the feature flag is active.","type": "boolean"},+ "bucketing_identifier": {+ "anyOf": [+ {+ "description": "* `distinct_id` - User ID (default)\n* `device_id` - Device ID",+ "enum": ["distinct_id", "device_id"],+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "description": "Identifier used to bucket users into rollout percentages and variants — `distinct_id` (user ID, the default) or `device_id`. Using `device_id` is incompatible with `ensure_experience_continuity=true`."+ },"ensure_experience_continuity": {"anyOf": [{@@ -23,6 +36,19 @@},"type": "array"},+ "evaluation_runtime": {+ "anyOf": [+ {+ "description": "* `server` - Server\n* `client` - Client\n* `all` - All",+ "enum": ["server", "client", "all"],+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "description": "Where this flag is allowed to evaluate — `server` (server-side SDKs only), `client` (client-side SDKs only), or `all` (both). Defaults to `all`."+ },"filters": {"description": "Feature flag targeting configuration.","properties": {