: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
fix(mcp): advertise render-ui annotations on tools/list (#128432)
Jake Ruthdd7c54dce6ad
diff --git a/services/mcp/src/hono/instructions.ts b/services/mcp/src/hono/instructions.tsindex 7b569693156f..1094ce0fcad0 100644--- a/services/mcp/src/hono/instructions.ts+++ b/services/mcp/src/hono/instructions.ts@@ -19,6 +19,7 @@ import { ExecLearnCatalog } from '@/tools/exec-learn'import {getRenderableToolNames,makeRenderUiSchema,+ RENDER_UI_TOOL_ANNOTATIONS,RENDER_UI_TOOL_NAME,RENDER_UI_TOOL_TITLE,renderUiDescription,@@ -132,6 +133,7 @@ export class InstructionsBuilder {description: renderUiDescription(toolNames),// OpenAI caches this schema across accounts; authorization stays in the executor.inputSchema: toMcpInputSchema(makeRenderUiSchema(toolNames as [string, ...string[]])),+ annotations: { ...RENDER_UI_TOOL_ANNOTATIONS },// Advertise the umbrella UI resource so MCP Apps hosts (e.g. Claude) discover// render-ui as renderable from `tools/list` and mount its iframe. Both the// modern and legacy keys are emitted since this entry isn't normalized downstream.diff --git a/services/mcp/src/tools/render-ui.ts b/services/mcp/src/tools/render-ui.tsindex 18d0e9114914..8a5f6e4d8fa6 100644--- a/services/mcp/src/tools/render-ui.ts+++ b/services/mcp/src/tools/render-ui.ts@@ -14,6 +14,14 @@ 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()+// OpenAI's plugin review rejects a tools/list entry without these hints.+export const RENDER_UI_TOOL_ANNOTATIONS = {+ destructiveHint: false,+ idempotentHint: true,+ openWorldHint: false,+ readOnlyHint: true,+} as const+export function renderUiDescription(renderableNames: string[]): string {return renderableNames.includes('explain-chart')? `${RENDER_UI_TOOL_DESCRIPTION}\n\n${RENDER_UI_EXPLAIN_CHART.trim()}`@@ -98,12 +106,7 @@ export function createRenderUiTool(description: renderUiDescription(renderableNames),schema,scopes: [],- annotations: {- destructiveHint: false,- idempotentHint: true,- openWorldHint: false,- readOnlyHint: true,- },+ annotations: { ...RENDER_UI_TOOL_ANNOTATIONS },// Advertise the umbrella UI resource on the tool definition itself.// MCP Apps hosts (e.g. Claude) discover renderable tools from `tools/list`// `_meta.ui.resourceUri`, pre-fetch the template, and only mount the iframediff --git a/services/mcp/tests/hono/tool-executor.test.ts b/services/mcp/tests/hono/tool-executor.test.tsindex 7efb5dd70216..852ee2258ded 100644--- a/services/mcp/tests/hono/tool-executor.test.ts+++ b/services/mcp/tests/hono/tool-executor.test.ts@@ -667,6 +667,12 @@ describe('ToolExecutor', () => {expect(properties.context!.description).toBeTruthy()expect(properties.llm_model!.description).toBeTruthy()expect(renderUiEntry.inputSchema.required).toEqual(['tool_name', 'context', 'llm_model'])+ expect(renderUiEntry.annotations).toEqual({+ destructiveHint: false,+ idempotentHint: true,+ openWorldHint: false,+ readOnlyHint: true,+ })const restrictedResult = await executor.handleToolsList(makeToolExecutorState([], { useSingleExec: true, renderUiEnabled: true })