@@ -681,7 +681,53 @@ export default async function deployRoutes(server: FastifyInstance) {
681681 } , 'Sent configure commands to satellites for all team members' ) ;
682682
683683 // ============================================
684- // STEP 11: Return Success (Installation Created!)
684+ // STEP 11: Emit MCP_DEPLOYMENT_CREATED Event
685+ // ============================================
686+ try {
687+ const eventContext = {
688+ db : db ,
689+ logger : request . log ,
690+ user : {
691+ id : userId ,
692+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
693+ email : ( request . user as any ) . email ,
694+ roleId : 'unknown'
695+ } ,
696+ request : {
697+ ip : request . ip ,
698+ userAgent : request . headers [ 'user-agent' ] ,
699+ requestId : request . id
700+ } ,
701+ timestamp : new Date ( )
702+ } ;
703+
704+ server . eventBus . emitWithContext (
705+ EVENT_NAMES . MCP_DEPLOYMENT_CREATED ,
706+ {
707+ deployment : {
708+ installationId : mcpInstallation . id ,
709+ serverId,
710+ commitSha
711+ } ,
712+ deployedBy : {
713+ id : userId ,
714+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
715+ email : ( request . user as any ) . email
716+ } ,
717+ metadata : {
718+ ip : request . ip
719+ }
720+ } ,
721+ eventContext
722+ ) ;
723+ request . log . info ( `MCP_DEPLOYMENT_CREATED event emitted for installation: ${ mcpInstallation . id } ` ) ;
724+ } catch ( eventError ) {
725+ request . log . error ( eventError , `Failed to emit MCP_DEPLOYMENT_CREATED event for installation ${ mcpInstallation . id } :` ) ;
726+ // Don't fail deployment if event emission fails
727+ }
728+
729+ // ============================================
730+ // STEP 12: Return Success (Installation Created!)
685731 // ============================================
686732 const successResponse : DeploySuccessResponse = {
687733 success : true ,
0 commit comments