File tree Expand file tree Collapse file tree
packages/ai-native/src/browser/mcp/tools Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,13 +15,16 @@ function getResult(raw: string) {
1515 } = { } ;
1616
1717 try {
18- const data = JSON . parse ( raw ) ;
18+ const data : {
19+ content : { type : string ; text : string } [ ] ;
20+ isError ?: boolean ;
21+ } = JSON . parse ( raw ) ;
1922 if ( data . isError ) {
2023 result . isError = data . isError ;
2124 }
2225
2326 if ( data . content ) {
24- result . text = data . content ;
27+ result . text = data . content . map ( ( item ) => item . text ) . join ( '\n' ) ;
2528 }
2629
2730 return result ;
@@ -36,7 +39,10 @@ export const TerminalToolComponent = memo((props: IMCPServerToolComponentProps)
3639 const [ disabled , toggleDisabled ] = useState ( false ) ;
3740
3841 const handleClick = useCallback ( ( approval : boolean ) => {
39- handler . handleApproval ( toolCallId ! , approval ) ;
42+ if ( ! toolCallId ) {
43+ return ;
44+ }
45+ handler . handleApproval ( toolCallId , approval ) ;
4046 toggleDisabled ( true ) ;
4147 } , [ ] ) ;
4248
Original file line number Diff line number Diff line change @@ -56,7 +56,12 @@ export class RunCommandHandler {
5656 if ( ! approval ) {
5757 return {
5858 isError : false ,
59- content : 'User rejection' ,
59+ content : [
60+ {
61+ type : 'text' ,
62+ text : 'User rejection' ,
63+ } ,
64+ ] ,
6065 } ;
6166 }
6267 }
@@ -67,11 +72,14 @@ export class RunCommandHandler {
6772
6873 this . terminalController . showTerminalPanel ( ) ;
6974
70- const result : string [ ] = [ ] ;
71- const def = new Deferred < { isError ?: boolean ; content : string [ ] } > ( ) ;
75+ const result : { type : string ; text : string } [ ] = [ ] ;
76+ const def = new Deferred < { isError ?: boolean ; content : { type : string ; text : string } [ ] } > ( ) ;
7277
7378 terminalClient . onOutput ( ( e ) => {
74- result . push ( e . data . toString ( ) ) ;
79+ result . push ( {
80+ type : 'text' ,
81+ text : e . data . toString ( ) ,
82+ } ) ;
7583 } ) ;
7684
7785 terminalClient . onExit ( ( e ) => {
You can’t perform that action at this time.
0 commit comments