@@ -76,7 +76,13 @@ pub struct GenerateArgs {
7676
7777 /// Generate integration tests and mocks.
7878 #[ clap( long, env = "CDD_TESTS" ) ]
79+ #[ clap( long, env = "CDD_TESTS" ) ]
7980 pub tests : bool ,
81+
82+ /// Generate Model Context Protocol (MCP) server and adapter.
83+
84+ #[ clap( long, env = "CDD_MCP" ) ]
85+ pub mcp : bool ,
8086}
8187
8288impl GenerateArgs {
@@ -119,6 +125,9 @@ pub fn execute(args: &FromOpenApiArgs) -> AppResult<()> {
119125 FromOpenApiCommands :: SdkCli ( gen_args) => {
120126 println ! ( "Generating SDK CLI..." ) ;
121127 run_generation ( gen_args, & ClapCliStrategy ) ?;
128+ if gen_args. mcp {
129+ run_generation ( gen_args, & cdd_core:: strategies:: McpClientStrategy ) ?;
130+ }
122131 }
123132 FromOpenApiCommands :: Sdk ( gen_args) => {
124133 println ! ( "Generating SDK..." ) ;
@@ -312,6 +321,7 @@ mod tests {
312321 no_github_actions : false ,
313322 no_installable_package : false ,
314323 tests : false ,
324+ mcp : false ,
315325 } ;
316326 let dir = args. get_output_dir ( ) ;
317327 assert_eq ! (
@@ -330,6 +340,7 @@ mod tests {
330340 no_github_actions : false ,
331341 no_installable_package : false ,
332342 tests : false ,
343+ mcp : false ,
333344 } ;
334345 assert_eq ! ( args. get_output_dir( ) , path) ;
335346 }
@@ -344,6 +355,7 @@ mod tests {
344355 no_github_actions : false ,
345356 no_installable_package : false ,
346357 tests : false ,
358+ mcp : false ,
347359 } ;
348360 assert_eq ! ( args. get_input_files( ) , vec![ path] ) ;
349361 }
@@ -365,6 +377,7 @@ mod tests {
365377 no_github_actions : false ,
366378 no_installable_package : false ,
367379 tests : false ,
380+ mcp : false ,
368381 } ;
369382 let mut files = args. get_input_files ( ) ;
370383 files. sort ( ) ;
@@ -382,6 +395,7 @@ mod tests {
382395 no_github_actions : false ,
383396 no_installable_package : false ,
384397 tests : false ,
398+ mcp : false ,
385399 } ;
386400 assert ! ( args. get_input_files( ) . is_empty( ) ) ;
387401 }
@@ -422,6 +436,7 @@ components:
422436 no_github_actions : false ,
423437 no_installable_package : false ,
424438 tests : false ,
439+ mcp : false ,
425440 } ) ,
426441 } ;
427442 assert ! ( execute( & args) . is_ok( ) ) ;
@@ -435,6 +450,7 @@ components:
435450 no_github_actions : false ,
436451 no_installable_package : false ,
437452 tests : false ,
453+ mcp : false ,
438454 } ) ,
439455 } ;
440456 assert ! ( execute( & args) . is_ok( ) ) ;
@@ -448,6 +464,7 @@ components:
448464 no_github_actions : false ,
449465 no_installable_package : false ,
450466 tests : false ,
467+ mcp : false ,
451468 } ) ,
452469 } ;
453470 assert ! ( execute( & args) . is_ok( ) ) ;
@@ -462,6 +479,7 @@ components:
462479 no_github_actions : false ,
463480 no_installable_package : false ,
464481 tests : false ,
482+ mcp : false ,
465483 } ,
466484 framework : ServerFramework :: ActixWeb ,
467485 } ,
@@ -478,6 +496,7 @@ components:
478496 no_github_actions : false ,
479497 no_installable_package : false ,
480498 tests : false ,
499+ mcp : false ,
481500 } ,
482501 framework : ServerFramework :: Axum ,
483502 } ,
@@ -494,6 +513,7 @@ components:
494513 no_github_actions : false ,
495514 no_installable_package : false ,
496515 tests : false ,
516+ mcp : false ,
497517 } ;
498518 let result = run_generation ( & args, & cdd_core:: strategies:: ActixStrategy ) ;
499519 assert ! ( result. is_err( ) ) ;
@@ -508,6 +528,7 @@ components:
508528 no_github_actions : false ,
509529 no_installable_package : false ,
510530 tests : false ,
531+ mcp : false ,
511532 } ;
512533 let result = run_generation ( & args, & cdd_core:: strategies:: ActixStrategy ) ;
513534 assert ! ( result. is_err( ) ) ;
@@ -528,6 +549,7 @@ components:
528549 no_github_actions : true ,
529550 no_installable_package : true ,
530551 tests : true ,
552+ mcp : false ,
531553 } ;
532554 let _ = run_generation ( & args, & cdd_core:: strategies:: ActixStrategy ) ;
533555 Ok ( ( ) )
@@ -552,7 +574,11 @@ pub struct FromOpenApiConfig {
552574 pub output_dir : Option < PathBuf > ,
553575 pub no_github_actions : bool ,
554576 pub no_installable_package : bool ,
577+
555578 pub tests : bool ,
579+
580+ /// Generate Model Context Protocol (MCP) server and adapter.
581+ pub mcp : bool ,
556582 pub framework : ServerFramework ,
557583}
558584
@@ -565,10 +591,18 @@ pub fn generate_from_openapi(config: &FromOpenApiConfig) -> AppResult<()> {
565591 no_github_actions : config. no_github_actions ,
566592 no_installable_package : config. no_installable_package ,
567593 tests : config. tests ,
594+ mcp : config. mcp ,
568595 } ;
569596
570597 match config. subcommand . as_str ( ) {
571- "to_sdk_cli" => run_generation ( & gen_args, & ClapCliStrategy ) ,
598+ "to_sdk_cli" => {
599+ let res = run_generation ( & gen_args, & ClapCliStrategy ) ;
600+ if gen_args. mcp && res. is_ok ( ) {
601+ run_generation ( & gen_args, & cdd_core:: strategies:: McpClientStrategy )
602+ } else {
603+ res
604+ }
605+ }
572606 "to_sdk" => run_generation ( & gen_args, & ReqwestStrategy ) ,
573607 "to_sdk_mcp" => run_generation ( & gen_args, & cdd_core:: strategies:: McpClientStrategy ) ,
574608 "to_server" => match config. framework {
0 commit comments