File tree Expand file tree Collapse file tree
ui/desktop/src/components/McpApps Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -128,12 +128,22 @@ export default function McpAppRenderer({
128128 if ( ! append ) {
129129 throw new Error ( 'Message handler not available in this context' ) ;
130130 }
131- append ( content . text ) ;
131+
132+ if ( ! Array . isArray ( content ) ) {
133+ throw new Error ( 'Invalid message format: content must be an array of ContentBlock' ) ;
134+ }
135+
136+ // Extract first text block from content, ignoring other block types
137+ const textContent = content . find ( ( block ) => block . type === 'text' ) ;
138+ if ( ! textContent ) {
139+ throw new Error ( 'Invalid message format: content must contain a text block' ) ;
140+ }
141+
142+ // MCP Apps can send other content block types, but we only append text blocks for now
143+
144+ append ( textContent . text ) ;
132145 window . dispatchEvent ( new CustomEvent ( 'scroll-chat-to-bottom' ) ) ;
133- return {
134- status : 'success' ,
135- message : 'Message appended successfully' ,
136- } satisfies McpMethodResponse [ 'ui/message' ] ;
146+ return { } satisfies McpMethodResponse [ 'ui/message' ] ;
137147 }
138148
139149 case 'tools/call' : {
Original file line number Diff line number Diff line change 11export type { CspMetadata , CallToolResponse as ToolResult } from '../../api/types.gen' ;
22
3+ export type ContentBlock =
4+ | { type : 'text' ; text : string }
5+ | { type : 'image' ; data : string ; mimeType : string }
6+ | {
7+ type : 'resource' ;
8+ resource : { uri : string ; mimeType ?: string ; text ?: string ; blob ?: string } ;
9+ } ;
10+
311export type McpMethodParams = {
412 'ui/open-link' : { url : string } ;
5- 'ui/message' : { content : { type : string ; text : string } } ;
13+ 'ui/message' : { role : 'user' ; content : ContentBlock [ ] } ;
614 'tools/call' : { name : string ; arguments ?: Record < string , unknown > } ;
715 'resources/read' : { uri : string } ;
816 'notifications/message' : { level ?: string ; logger ?: string ; data : unknown } ;
@@ -11,7 +19,7 @@ export type McpMethodParams = {
1119
1220export type McpMethodResponse = {
1321 'ui/open-link' : { status : string ; message : string } ;
14- 'ui/message' : { status : string ; message : string } ;
22+ 'ui/message' : Record < string , never > ;
1523 'tools/call' : {
1624 content : unknown [ ] ;
1725 isError : boolean ;
You can’t perform that action at this time.
0 commit comments