: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(mcp): roll out render-ui to all MCP Apps hosts, remove flag (#69662)
Georgiy Tarasov23f878012853
diff --git a/ee/hogai/eval/sandboxed/cli_mcp/eval_render_ui.py b/ee/hogai/eval/sandboxed/cli_mcp/eval_render_ui.pyindex ce2a38c8e289..ab4b2ff541b1 100644--- a/ee/hogai/eval/sandboxed/cli_mcp/eval_render_ui.py+++ b/ee/hogai/eval/sandboxed/cli_mcp/eval_render_ui.py@@ -33,11 +33,9 @@ Not exercised here (sandbox/scope limits, not prompt gaps):side effects against the shared demo project.* **Surveys** — the hedgebox demo seeds none.-``render-ui`` is registered only in ``cli`` mode AND when the ``mcp-render-ui``-feature flag is on. The eval forces the flag on for the MCP server via the-dev/test-only ``FEATURE_FLAG_OVERRIDES`` seam (see ``conftest.py:_mcp_server``),-so the only remaining gate here is the mode: all cases skip under-``--mcp-mode=tools`` (see ``conftest.py:_apply_mcp_mode``).+``render-ui`` is registered only in ``cli`` mode and for MCP Apps hosts (the+sandboxed eval client presents as one), so the only remaining gate here is the+mode: all cases skip under ``--mcp-mode=tools`` (see ``conftest.py:_apply_mcp_mode``).To run a single eval:pytest ee/hogai/eval/sandboxed/cli_mcp/eval_render_ui.py::eval_renders_entity_ui --mcp-mode=clidiff --git a/ee/hogai/eval/sandboxed/conftest.py b/ee/hogai/eval/sandboxed/conftest.pyindex 5695df3d6df0..932fedf11ed6 100644--- a/ee/hogai/eval/sandboxed/conftest.py+++ b/ee/hogai/eval/sandboxed/conftest.py@@ -552,11 +552,10 @@ def _mcp_server(_django_live_server, _sandbox_settings):# here (no POSTHOG_ANALYTICS_* config), so every flag would resolve false.# Force flag-gated behavior on for evals via the dev/test-only override seam# (honored only when NODE_ENV is explicitly development/test — set above).- # `mcp-render-ui` gates the render_ui umbrella tool — see eval_render_ui.py.# `mcp-sql-schema-discovery` routes warehouse/system-table schema discovery# through `system.information_schema.*` SQL instead of read-data-warehouse-schema# — see eval_system_table_search.py.- "FEATURE_FLAG_OVERRIDES": json.dumps({"mcp-render-ui": True, "mcp-sql-schema-discovery": True}),+ "FEATURE_FLAG_OVERRIDES": json.dumps({"mcp-sql-schema-discovery": True}),}logger.info("Starting MCP server (Hono runtime) on port %d (API: %s)", MCP_PORT, api_url)diff --git a/services/mcp/src/hono/request-state-resolver.ts b/services/mcp/src/hono/request-state-resolver.tsindex 282cdf902e31..7e024a892aef 100644--- a/services/mcp/src/hono/request-state-resolver.ts+++ b/services/mcp/src/hono/request-state-resolver.ts@@ -12,7 +12,6 @@ import {import type { RequestProperties } from '@/lib/request-properties'import type { McpMode } from '@/lib/utils'import { SQL_SCHEMA_DISCOVERY_FEATURE_FLAG } from '@/tools/posthogAiTools/readDataWarehouseSchema'-import { RENDER_UI_FEATURE_FLAG } from '@/tools/render-ui'import { getRequiredFeatureFlags, getScopeGatedTools, type ScopeGatedTool } from '@/tools/toolDefinitions'import type { Context, Tool, Env, State, ZodObjectAny } from '@/tools/types'@@ -108,14 +107,11 @@ export class RequestStateResolver {}const toolFlagKeys = getRequiredFeatureFlags()- // `mcp-render-ui` isn't a catalog tool flag, but it rides the same batched- // evaluation and lives in the same map so the instructions layer can gate- // the rendering prompt section on it (like `mcp-feedback-tool`).// `mcp-sql-schema-discovery` now gates the read-data-warehouse-schema tool, so// it already arrives via `getRequiredFeatureFlags()`; keep it listed (and dedupe)// since the instructions layer also reads it for SQL discovery steering — neither// concern should depend on the other's wiring.- const allFlagKeys = [...new Set([...toolFlagKeys, RENDER_UI_FEATURE_FLAG, SQL_SCHEMA_DISCOVERY_FEATURE_FLAG])]+ const allFlagKeys = [...new Set([...toolFlagKeys, SQL_SCHEMA_DISCOVERY_FEATURE_FLAG])]const flagAnalyticsContext = await reqCtx.safelyGetAnalyticsContext(context)const flagGroups = flagAnalyticsContext ? buildMCPAnalyticsGroups(flagAnalyticsContext) : undefined@@ -135,7 +131,6 @@ export class RequestStateResolver {// even when no catalog tool referenced it.const flagKeysForState = [...new Set([...allFlagKeys, ...Object.keys(overrides)])]const toolFeatureFlags = Object.fromEntries(flagKeysForState.map((k) => [k, mergedFlags[k]]))- const renderUiFlagEnabled = mergedFlags[RENDER_UI_FEATURE_FLAG] === trueconst oauthClientName = (await reqCtx.tokenCache.get('clientName')) || undefined@@ -149,11 +144,9 @@ export class RequestStateResolver {})// `render-ui` is only meaningful for MCP Apps hosts (Claude web/desktop) that can- // mount its iframe. The flag is necessary but not sufficient: Claude Code and other- // single-exec CLI clients pool the same flag value, so the tool's advertisement and- // execution must also require the UI-host check — otherwise rolling the flag out to- // everyone leaks `render-ui` into Claude Code.- const renderUiEnabled = renderUiFlagEnabled && clientProfile.isClaudeUiHost()+ // mount its iframe. Single-exec CLI clients like Claude Code can't mount it, so the+ // tool's advertisement and execution stay gated on the UI-host check.+ const renderUiEnabled = clientProfile.isClaudeUiHost()const { mode: resolvedMode, useSingleExec } = resolveMode({mode: requestContext.mode,diff --git a/services/mcp/src/hono/tool-executor.ts b/services/mcp/src/hono/tool-executor.tsindex 96a2ed98015a..b1a4de0967e6 100644--- a/services/mcp/src/hono/tool-executor.ts+++ b/services/mcp/src/hono/tool-executor.ts@@ -108,7 +108,7 @@ export class ToolExecutor {}if (toolName === 'render-ui') {- // render-ui is only advertised when the flag is on; reject calls otherwise.+ // render-ui is only advertised to MCP Apps hosts; reject calls from others.if (!state.renderUiEnabled) {toolCallsTotal.inc({ tool: toolName, status: 'error' })return { content: [{ type: 'text', text: `Tool ${toolName} not found` }], isError: true }diff --git a/services/mcp/src/lib/client-detection.ts b/services/mcp/src/lib/client-detection.tsindex ee92876573eb..4caeec17d698 100644--- a/services/mcp/src/lib/client-detection.ts+++ b/services/mcp/src/lib/client-detection.ts@@ -27,7 +27,7 @@** - `isClaudeUiHost()` matches Claude web/desktop and Cowork — MCP Apps hosts* that render interactive UI (iframes). Used to advertise the `render-ui`- * tool to them, gated behind the `mcp-render-ui` flag.+ * tool to them.** - `isClaudeChatHost()` matches Claude web/desktop only — the chat surfaces that* report `supportsInstructions` but never surface the `instructions` payload todiff --git a/services/mcp/src/lib/instructions-formatter.ts b/services/mcp/src/lib/instructions-formatter.tsindex d7af02225edf..fdfbabc99255 100644--- a/services/mcp/src/lib/instructions-formatter.ts+++ b/services/mcp/src/lib/instructions-formatter.ts@@ -38,9 +38,9 @@ export interface InstructionsContext {/** Resolved tool feature flags from `resolveToolFeatureFlags`. Used to gate* prompt sections whose corresponding tool is flag-gated. */featureFlags?: EvaluatedFlags | undefined- /** Whether `render-ui` is actually available to this client (the `mcp-render-ui`- * flag is on AND the client is an MCP Apps host). Gates the CLI rendering section- * so it never reaches clients — like Claude Code — that can't mount the iframe. */+ /** Whether `render-ui` is actually available to this client (i.e. the client is+ * an MCP Apps host). Gates the CLI rendering section so it never reaches clients —+ * like Claude Code — that can't mount the iframe. */renderUiEnabled?: boolean | undefined}diff --git a/services/mcp/src/lib/posthog/flags.ts b/services/mcp/src/lib/posthog/flags.tsindex 8332514f3835..d77192bc692d 100644--- a/services/mcp/src/lib/posthog/flags.ts+++ b/services/mcp/src/lib/posthog/flags.ts@@ -42,7 +42,7 @@ export async function evaluateFeatureFlags(}// Env var (or Cloudflare var) holding a JSON object of flag overrides, e.g.-// `FEATURE_FLAG_OVERRIDES={"mcp-render-ui": true, "some-flag": "variant-a"}`.+// `FEATURE_FLAG_OVERRIDES={"mcp-sql-schema-discovery": true, "some-flag": "variant-a"}`.const FEATURE_FLAG_OVERRIDES_ENV = 'FEATURE_FLAG_OVERRIDES'/** Parse a JSON object of flag overrides. Non-object JSON, parse errors, anddiff --git a/services/mcp/src/tools/render-ui.ts b/services/mcp/src/tools/render-ui.tsindex e4b92ae219c4..487741cbca16 100644--- a/services/mcp/src/tools/render-ui.ts+++ b/services/mcp/src/tools/render-ui.ts@@ -11,10 +11,6 @@ export const RENDER_UI_TOOL_NAME = 'render-ui'export const RENDER_UI_TOOL_TITLE = 'Render a PostHog visualization'export const RENDER_UI_TOOL_DESCRIPTION = RENDER_UI_PROMPT.trim()-// Feature flag gating the entire `render-ui` feature: tool registration/advertisement,-// the rendering prompt section, and the single-exec switch for Claude web/desktop.-export const RENDER_UI_FEATURE_FLAG = 'mcp-render-ui'-// Reverse of URI_MAP so a tool's `_meta.ui.resourceUri` resolves back to its app key.const URI_TO_APP_KEY = new Map<string, UiAppKey>(Object.entries(URI_MAP).map(([appKey, uri]) => [uri, appKey as UiAppKey])diff --git a/services/mcp/tests/hono/request-state-resolver.test.ts b/services/mcp/tests/hono/request-state-resolver.test.tsindex d6f7a5a227d0..e028f304ee9d 100644--- a/services/mcp/tests/hono/request-state-resolver.test.ts+++ b/services/mcp/tests/hono/request-state-resolver.test.ts@@ -258,8 +258,7 @@ describe('RequestStateResolver MCP client contexts', () => {expect(mockSessionStore.get('mcpVendorClient')).toBe('ClaudeCode')})- it('puts Claude web/desktop in single-exec when the render-ui flag is on', async () => {- vi.mocked(evaluateFeatureFlags).mockResolvedValueOnce({ 'mcp-render-ui': true })+ it('puts Claude web/desktop in single-exec and enables render-ui', async () => {const props = makeProps({ mcpClientName: 'Claude Desktop', mcpVendorClient: 'ClaudeAI' })const result = await makeResolver().resolve(props)@@ -268,18 +267,6 @@ describe('RequestStateResolver MCP client contexts', () => {expect(props.mode).toBe('cli')})- it('keeps Claude web/desktop in single-exec via the Claude-User user agent even when the render-ui flag is off', async () => {- // Anthropic clients always run in CLI (single-exec) mode, so the- // User-Agent-only path is single-exec regardless of the render-ui flag — the- // flag only gates whether the `render-ui` tool itself is advertised.- const props = makeProps({ mcpClientName: 'Claude Desktop', clientUserAgent: 'Claude-User' })- const result = await makeResolver().resolve(props)-- expect(result.renderUiEnabled).toBe(false)- expect(result.useSingleExec).toBe(true)- expect(props.mode).toBe('cli')- })-it('puts header-less Claude.ai (pooled Anthropic/* name + Claude-User UA, no vendor header) in single-exec', async () => {// The production gap: Claude.ai web/desktop sessions that omit the// x-anthropic-client header and report only clientInfo.name "Anthropic/ClaudeAI"@@ -295,39 +282,34 @@ describe('RequestStateResolver MCP client contexts', () => {expect(props.mode).toBe('cli')})- it('does not enable render-ui for Claude Code even when the flag is on', async () => {- // Claude Code pools the same `mcp-render-ui` flag value as Claude web/desktop, but- // it isn't an MCP Apps host — it can't mount the iframe. It must stay in single-exec- // (it's a CLI client) while `renderUiEnabled` resolves to false, so the tool-executor- // never advertises or accepts `render-ui` for it.- vi.mocked(evaluateFeatureFlags).mockResolvedValueOnce({ 'mcp-render-ui': true })+ it('does not enable render-ui for Claude Code', async () => {+ // Claude Code is a single-exec CLI client but not an MCP Apps host — it can't+ // mount the iframe. It must stay in single-exec while `renderUiEnabled` resolves+ // to false, so the tool-executor never advertises or accepts `render-ui` for it.const props = makeProps({ mcpClientName: 'Anthropic/ClaudeAI', mcpVendorClient: 'ClaudeCode' })const result = await makeResolver().resolve(props)expect(result.renderUiEnabled).toBe(false)expect(result.useSingleExec).toBe(true)- expect(result.toolFeatureFlags?.['mcp-render-ui']).toBe(true)})- it('detects Claude web/desktop via the Claude-User user agent', async () => {- vi.mocked(evaluateFeatureFlags).mockResolvedValueOnce({ 'mcp-render-ui': true })+ it('detects Claude web/desktop via the Claude-User user agent and enables render-ui', async () => {const props = makeProps({ mcpClientName: 'Claude Desktop', clientUserAgent: 'Claude-User' })const result = await makeResolver().resolve(props)+ expect(result.renderUiEnabled).toBe(true)expect(result.useSingleExec).toBe(true)expect(props.mode).toBe('cli')})it('honors a dev/test flag override even when evaluation returns nothing', async () => {// Evaluation stays empty (analytics client disabled, as in local dev/evals);- // the override seam is what flips the flag on.- vi.mocked(resolveFeatureFlagOverrides).mockReturnValueOnce({ 'mcp-render-ui': true })+ // the override seam is what flips a tool flag on so it reaches the tool layer.+ vi.mocked(resolveFeatureFlagOverrides).mockReturnValueOnce({ 'mcp-sql-schema-discovery': true })const props = makeProps({ mcpClientName: 'Claude Desktop', mcpVendorClient: 'ClaudeAI' })const result = await makeResolver().resolve(props)- expect(result.renderUiEnabled).toBe(true)- expect(result.useSingleExec).toBe(true)- expect(result.toolFeatureFlags?.['mcp-render-ui']).toBe(true)+ expect(result.toolFeatureFlags?.['mcp-sql-schema-discovery']).toBe(true)})it('captures consumer from a later request when initialize omitted the header', async () => {diff --git a/services/mcp/tests/hono/session-mode-pool.test.ts b/services/mcp/tests/hono/session-mode-pool.test.tsindex f2c549c36d14..ef0711a2fdb3 100644--- a/services/mcp/tests/hono/session-mode-pool.test.ts+++ b/services/mcp/tests/hono/session-mode-pool.test.ts@@ -126,7 +126,7 @@ describe('Resolved mode is preserved across pooled-transport vendor flips', () =// Client caches the tools payload at init. cli mode collapses the wire// roster to the single `exec` umbrella tool (the sibling `render-ui` tool- // is gated behind the `mcp-render-ui` flag, which is off in tests).+ // only advertises to MCP Apps hosts; Claude Code isn't one).const cachedTools = await clientA.listTools()expect(cachedTools.tools.map((t) => t.name).sort()).toEqual(['exec'])diff --git a/services/mcp/tests/hono/tool-executor.test.ts b/services/mcp/tests/hono/tool-executor.test.tsindex 52be38ad308d..002a62260fef 100644--- a/services/mcp/tests/hono/tool-executor.test.ts+++ b/services/mcp/tests/hono/tool-executor.test.ts@@ -257,7 +257,7 @@ describe('ToolExecutor', () => {expect(renderUiEntry.inputSchema.required).toEqual(['tool_name'])})- it('omits render-ui when the flag is off, even with a UI-app tool available', async () => {+ it('omits render-ui when render-ui is disabled, even with a UI-app tool available', async () => {const state = makeState([uiAppTool], { useSingleExec: true, renderUiEnabled: false })const result = await executor.handleToolsList(state)@@ -266,7 +266,7 @@ describe('ToolExecutor', () => {})describe('render-ui', () => {- it('dispatches to the render-ui payload when the flag is on', async () => {+ it('dispatches to the render-ui payload when render-ui is enabled', async () => {const state = makeState([uiAppTool], { useSingleExec: true, renderUiEnabled: true })const result = (await executor.handleToolCall(@@ -279,7 +279,7 @@ describe('ToolExecutor', () => {expect(result.structuredContent.app_key).toBe('survey')})- it('rejects a render-ui call when the flag is off', async () => {+ it('rejects a render-ui call when render-ui is disabled', async () => {const state = makeState([uiAppTool], { useSingleExec: true, renderUiEnabled: false })const result = (await executor.handleToolCall(diff --git a/services/mcp/tests/integration/mcp-protocol-suite.ts b/services/mcp/tests/integration/mcp-protocol-suite.tsindex 2b52254aa483..29a92b8ba0bc 100644--- a/services/mcp/tests/integration/mcp-protocol-suite.ts+++ b/services/mcp/tests/integration/mcp-protocol-suite.ts@@ -1605,9 +1605,9 @@ export function defineExecModeTests(it('lists the exec umbrella tool in cli mode', async () => {const { tools } = await client.listTools()- // The sibling `render-ui` tool is gated behind the `mcp-render-ui` flag,- // which is off in this environment (analytics client disabled), so the- // cli-mode roster collapses to just `exec`.+ // The sibling `render-ui` tool only advertises to MCP Apps hosts (Claude+ // web/desktop); this generic test client isn't one, so the cli-mode roster+ // collapses to just `exec`.expect(tools.map((t) => t.name).sort()).toEqual(['exec'])})diff --git a/services/mcp/tests/unit/feature-flag-overrides.test.ts b/services/mcp/tests/unit/feature-flag-overrides.test.tsindex b09aae5fb656..aeeb076d0583 100644--- a/services/mcp/tests/unit/feature-flag-overrides.test.ts+++ b/services/mcp/tests/unit/feature-flag-overrides.test.ts@@ -21,14 +21,14 @@ describe('resolveFeatureFlagOverrides', () => {})it('parses the env JSON object with boolean and variant values', () => {- process.env.FEATURE_FLAG_OVERRIDES = JSON.stringify({ 'mcp-render-ui': true, 'some-flag': 'variant-a' })- expect(resolveFeatureFlagOverrides()).toEqual({ 'mcp-render-ui': true, 'some-flag': 'variant-a' })+ process.env.FEATURE_FLAG_OVERRIDES = JSON.stringify({ 'mcp-sql-schema-discovery': true, 'some-flag': 'variant-a' })+ expect(resolveFeatureFlagOverrides()).toEqual({ 'mcp-sql-schema-discovery': true, 'some-flag': 'variant-a' })})it('lets a per-request override win over the env var', () => {- process.env.FEATURE_FLAG_OVERRIDES = JSON.stringify({ 'mcp-render-ui': false })- expect(resolveFeatureFlagOverrides(JSON.stringify({ 'mcp-render-ui': true }))).toEqual({- 'mcp-render-ui': true,+ process.env.FEATURE_FLAG_OVERRIDES = JSON.stringify({ 'mcp-sql-schema-discovery': false })+ expect(resolveFeatureFlagOverrides(JSON.stringify({ 'mcp-sql-schema-discovery': true }))).toEqual({+ 'mcp-sql-schema-discovery': true,})})@@ -40,13 +40,13 @@ describe('resolveFeatureFlagOverrides', () => {it('is a no-op in production, even with overrides set', () => {process.env.NODE_ENV = 'production'- process.env.FEATURE_FLAG_OVERRIDES = JSON.stringify({ 'mcp-render-ui': true })+ process.env.FEATURE_FLAG_OVERRIDES = JSON.stringify({ 'mcp-sql-schema-discovery': true })expect(resolveFeatureFlagOverrides(JSON.stringify({ x: true }))).toEqual({})})it('fails closed when NODE_ENV is unset, even with overrides set', () => {delete process.env.NODE_ENV- process.env.FEATURE_FLAG_OVERRIDES = JSON.stringify({ 'mcp-render-ui': true })+ process.env.FEATURE_FLAG_OVERRIDES = JSON.stringify({ 'mcp-sql-schema-discovery': true })expect(resolveFeatureFlagOverrides(JSON.stringify({ x: true }))).toEqual({})})diff --git a/services/mcp/tests/unit/instructions-formatter-snapshot.test.ts b/services/mcp/tests/unit/instructions-formatter-snapshot.test.tsindex 05fe8213fe84..4c83ccd2d979 100644--- a/services/mcp/tests/unit/instructions-formatter-snapshot.test.ts+++ b/services/mcp/tests/unit/instructions-formatter-snapshot.test.ts@@ -41,7 +41,7 @@ const STATIC_CTX: InstructionsContext = {metadata: STATIC_METADATA,tools: STATIC_TOOLS,queryTools: STATIC_QUERY_TOOLS,- featureFlags: { 'mcp-feedback-tool': true, 'mcp-render-ui': true },+ featureFlags: { 'mcp-feedback-tool': true },renderUiEnabled: true,}diff --git a/services/mcp/tests/unit/instructions-formatter.test.ts b/services/mcp/tests/unit/instructions-formatter.test.tsindex 5fec34deaf27..dab6c782734b 100644--- a/services/mcp/tests/unit/instructions-formatter.test.ts+++ b/services/mcp/tests/unit/instructions-formatter.test.ts@@ -34,7 +34,7 @@ const fullCtx: InstructionsContext = {metadata: realisticMetadata,tools: realisticTools,queryTools: realisticQueryTools,- featureFlags: { 'mcp-feedback-tool': true, 'mcp-render-ui': true },+ featureFlags: { 'mcp-feedback-tool': true },renderUiEnabled: true,}