Skip to content

Commit 3cdfc02

Browse files
author
Lasim
committed
refactor(gateway): remove tools refresh notification endpoint and client notification service
1 parent 925cd6e commit 3cdfc02

File tree

3 files changed

+0
-284
lines changed

3 files changed

+0
-284
lines changed

services/gateway/src/core/server/proxy.ts

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,6 @@ export class ProxyServer {
246246
await this.handleRestartServer(request, reply);
247247
});
248248

249-
// Tools refresh notification endpoint
250-
this.fastify.post('/api/tools/refresh', async (request, reply) => {
251-
await this.handleToolsRefresh(request, reply);
252-
});
253249

254250
// Logs streaming endpoint - real-time log streaming via SSE
255251
this.fastify.get('/logs/stream', async (request, reply) => {
@@ -1347,51 +1343,4 @@ export class ProxyServer {
13471343
}
13481344
}
13491345

1350-
/**
1351-
* Handle tools refresh notification - notify all connected clients about tool changes
1352-
*/
1353-
private async handleToolsRefresh(request: FastifyRequest, reply: FastifyReply): Promise<void> {
1354-
try {
1355-
const body = request.body as any;
1356-
const reason = body?.reason || 'manual_refresh';
1357-
1358-
console.log(chalk.blue(`[API] Tools refresh notification: ${reason}`));
1359-
1360-
// Import ClientNotificationService here to avoid circular dependencies
1361-
const { ClientNotificationService } = await import('../../services/client-notification-service');
1362-
1363-
// Create notification service with current handlers
1364-
const notificationService = new ClientNotificationService(
1365-
this.sessionManager,
1366-
this.streamableHandler,
1367-
this.sseHandler
1368-
);
1369-
1370-
// Notify all connected clients about tool changes
1371-
const result = await notificationService.notifyToolsChanged();
1372-
1373-
console.log(chalk.green(`[API] Notified ${result.totalNotified} clients about tool changes`));
1374-
if (result.errors.length > 0) {
1375-
console.log(chalk.yellow(`[API] ${result.errors.length} notification errors occurred`));
1376-
}
1377-
1378-
reply.code(200).send({
1379-
success: true,
1380-
message: 'Tool refresh notifications sent',
1381-
totalNotified: result.totalNotified,
1382-
sseNotified: result.sseNotified,
1383-
streamableHttpNotified: result.streamableHttpNotified,
1384-
errors: result.errors.length,
1385-
reason
1386-
});
1387-
1388-
} catch (error) {
1389-
console.error(chalk.red(`[API] Error handling tools refresh:`), error);
1390-
1391-
reply.code(500).send({
1392-
error: 'Internal server error',
1393-
message: error instanceof Error ? error.message : String(error)
1394-
});
1395-
}
1396-
}
13971346
}

services/gateway/src/services/client-notification-service.ts

Lines changed: 0 additions & 181 deletions
This file was deleted.

services/gateway/src/services/refresh-service.ts

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { CredentialStorage } from '../core/auth/storage';
44
import { DeployStackAPI } from '../core/auth/api-client';
55
import { MCPConfigService } from '../core/mcp';
66
import { ConfigurationChangeService } from './configuration-change-service';
7-
import { ClientNotificationService } from './client-notification-service';
87
import { AuthenticationError } from '../types/auth';
98
import { detectDeviceInfo } from '../utils/device-detection';
109

@@ -100,9 +99,6 @@ export class RefreshService {
10099
// Step 2: Handle configuration changes
101100
if (changeInfo.hasChanges) {
102101
await this.changeService.handleConfigurationChanges(changeInfo, teamMCPConfig.servers);
103-
104-
// Step 3: Notify connected clients about tool changes
105-
await this.notifyConnectedClients();
106102
} else {
107103
console.log(chalk.green('✅ No configuration changes detected - your MCP servers are up to date'));
108104
console.log(chalk.gray('💡 All servers are already running with the latest configuration'));
@@ -141,52 +137,4 @@ export class RefreshService {
141137
}
142138
}
143139

144-
/**
145-
* Notify connected clients about tool changes using HTTP requests to the running gateway
146-
*/
147-
private async notifyConnectedClients(): Promise<void> {
148-
try {
149-
console.log(chalk.blue('Notifying connected MCP clients about tool changes...'));
150-
151-
// Try to notify the running gateway about tool changes
152-
// The gateway will handle notifying all connected clients
153-
const gatewayUrl = 'http://localhost:9095';
154-
155-
try {
156-
const fetch = (await import('node-fetch')).default;
157-
const response = await fetch(`${gatewayUrl}/api/tools/refresh`, {
158-
method: 'POST',
159-
headers: {
160-
'Content-Type': 'application/json'
161-
},
162-
body: JSON.stringify({ reason: 'configuration_refresh' })
163-
});
164-
165-
if (response.ok) {
166-
const result = await response.json() as {
167-
totalNotified?: number;
168-
sseNotified?: number;
169-
streamableHttpNotified?: number;
170-
};
171-
console.log(chalk.green(`✅ Notified ${result.totalNotified || 0} connected clients`));
172-
if (result.sseNotified && result.sseNotified > 0) {
173-
console.log(chalk.gray(` • SSE clients: ${result.sseNotified}`));
174-
}
175-
if (result.streamableHttpNotified && result.streamableHttpNotified > 0) {
176-
console.log(chalk.gray(` • Streamable HTTP clients: ${result.streamableHttpNotified}`));
177-
}
178-
} else {
179-
throw new Error(`HTTP ${response.status}`);
180-
}
181-
} catch (error) {
182-
// Gateway might not be running, which is fine
183-
console.log(chalk.gray('💡 Gateway not running - clients will receive updated tools when they connect'));
184-
}
185-
186-
} catch (error) {
187-
console.log(chalk.yellow(`⚠️ Failed to notify some clients: ${error instanceof Error ? error.message : String(error)}`));
188-
console.log(chalk.gray('💡 Clients will still receive updated tools on their next request'));
189-
}
190-
}
191-
192140
}

0 commit comments

Comments
 (0)