Skip to content

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

fix(mcp): render ui apps via render-ui for cowork sessions (#111505)

Sam Penningtond87413f900fa
diff --git a/services/mcp/src/lib/build-tool-result.ts b/services/mcp/src/lib/build-tool-result.ts
index 95892071d39b..ab209560438e 100644
--- a/services/mcp/src/lib/build-tool-result.ts
+++ b/services/mcp/src/lib/build-tool-result.ts
@@ -24,7 +24,7 @@ export interface BuildToolResultOptions {
/** Whether formatted-result text should win over structuredContent for this client profile. */
suppressStructuredContentForFormattedResults?: boolean | undefined
/**
- * For inline-exec UI-app hosts (PostHog Desktop, Claude Code, Cowork): when a compact
+ * For inline-exec UI-app hosts (PostHog Desktop, Claude Code): when a compact
* formatted table is available, drop top-level `structuredContent` toward the model so
* it reads the compact table instead of the verbose JSON, and re-home the app payload
* onto `_meta` for the UI app (see APP_DATA_META_KEY). When there is NO formatted table
diff --git a/services/mcp/src/lib/client-detection.ts b/services/mcp/src/lib/client-detection.ts
index 63cd03401b66..cc37a50b6fe7 100644
--- a/services/mcp/src/lib/client-detection.ts
+++ b/services/mcp/src/lib/client-detection.ts
@@ -189,12 +189,12 @@ export const ANTHROPIC_UI_HOST_VENDOR_FRAGMENTS = ['claudeai', 'cowork'] as cons
// is not a chat host even though it is a UI host.
export const ANTHROPIC_CHAT_HOST_VENDOR_FRAGMENTS = ['claudeai'] as const
-// Anthropic coding-agent surfaces that render MCP UI apps inline through the
-// single-exec `exec` tool. `ClaudeCode` and `Cowork` render UI apps on the exec
-// response itself (`ClaudeAI` uses the separate `render-ui` tool instead;
-// `Cowork` supports both), so they get the same treatment as the PostHog Desktop
-// consumer.
-export const INLINE_EXEC_UI_APP_VENDOR_FRAGMENTS = ['claudecode', 'cowork'] as const
+// Anthropic surfaces that render MCP UI apps on the `exec` response itself, so they
+// get the same treatment as the PostHog Desktop consumer. `Cowork` is not one: Claude
+// desktop chat reports `Cowork` and mounts an iframe only for a tool that declares
+// `_meta.ui.resourceUri` on `tools/list`, which `exec` does not. It renders through
+// `render-ui`, like `ClaudeAI`.
+export const INLINE_EXEC_UI_APP_VENDOR_FRAGMENTS = ['claudecode'] as const
// User-Agent Anthropic clients send when they connect without the
// `x-anthropic-client` header (Claude.ai web/desktop and internal Anthropic
@@ -333,12 +333,11 @@ export class MCPClientProfile {
}
isInlineExecUiHost(): boolean {
- // Anthropic coding-agent surfaces that render MCP UI apps inline through the
- // single-exec `exec` tool (Claude Code, Cowork) — Claude.ai web/desktop
- // renders via the separate `render-ui` tool instead (Cowork supports both).
- // Like PostHog Desktop, these hosts surface `structuredContent` to the model, so
+ // Claude Code renders MCP UI apps inline on the single-exec `exec` tool, while
+ // Claude.ai and Cowork render through the separate `render-ui` tool.
+ // Like PostHog Desktop, Claude Code surfaces `structuredContent` to the model, so
// the exec UI-app branch suppresses it and re-homes the app data onto `_meta`.
- // The per-request vendor header (`ClaudeCode` / `Cowork`) is the reliable signal.
+ // The per-request vendor header (`ClaudeCode`) is the reliable signal.
return matchesAnyFragment(this.vendorClient, INLINE_EXEC_UI_APP_VENDOR_FRAGMENTS)
}
diff --git a/services/mcp/src/tools/exec.ts b/services/mcp/src/tools/exec.ts
index b91d2756a9ec..1ff45315e2e0 100644
--- a/services/mcp/src/tools/exec.ts
+++ b/services/mcp/src/tools/exec.ts
@@ -219,7 +219,7 @@ export interface ExecToolOptions {
learnCatalog?: ExecLearnCatalog
/**
* Client is an inline-exec UI-app host that renders MCP UI apps on the exec
- * response (Claude Code, Cowork). Gets the same UI-app payload treatment as the
+ * response (Claude Code). Gets the same UI-app payload treatment as the
* PostHog Desktop consumer: structuredContent suppressed toward the model, app data
* re-homed onto `_meta`. Computed from the client profile at the call site.
*/
@@ -2092,7 +2092,7 @@ export function createExecTool(
toolMeta: tool._meta,
toolName: tool.name,
params: useJson ? { ...input, output_format: 'json' } : input,
- // Inline-exec UI-app hosts (PostHog Desktop, Claude Code, Cowork)
+ // Inline-exec UI-app hosts (PostHog Desktop, Claude Code)
// surface `structuredContent` to the model in preference to the
// text content, which would bury a compact formatted table under
// the raw JSON. When such a table exists, re-home the UI app's data
diff --git a/services/mcp/tests/unit/build-tool-result.test.ts b/services/mcp/tests/unit/build-tool-result.test.ts
index 6ef9895607d1..df936d5375ab 100644
--- a/services/mcp/tests/unit/build-tool-result.test.ts
+++ b/services/mcp/tests/unit/build-tool-result.test.ts
@@ -228,7 +228,7 @@ describe('buildToolResultPayload — query-trends for Claude Code', () => {
})
})
-// Inline-exec UI-app hosts (PostHog Desktop, Claude Code, Cowork) go through the exec
+// Inline-exec UI-app hosts (PostHog Desktop, Claude Code) go through the exec
// wrapper, which sets `forceUiDataToMeta` + `includeUiResponseMeta`. The app payload
// should only move onto `_meta` when a compact formatted table takes structuredContent's
// place for the model — otherwise it stays in the standard structuredContent field so it
diff --git a/services/mcp/tests/unit/client-detection.test.ts b/services/mcp/tests/unit/client-detection.test.ts
index ee719b4ec3bc..c23c616f9727 100644
--- a/services/mcp/tests/unit/client-detection.test.ts
+++ b/services/mcp/tests/unit/client-detection.test.ts
@@ -455,12 +455,12 @@ describe('MCPClientProfile', () => {
})
describe('isInlineExecUiHost()', () => {
- it.each([['ClaudeCode'], ['Cowork']])('is true for the %s vendor client', (vendorClient) => {
- expect(new MCPClientProfile({ vendorClient }).isInlineExecUiHost()).toBe(true)
+ it('is true for the ClaudeCode vendor client', () => {
+ expect(new MCPClientProfile({ vendorClient: 'ClaudeCode' }).isInlineExecUiHost()).toBe(true)
})
- // Claude.ai renders via the separate render-ui tool, not the inline exec payload.
- it.each([['ClaudeAI'], ['ClaudeDesign'], ['some-random-tool'], ['']])(
+ // Claude.ai and Cowork render via the separate render-ui tool, not the inline exec payload.
+ it.each([['ClaudeAI'], ['Cowork'], ['ClaudeDesign'], ['some-random-tool'], ['']])(
'is false for the %s vendor client',
(vendorClient) => {
expect(new MCPClientProfile({ vendorClient }).isInlineExecUiHost()).toBe(false)
diff --git a/services/mcp/tests/unit/exec.test.ts b/services/mcp/tests/unit/exec.test.ts
index 435ed2115095..1371484e9755 100644
--- a/services/mcp/tests/unit/exec.test.ts
+++ b/services/mcp/tests/unit/exec.test.ts
@@ -508,13 +508,12 @@ describe('exec tool', () => {
expect(result.__execBuiltPayload).toBe(true)
})
- // Inline-exec UI-app hosts: PostHog Desktop (via consumer) plus Claude Code and
- // Cowork (via the client-profile flag). All three surface structuredContent to
- // the model, so it must be dropped and the UI data re-homed onto _meta.
+ // Inline-exec UI-app hosts: PostHog Desktop (via consumer) plus Claude Code (via
+ // the client-profile flag). Both surface structuredContent to the model, so it
+ // must be dropped and the UI data re-homed onto _meta.
it.each([
['posthog-code consumer', 'posthog-code', undefined],
['claude-code client', undefined, { isInlineExecUiHost: true }],
- ['cowork client', undefined, { isInlineExecUiHost: true }],
])(
'suppresses structuredContent toward the model but re-homes UI data onto _meta for %s (with a formatted override)',
async (_label, consumer, options) => {