File tree Expand file tree Collapse file tree
packages/client/src/components Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -88,11 +88,14 @@ export const HtmlResource: React.FC<RenderHtmlResourceProps> = ({
8888
8989 useEffect ( ( ) => {
9090 function handleMessage ( event : MessageEvent ) {
91- if ( event . data && typeof event . data === 'object' && event . data . tool ) {
92- onGenericMcpAction ( event . data . tool , event . data . params || { } )
93- . catch ( err => {
94- console . error ( "Error from onGenericMcpAction in RenderHtmlResource:" , err ) ;
95- } ) ;
91+ // Only process the message if it came from this specific iframe
92+ if ( iframeRef . current && event . source === iframeRef . current . contentWindow ) {
93+ if ( event . data ?. tool ) {
94+ onGenericMcpAction ( event . data . tool , event . data . params || { } )
95+ . catch ( err => {
96+ console . error ( "Error from onGenericMcpAction in RenderHtmlResource:" , err ) ;
97+ } ) ;
98+ }
9699 }
97100 }
98101 window . addEventListener ( 'message' , handleMessage ) ;
You can’t perform that action at this time.
0 commit comments