Skip to content

Commit f6fa17f

Browse files
committed
fix(backend): enhance credential validation request handling for satellite
1 parent 0607e39 commit f6fa17f

File tree

1 file changed

+46
-9
lines changed

1 file changed

+46
-9
lines changed

services/backend/src/services/mcpHealthCheckService.ts

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,7 @@ export class McpHealthCheckService {
590590
/**
591591
* Request satellite to validate API key credentials for an installation
592592
* Creates a health_check command with credential_validation type
593+
* Sends to the installation's assigned satellite, or broadcasts to all global satellites if no specific satellite
593594
*/
594595
async requestCredentialValidation(installationId: string, teamId: string): Promise<void> {
595596
if (!this.satelliteCommandService) {
@@ -601,22 +602,58 @@ export class McpHealthCheckService {
601602
return;
602603
}
603604

604-
await this.satelliteCommandService.createCommandForAllGlobalSatellites({
605-
commandType: 'health_check',
606-
priority: 'normal',
605+
// Query the installation to get its satellite_id
606+
const installation = await this.db
607+
.select({
608+
satellite_id: this.mcpServerInstallations.satellite_id
609+
})
610+
.from(this.mcpServerInstallations)
611+
.where(eq(this.mcpServerInstallations.id, installationId))
612+
.limit(1);
613+
614+
if (!installation || installation.length === 0) {
615+
this.logger.warn({
616+
operation: 'credential_validation_request_skipped',
617+
installationId,
618+
reason: 'installation_not_found'
619+
}, `Cannot request credential validation - installation ${installationId} not found`);
620+
return;
621+
}
622+
623+
const satelliteId = installation[0].satellite_id;
624+
625+
const commandOptions = {
626+
commandType: 'health_check' as const,
627+
priority: 'normal' as const,
607628
payload: {
608629
check_type: 'credential_validation',
609630
installation_id: installationId
610631
},
611632
targetTeamId: teamId,
612633
expiresInMinutes: 5
613-
});
634+
};
614635

615-
this.logger.debug({
616-
operation: 'credential_validation_requested',
617-
installationId,
618-
teamId
619-
}, `Credential validation requested for installation ${installationId}`);
636+
if (satelliteId) {
637+
await this.satelliteCommandService.createCommandForSpecificSatellite(
638+
satelliteId,
639+
commandOptions
640+
);
641+
642+
this.logger.debug({
643+
operation: 'credential_validation_requested',
644+
installationId,
645+
teamId,
646+
satelliteId
647+
}, `Credential validation requested for installation ${installationId} on satellite ${satelliteId}`);
648+
} else {
649+
await this.satelliteCommandService.createCommandForAllGlobalSatellites(commandOptions);
650+
651+
this.logger.debug({
652+
operation: 'credential_validation_requested',
653+
installationId,
654+
teamId
655+
}, `Credential validation requested for installation ${installationId} (broadcast to all global satellites)`);
656+
}
620657
}
621658

622659
/**

0 commit comments

Comments
 (0)