Skip to content

Commit b3df717

Browse files
author
Lasim
committed
fix(backend): notify satellites when auto-installing MCP servers for new teams
1 parent b3fe4a0 commit b3df717

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

services/backend/src/services/teamService.ts

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -487,9 +487,11 @@ export class TeamService {
487487
}, `Found ${autoInstallServers.length} MCP servers marked for auto-installation`);
488488
}
489489

490-
// Import McpInstallationService dynamically to avoid circular dependencies
490+
// Import services dynamically to avoid circular dependencies
491491
const { McpInstallationService } = await import('./mcpInstallationService');
492+
const { SatelliteCommandService } = await import('./satelliteCommandService');
492493
const installationService = new McpInstallationService(db, logger || console as any);
494+
const satelliteCommandService = new SatelliteCommandService(db, logger || console as any);
493495

494496
let successCount = 0;
495497
let errorCount = 0;
@@ -498,8 +500,8 @@ export class TeamService {
498500
for (const server of autoInstallServers) {
499501
try {
500502
const installationName = server.name; // Use server name as installation name
501-
502-
await installationService.createInstallation(
503+
504+
const installation = await installationService.createInstallation(
503505
teamId,
504506
userId,
505507
{
@@ -510,8 +512,35 @@ export class TeamService {
510512
}
511513
);
512514

515+
// Notify satellites about the new installation
516+
try {
517+
const commands = await satelliteCommandService.notifyMcpInstallation(
518+
installation.id,
519+
teamId,
520+
userId
521+
);
522+
523+
if (logger) {
524+
logger.debug({
525+
operation: 'auto_install_mcp_servers',
526+
installationId: installation.id,
527+
commandsCreated: commands.length,
528+
satelliteIds: commands.map(c => c.satellite_id)
529+
}, 'Satellite commands created for auto-installed MCP server');
530+
}
531+
} catch (commandError) {
532+
// Log but don't fail - installation succeeded
533+
if (logger) {
534+
logger.warn({
535+
error: commandError,
536+
operation: 'auto_install_mcp_servers',
537+
installationId: installation.id
538+
}, 'Failed to create satellite commands for auto-installed MCP server');
539+
}
540+
}
541+
513542
successCount++;
514-
543+
515544
if (logger) {
516545
logger.debug({
517546
operation: 'auto_install_mcp_servers',

0 commit comments

Comments
 (0)