@@ -353,7 +353,40 @@ suite("Roo Code use_mcp_tool Tool", function () {
353353 }
354354 }
355355 api . on ( "taskCompleted" , taskCompletedHandler )
356+ await sleep ( 2000 ) // Wait for Roo Code to fully initialize
357+
358+ // Trigger MCP server detection by opening and modifying the file
359+ console . log ( "Triggering MCP server detection by modifying the config file..." )
360+ try {
361+ const mcpConfigUri = vscode . Uri . file ( testFiles . mcpConfig )
362+ const document = await vscode . workspace . openTextDocument ( mcpConfigUri )
363+ const editor = await vscode . window . showTextDocument ( document )
364+
365+ // Make a small modification to trigger the save event, without this Roo Code won't load the MCP server
366+ const edit = new vscode . WorkspaceEdit ( )
367+ const currentContent = document . getText ( )
368+ const modifiedContent = currentContent . replace (
369+ '"alwaysAllow": []' ,
370+ '"alwaysAllow": ["read_file", "read_multiple_files", "write_file", "edit_file", "create_directory", "list_directory", "directory_tree", "move_file", "search_files", "get_file_info", "list_allowed_directories"]' ,
371+ )
372+
373+ const fullRange = new vscode . Range ( document . positionAt ( 0 ) , document . positionAt ( document . getText ( ) . length ) )
356374
375+ edit . replace ( mcpConfigUri , fullRange , modifiedContent )
376+ await vscode . workspace . applyEdit ( edit )
377+
378+ // Save the document to trigger MCP server detection
379+ await editor . document . save ( )
380+
381+ // Close the editor
382+ await vscode . commands . executeCommand ( "workbench.action.closeActiveEditor" )
383+
384+ console . log ( "MCP config file modified and saved successfully" )
385+ } catch ( error ) {
386+ console . error ( "Failed to modify/save MCP config file:" , error )
387+ }
388+
389+ await sleep ( 5000 ) // Wait for MCP servers to initialize
357390 let taskId : string
358391 try {
359392 // Start task requesting to use MCP filesystem write_file tool
@@ -481,7 +514,40 @@ suite("Roo Code use_mcp_tool Tool", function () {
481514 }
482515 }
483516 api . on ( "taskCompleted" , taskCompletedHandler )
517+ await sleep ( 2000 ) // Wait for Roo Code to fully initialize
484518
519+ // Trigger MCP server detection by opening and modifying the file
520+ console . log ( "Triggering MCP server detection by modifying the config file..." )
521+ try {
522+ const mcpConfigUri = vscode . Uri . file ( testFiles . mcpConfig )
523+ const document = await vscode . workspace . openTextDocument ( mcpConfigUri )
524+ const editor = await vscode . window . showTextDocument ( document )
525+
526+ // Make a small modification to trigger the save event, without this Roo Code won't load the MCP server
527+ const edit = new vscode . WorkspaceEdit ( )
528+ const currentContent = document . getText ( )
529+ const modifiedContent = currentContent . replace (
530+ '"alwaysAllow": []' ,
531+ '"alwaysAllow": ["read_file", "read_multiple_files", "write_file", "edit_file", "create_directory", "list_directory", "directory_tree", "move_file", "search_files", "get_file_info", "list_allowed_directories"]' ,
532+ )
533+
534+ const fullRange = new vscode . Range ( document . positionAt ( 0 ) , document . positionAt ( document . getText ( ) . length ) )
535+
536+ edit . replace ( mcpConfigUri , fullRange , modifiedContent )
537+ await vscode . workspace . applyEdit ( edit )
538+
539+ // Save the document to trigger MCP server detection
540+ await editor . document . save ( )
541+
542+ // Close the editor
543+ await vscode . commands . executeCommand ( "workbench.action.closeActiveEditor" )
544+
545+ console . log ( "MCP config file modified and saved successfully" )
546+ } catch ( error ) {
547+ console . error ( "Failed to modify/save MCP config file:" , error )
548+ }
549+
550+ await sleep ( 5000 ) // Wait for MCP servers to initialize
485551 let taskId : string
486552 try {
487553 // Start task requesting MCP filesystem list_directory tool
@@ -620,7 +686,40 @@ suite("Roo Code use_mcp_tool Tool", function () {
620686 }
621687 }
622688 api . on ( "taskCompleted" , taskCompletedHandler )
689+ await sleep ( 2000 ) // Wait for Roo Code to fully initialize
623690
691+ // Trigger MCP server detection by opening and modifying the file
692+ console . log ( "Triggering MCP server detection by modifying the config file..." )
693+ try {
694+ const mcpConfigUri = vscode . Uri . file ( testFiles . mcpConfig )
695+ const document = await vscode . workspace . openTextDocument ( mcpConfigUri )
696+ const editor = await vscode . window . showTextDocument ( document )
697+
698+ // Make a small modification to trigger the save event, without this Roo Code won't load the MCP server
699+ const edit = new vscode . WorkspaceEdit ( )
700+ const currentContent = document . getText ( )
701+ const modifiedContent = currentContent . replace (
702+ '"alwaysAllow": []' ,
703+ '"alwaysAllow": ["read_file", "read_multiple_files", "write_file", "edit_file", "create_directory", "list_directory", "directory_tree", "move_file", "search_files", "get_file_info", "list_allowed_directories"]' ,
704+ )
705+
706+ const fullRange = new vscode . Range ( document . positionAt ( 0 ) , document . positionAt ( document . getText ( ) . length ) )
707+
708+ edit . replace ( mcpConfigUri , fullRange , modifiedContent )
709+ await vscode . workspace . applyEdit ( edit )
710+
711+ // Save the document to trigger MCP server detection
712+ await editor . document . save ( )
713+
714+ // Close the editor
715+ await vscode . commands . executeCommand ( "workbench.action.closeActiveEditor" )
716+
717+ console . log ( "MCP config file modified and saved successfully" )
718+ } catch ( error ) {
719+ console . error ( "Failed to modify/save MCP config file:" , error )
720+ }
721+
722+ await sleep ( 5000 ) // Wait for MCP servers to initialize
624723 let taskId : string
625724 try {
626725 // Start task requesting MCP filesystem directory_tree tool
@@ -841,7 +940,40 @@ suite("Roo Code use_mcp_tool Tool", function () {
841940 }
842941 }
843942 api . on ( "taskCompleted" , taskCompletedHandler )
943+ await sleep ( 2000 ) // Wait for Roo Code to fully initialize
844944
945+ // Trigger MCP server detection by opening and modifying the file
946+ console . log ( "Triggering MCP server detection by modifying the config file..." )
947+ try {
948+ const mcpConfigUri = vscode . Uri . file ( testFiles . mcpConfig )
949+ const document = await vscode . workspace . openTextDocument ( mcpConfigUri )
950+ const editor = await vscode . window . showTextDocument ( document )
951+
952+ // Make a small modification to trigger the save event, without this Roo Code won't load the MCP server
953+ const edit = new vscode . WorkspaceEdit ( )
954+ const currentContent = document . getText ( )
955+ const modifiedContent = currentContent . replace (
956+ '"alwaysAllow": []' ,
957+ '"alwaysAllow": ["read_file", "read_multiple_files", "write_file", "edit_file", "create_directory", "list_directory", "directory_tree", "move_file", "search_files", "get_file_info", "list_allowed_directories"]' ,
958+ )
959+
960+ const fullRange = new vscode . Range ( document . positionAt ( 0 ) , document . positionAt ( document . getText ( ) . length ) )
961+
962+ edit . replace ( mcpConfigUri , fullRange , modifiedContent )
963+ await vscode . workspace . applyEdit ( edit )
964+
965+ // Save the document to trigger MCP server detection
966+ await editor . document . save ( )
967+
968+ // Close the editor
969+ await vscode . commands . executeCommand ( "workbench.action.closeActiveEditor" )
970+
971+ console . log ( "MCP config file modified and saved successfully" )
972+ } catch ( error ) {
973+ console . error ( "Failed to modify/save MCP config file:" , error )
974+ }
975+
976+ await sleep ( 5000 ) // Wait for MCP servers to initialize
845977 let taskId : string
846978 try {
847979 // Start task requesting MCP filesystem get_file_info tool
@@ -857,7 +989,7 @@ suite("Roo Code use_mcp_tool Tool", function () {
857989 } )
858990
859991 // Wait for attempt_completion to be called (indicating task finished)
860- await waitFor ( ( ) => attemptCompletionCalled , { timeout : 45_000 } )
992+ await waitFor ( ( ) => attemptCompletionCalled , { timeout : 50_000 } )
861993
862994 // Verify the MCP tool was requested with valid format
863995 assert . ok ( mcpToolRequested , "The use_mcp_tool should have been requested" )
0 commit comments