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): send error name and code with render-ui render failures (#126743)

Sam Penningtond636e631a083
diff --git a/services/mcp/src/ui-apps/apps/render-ui.tsx b/services/mcp/src/ui-apps/apps/render-ui.tsx
index c77153fd147f..08b02fddd629 100644
--- a/services/mcp/src/ui-apps/apps/render-ui.tsx
+++ b/services/mcp/src/ui-apps/apps/render-ui.tsx
@@ -42,7 +42,12 @@ function RenderUiContent({
openLink: (url: string) => void
}): JSX.Element {
const [data, setData] = useState<unknown>(null)
- const [error, setError] = useState<{ reason: string; message: string } | null>(null)
+ const [error, setError] = useState<{
+ reason: string
+ message: string
+ errorName?: string
+ errorCode?: number
+ } | null>(null)
// Key the fetch on serialized values, not `envelope` identity — a parent
// re-render with a fresh-but-equal envelope object must not refetch.
@@ -73,7 +78,14 @@ function RenderUiContent({
})
.catch((e: unknown) => {
if (!cancelled) {
- setError({ reason: 'exception', message: e instanceof Error ? e.message : String(e) })
+ // Analytics gets only the name and JSON-RPC code: the message can quote response content.
+ const code = (e as { code?: unknown } | null)?.code
+ setError({
+ reason: 'exception',
+ message: e instanceof Error ? e.message : String(e),
+ errorName: e instanceof Error ? e.name : typeof e,
+ errorCode: typeof code === 'number' ? code : undefined,
+ })
}
})
return () => {
@@ -83,15 +95,19 @@ function RenderUiContent({
const render = RENDER_DISPATCH[envelope.app_key]
const failureReason = render ? error?.reason : 'no_visualization'
+ const errorName = render ? error?.errorName : undefined
+ const errorCode = render ? error?.errorCode : undefined
useEffect(() => {
if (failureReason) {
capture('mcp_ui_app_render_failed', {
rendered_tool_name: toolName,
app_key: envelope.app_key,
reason: failureReason,
+ error_name: errorName,
+ error_code: errorCode,
})
}
- }, [failureReason, toolName, envelope.app_key])
+ }, [failureReason, errorName, errorCode, toolName, envelope.app_key])
if (!render) {
return <AppErrorState message={`No visualization is available for ${envelope.tool_name}.`} />