Dont show MCP UI/Apps until tool is approved (#6492)

Co-authored-by: Douwe Osinga <douwe@squareup.com>
This commit is contained in:
Douwe Osinga
2026-01-21 09:09:37 -05:00
committed by GitHub
parent 51cc5db387
commit 727679ce92
4 changed files with 46 additions and 4 deletions
@@ -55,6 +55,7 @@ interface ToolCallWithResponseProps {
toolResponse?: ToolResponseMessageContent;
notifications?: NotificationEvent[];
isStreamingMessage?: boolean;
isPendingApproval: boolean;
append?: (value: string) => void;
}
@@ -110,10 +111,8 @@ function McpAppWrapper({
? requestWithMeta.toolCall.value.arguments
: undefined;
// Memoize toolInput to prevent unnecessary re-renders
const toolInput = useMemo(() => ({ arguments: toolArguments || {} }), [toolArguments]);
// Memoize toolResult to prevent unnecessary re-renders
const toolResult = useMemo(() => {
if (!toolResponse) return undefined;
const resultWithMeta = toolResponse.toolResult as ToolResultWithMeta;
@@ -153,6 +152,7 @@ export default function ToolCallWithResponse({
toolResponse,
notifications,
isStreamingMessage,
isPendingApproval,
append,
}: ToolCallWithResponseProps) {
// Handle both the wrapped ToolResult format and the unwrapped format
@@ -173,6 +173,8 @@ export default function ToolCallWithResponse({
requestWithMeta._meta?.ui?.resourceUri || resultWithMeta?.value?._meta?.ui?.resourceUri
);
const shouldShowMcpContent = !isPendingApproval;
return (
<>
<div
@@ -191,7 +193,8 @@ export default function ToolCallWithResponse({
/>
</div>
{/* MCP UI — Inline */}
{!hasMcpAppResourceURI &&
{shouldShowMcpContent &&
!hasMcpAppResourceURI &&
toolResponse?.toolResult &&
getToolResultContent(toolResponse.toolResult).map((content, index) => {
const resourceContent = isEmbeddedResource(content)
@@ -214,7 +217,8 @@ export default function ToolCallWithResponse({
}
})}
{hasMcpAppResourceURI && sessionId && (
{/* MCP App */}
{shouldShowMcpContent && hasMcpAppResourceURI && sessionId && (
<McpAppWrapper
toolRequest={toolRequest}
toolResponse={toolResponse}