@@ -65,6 +65,9 @@ export class RefreshService {
6565 // Detect current device information
6666 const deviceInfo = await detectDeviceInfo ( ) ;
6767
68+ // Get existing configuration for change detection
69+ const oldConfig = await this . mcpService . getMCPConfig ( credentials . selectedTeam . id ) ;
70+
6871 // Download merged configurations using the new gateway endpoint
6972 // Backend will automatically find device by hardware_id
7073 const gatewayConfig = await this . mcpService . downloadGatewayMCPConfig ( deviceInfo . hardware_id , api , false ) ;
@@ -76,14 +79,16 @@ export class RefreshService {
7679 gatewayConfig
7780 ) ;
7881
82+ // Detect configuration changes
83+ const changeInfo = this . detectConfigurationChanges ( oldConfig , teamMCPConfig ) ;
84+
7985 // Store the converted configuration
8086 await this . mcpService . storeMCPConfig ( teamMCPConfig ) ;
8187
8288 const readyServers = gatewayConfig . servers . filter ( s => s . status === 'ready' ) ;
8389 const invalidServers = gatewayConfig . servers . filter ( s => s . status === 'invalid' ) ;
8490
8591 spinner . succeed ( `Gateway MCP configurations refreshed (${ readyServers . length } ready, ${ invalidServers . length } invalid)` ) ;
86- console . log ( chalk . green ( '✅ MCP configuration has been refreshed using new three-tier system' ) ) ;
8792
8893 if ( invalidServers . length > 0 ) {
8994 console . log ( chalk . yellow ( `\n⚠️ ${ invalidServers . length } server${ invalidServers . length === 1 ? '' : 's' } marked as invalid:` ) ) ;
@@ -93,44 +98,12 @@ export class RefreshService {
9398 console . log ( chalk . gray ( `💡 Configure these servers in the web UI to make them available` ) ) ;
9499 }
95100
96- // Step 2: Check if gateway restart is needed
97- const isRunning = this . restartService . isServerRunning ( ) ;
98-
99- if ( isRunning ) {
100- console . log ( chalk . yellow ( '\n⚠️ Gateway restart required for changes to take effect.' ) ) ;
101-
102- // Prompt user for restart
103- const { shouldRestart } = await inquirer . prompt ( [
104- {
105- type : 'confirm' ,
106- name : 'shouldRestart' ,
107- message : 'Do you want to restart the DeployStack Gateway now?' ,
108- default : true
109- }
110- ] ) ;
111-
112- if ( shouldRestart ) {
113- console . log ( chalk . blue ( '\n🔄 Restarting gateway with updated configuration...' ) ) ;
114-
115- try {
116- const result = await this . restartService . restartGatewayServer ( ) ;
117-
118- if ( result . restarted ) {
119- console . log ( chalk . green ( '✅ Gateway restarted successfully with new configuration' ) ) ;
120-
121- if ( result . mcpServersStarted !== undefined ) {
122- console . log ( chalk . blue ( `🤖 Ready to serve ${ result . mcpServersStarted } MCP server${ result . mcpServersStarted === 1 ? '' : 's' } ` ) ) ;
123- }
124- }
125- } catch ( error ) {
126- console . log ( chalk . red ( `❌ Failed to restart gateway: ${ error instanceof Error ? error . message : String ( error ) } ` ) ) ;
127- console . log ( chalk . gray ( '💡 You can restart manually with "deploystack restart"' ) ) ;
128- }
129- } else {
130- console . log ( chalk . gray ( '💡 Configuration updated. Restart gateway manually with "deploystack restart" when ready.' ) ) ;
131- }
101+ // Step 2: Handle configuration changes
102+ if ( changeInfo . hasChanges ) {
103+ await this . handleConfigurationChanges ( changeInfo ) ;
132104 } else {
133- console . log ( chalk . gray ( '💡 Gateway is not currently running. Changes will take effect when you start it.' ) ) ;
105+ console . log ( chalk . green ( '✅ No configuration changes detected - your MCP servers are up to date' ) ) ;
106+ console . log ( chalk . gray ( '💡 All servers are already running with the latest configuration' ) ) ;
134107 }
135108
136109 // Show summary
0 commit comments