@@ -110,7 +110,6 @@ enum Command {
110110 Config ( services:: config:: ConfigSubcommand ) ,
111111 Setup ( services:: setup:: SetupRequest ) ,
112112 Doctor ( services:: doctor:: DoctorRequest ) ,
113- Mcp ,
114113 Hooks ( services:: hooks:: HookSubcommand ) ,
115114 Trace ( services:: trace:: TraceRequest ) ,
116115 Sync ( services:: sync:: SyncRequest ) ,
@@ -127,7 +126,6 @@ impl Command {
127126 Self :: Config ( _) => services:: config:: NAME ,
128127 Self :: Setup ( _) => services:: setup:: NAME ,
129128 Self :: Doctor ( _) => services:: doctor:: NAME ,
130- Self :: Mcp => services:: mcp:: NAME ,
131129 Self :: Hooks ( _) => services:: hooks:: NAME ,
132130 Self :: Trace ( _) => services:: trace:: NAME ,
133131 Self :: Sync ( _) => services:: sync:: NAME ,
@@ -185,6 +183,10 @@ fn write_stdout_payload<W>(writer: &mut W, payload: &str) -> Result<(), Classifi
185183where
186184 W : Write ,
187185{
186+ if payload. is_empty ( ) {
187+ return Ok ( ( ) ) ;
188+ }
189+
188190 writeln ! ( writer, "{payload}" ) . map_err ( |error| {
189191 ClassifiedError :: runtime ( format ! ( "Failed to write command output to stdout: {error}" ) )
190192 } )
@@ -268,7 +270,7 @@ where
268270 & [ ( "command" , command. name ( ) ) ] ,
269271 ) ;
270272
271- match dispatch ( & command) {
273+ match dispatch ( & command, & logger ) {
272274 Ok ( payload) => {
273275 logger. info (
274276 "sce.command.completed" ,
@@ -469,7 +471,6 @@ fn convert_clap_command(command: cli_schema::Commands) -> Result<Command, Classi
469471 } ,
470472 format : convert_output_format ( format) ,
471473 } ) ) ,
472- cli_schema:: Commands :: Mcp => Ok ( Command :: Mcp ) ,
473474 cli_schema:: Commands :: Hooks { subcommand } => convert_hooks_subcommand ( subcommand) ,
474475 cli_schema:: Commands :: Trace { subcommand } => convert_trace_subcommand ( subcommand) ,
475476 cli_schema:: Commands :: Sync { format } => Ok ( Command :: Sync ( services:: sync:: SyncRequest {
@@ -654,7 +655,10 @@ fn convert_trace_subcommand(
654655 }
655656}
656657
657- fn dispatch ( command : & Command ) -> Result < String , ClassifiedError > {
658+ fn dispatch (
659+ command : & Command ,
660+ _logger : & services:: observability:: Logger ,
661+ ) -> Result < String , ClassifiedError > {
658662 match command {
659663 Command :: Help => Ok ( command_surface:: help_text ( ) ) ,
660664 Command :: HelpText { text, .. } => Ok ( text. clone ( ) ) ,
@@ -716,8 +720,6 @@ fn dispatch(command: &Command) -> Result<String, ClassifiedError> {
716720 }
717721 Command :: Doctor ( request) => services:: doctor:: run_doctor ( * request)
718722 . map_err ( |error| ClassifiedError :: runtime ( error. to_string ( ) ) ) ,
719- Command :: Mcp => services:: mcp:: run_mcp_server_blocking ( )
720- . map_err ( |error| ClassifiedError :: runtime ( error. to_string ( ) ) ) ,
721723 Command :: Hooks ( subcommand) => services:: hooks:: run_hooks_subcommand ( subcommand. clone ( ) )
722724 . map_err ( |error| ClassifiedError :: runtime ( error. to_string ( ) ) ) ,
723725 Command :: Trace ( request) => services:: trace:: run_trace_subcommand ( request. clone ( ) )
@@ -839,6 +841,15 @@ mod tests {
839841 assert ! ( stderr. contains( "Try:" ) ) ;
840842 }
841843
844+ #[ test]
845+ fn empty_payload_does_not_write_stdout ( ) {
846+ let mut stdout = Vec :: new ( ) ;
847+
848+ super :: write_stdout_payload ( & mut stdout, "" ) . expect ( "empty payload should be skipped" ) ;
849+
850+ assert ! ( stdout. is_empty( ) ) ;
851+ }
852+
842853 #[ test]
843854 fn parse_failure_stderr_contract_is_exact_and_deterministic ( ) {
844855 let mut first_stdout = Vec :: new ( ) ;
@@ -1265,10 +1276,10 @@ mod tests {
12651276 }
12661277
12671278 #[ test]
1268- fn parser_routes_mcp ( ) {
1269- let command = parse_command ( vec ! [ "sce" . to_string( ) , "mcp" . to_string( ) ] )
1270- . expect ( "command should parse ") ;
1271- assert_eq ! ( command, Command :: Mcp ) ;
1279+ fn parser_rejects_mcp ( ) {
1280+ let error = parse_command ( vec ! [ "sce" . to_string( ) , "mcp" . to_string( ) ] )
1281+ . expect_err ( "mcp should be rejected ") ;
1282+ assert ! ( error . to_string ( ) . contains ( "Unknown command 'mcp'" ) ) ;
12721283 }
12731284
12741285 #[ test]
0 commit comments