File tree Expand file tree Collapse file tree 4 files changed +68
-2
lines changed
Expand file tree Collapse file tree 4 files changed +68
-2
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ export const EVENT_NAMES = {
3838 MCP_SERVER_CREATED : 'mcp.server_created' , // matches mcp.servers.create
3939 MCP_SERVER_UPDATED : 'mcp.server_updated' , // matches mcp.servers.edit
4040 MCP_SERVER_DELETED : 'mcp.server_deleted' , // matches mcp.servers.delete
41+ MCP_DEPLOYMENT_CREATED : 'mcp.deployment_created' , // matches mcp.servers.deploy permission
4142
4243 // System Events
4344 SYSTEM_STARTUP : 'system.startup' ,
Original file line number Diff line number Diff line change @@ -51,7 +51,11 @@ export const {
5151 MCP_INSTALLATION_CREATED ,
5252 MCP_INSTALLATION_UPDATED ,
5353 MCP_INSTALLATION_DELETED ,
54-
54+ MCP_SERVER_CREATED ,
55+ MCP_SERVER_UPDATED ,
56+ MCP_SERVER_DELETED ,
57+ MCP_DEPLOYMENT_CREATED ,
58+
5559 // System Events
5660 SYSTEM_STARTUP ,
5761 SYSTEM_SHUTDOWN ,
Original file line number Diff line number Diff line change @@ -387,6 +387,21 @@ export interface CoreEventData {
387387 } ;
388388 } ;
389389
390+ [ EVENT_NAMES . MCP_DEPLOYMENT_CREATED ] : {
391+ deployment : {
392+ installationId : string ;
393+ serverId : string ;
394+ commitSha : string ;
395+ } ;
396+ deployedBy : {
397+ id : string ;
398+ email : string ;
399+ } ;
400+ metadata : {
401+ ip : string ;
402+ } ;
403+ } ;
404+
390405 [ EVENT_NAMES . SYSTEM_STARTUP ] : {
391406 version : string ;
392407 environment : string ;
Original file line number Diff line number Diff line change @@ -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 ,
You can’t perform that action at this time.
0 commit comments