@@ -42,7 +42,6 @@ export default class ControllerAppBootHook {
4242 return new EggControllerLoader ( unitPath ) ;
4343 } ) ;
4444 this . controllerRegisterFactory . registerControllerRegister ( ControllerType . HTTP , HTTPControllerRegister . create ) ;
45- this . controllerRegisterFactory . registerControllerRegister ( ControllerType . MCP , MCPControllerRegister . create ) ;
4645 this . app . loadUnitFactory . registerLoadUnitCreator (
4746 CONTROLLER_LOAD_UNIT ,
4847 ( ctx : LoadUnitLifecycleContext ) : ControllerLoadUnit => {
@@ -63,8 +62,11 @@ export default class ControllerAppBootHook {
6362
6463 // init http root proto middleware
6564 this . prepareMiddleware ( this . app . config . coreMiddleware ) ;
66- // Don't let the mcp's body be consumed
67- this . app . config . coreMiddleware . unshift ( 'mcpBodyMiddleware' ) ;
65+ if ( this . app . mcpProxy ) {
66+ this . controllerRegisterFactory . registerControllerRegister ( ControllerType . MCP , MCPControllerRegister . create ) ;
67+ // Don't let the mcp's body be consumed
68+ this . app . config . coreMiddleware . unshift ( 'mcpBodyMiddleware' ) ;
69+ }
6870 }
6971
7072 prepareMiddleware ( middlewareNames : string [ ] ) {
@@ -88,7 +90,9 @@ export default class ControllerAppBootHook {
8890 // and register methods after collect is done.
8991 HTTPControllerRegister . instance ?. doRegister ( this . app . rootProtoManager ) ;
9092
91- await ( this . app . mcpProxy as any ) ?. ready ( ) ;
93+ if ( this . app . mcpProxy ) {
94+ await ( this . app . mcpProxy as any ) ?. ready ( ) ;
95+ }
9296 }
9397
9498 async beforeClose ( ) {
0 commit comments