diff --git a/ui/goose2/src/features/chat/ui/McpAppView.tsx b/ui/goose2/src/features/chat/ui/McpAppView.tsx index bea9a71837..b2be72a6e1 100644 --- a/ui/goose2/src/features/chat/ui/McpAppView.tsx +++ b/ui/goose2/src/features/chat/ui/McpAppView.tsx @@ -93,6 +93,22 @@ function getDeviceCapabilities(): NonNullable< }; } +// Derives https://github.com/modelcontextprotocol/ext-apps/blob/1d091e21321c0680564f19fea9c82a805a352a9c/src/spec.types.ts#L494 +// from the handlers passed to , keeping advertised capabilities in sync with what the host supports. +function buildHostCapabilities(handlers: { + onCallTool?: unknown; + onOpenLink?: unknown; + onReadResource?: unknown; + onSendMessage?: unknown; +}) { + return { + ...(handlers.onCallTool !== undefined && { serverTools: {} }), + ...(handlers.onOpenLink !== undefined && { openLinks: {} }), + ...(handlers.onReadResource !== undefined && { serverResources: {} }), + ...(handlers.onSendMessage !== undefined && { message: { text: {} } }), + }; +} + function buildHostContextToolInfo(payload: McpAppPayload): HostContextToolInfo { const tool: HostContextTool = { name: payload.tool.name, @@ -426,6 +442,12 @@ export function McpAppView({ toolInput={currentToolInput} toolResult={currentToolResult} hostContext={hostContext} + hostCapabilities={buildHostCapabilities({ + onCallTool: handleCallTool, + onOpenLink: handleOpenLink, + onReadResource: handleReadResource, + onSendMessage: onSendMessage, + })} onOpenLink={handleOpenLink} onMessage={handleMessage} onCallTool={handleCallTool}