@@ -23,6 +23,7 @@ public sealed class ServiceStartCommand : BaseCommand
2323 private const string _commandTitle = "Start MCP Server" ;
2424 private readonly Option < string > _transportOption = OptionDefinitions . Service . Transport ;
2525 private readonly Option < int > _portOption = OptionDefinitions . Service . Port ;
26+ private readonly Option < string ? > _serviceTypeOption = OptionDefinitions . Service . ServiceType ;
2627
2728 public override string Name => "start" ;
2829 public override string Description => "Starts Azure MCP Server." ;
@@ -33,6 +34,7 @@ protected override void RegisterOptions(Command command)
3334 base . RegisterOptions ( command ) ;
3435 command . AddOption ( _transportOption ) ;
3536 command . AddOption ( _portOption ) ;
37+ command . AddOption ( _serviceTypeOption ) ;
3638 }
3739
3840 public override async Task < CommandResponse > ExecuteAsync ( CommandContext context , ParseResult parseResult )
@@ -41,10 +43,15 @@ public override async Task<CommandResponse> ExecuteAsync(CommandContext context,
4143 ? OptionDefinitions . Service . Port . GetDefaultValue ( )
4244 : parseResult . GetValueForOption ( _portOption ) ;
4345
46+ var service = parseResult . GetValueForOption ( _serviceTypeOption ) == default
47+ ? OptionDefinitions . Service . ServiceType . GetDefaultValue ( )
48+ : parseResult . GetValueForOption ( _serviceTypeOption ) ;
49+
4450 var serverOptions = new ServiceStartOptions
4551 {
4652 Transport = parseResult . GetValueForOption ( _transportOption ) ?? TransportTypes . StdIo ,
47- Port = port
53+ Port = port ,
54+ Service = service ,
4855 } ;
4956
5057 using var host = CreateHost ( serverOptions ) ;
@@ -60,7 +67,7 @@ private IHost CreateHost(ServiceStartOptions serverOptions)
6067 {
6168 var builder = WebApplication . CreateBuilder ( [ ] ) ;
6269 Program . ConfigureServices ( builder . Services ) ;
63- ConfigureMcpServer ( builder . Services , serverOptions . Transport ) ;
70+ ConfigureMcpServer ( builder . Services , serverOptions ) ;
6471
6572 builder . WebHost
6673 . ConfigureKestrel ( server => server . ListenAnyIP ( serverOptions . Port ) )
@@ -86,13 +93,13 @@ private IHost CreateHost(ServiceStartOptions serverOptions)
8693 . ConfigureServices ( services =>
8794 {
8895 Program . ConfigureServices ( services ) ;
89- ConfigureMcpServer ( services , serverOptions . Transport ) ;
96+ ConfigureMcpServer ( services , serverOptions ) ;
9097 } )
9198 . Build ( ) ;
9299 }
93100 }
94101
95- private static void ConfigureMcpServer ( IServiceCollection services , string transport )
102+ private static void ConfigureMcpServer ( IServiceCollection services , ServiceStartOptions options )
96103 {
97104 services . AddSingleton < ToolOperations > ( ) ;
98105 services . AddSingleton < AzureEventSourceLogForwarder > ( ) ;
@@ -111,18 +118,18 @@ private static void ConfigureMcpServer(IServiceCollection services, string trans
111118 Version = assemblyName ? . Version ? . ToString ( ) ?? "1.0.0-beta"
112119 } ;
113120
121+ toolOperations . CommandGroup = options . Service ;
114122 mcpServerOptions . Capabilities = new ServerCapabilities
115123 {
116124 Tools = toolOperations . ToolsCapability
117125 } ;
118126
119127 mcpServerOptions . ProtocolVersion = "2024-11-05" ;
120-
121128 } ) ;
122129
123130 var mcpServerBuilder = services . AddMcpServer ( ) ;
124131
125- if ( transport != TransportTypes . Sse )
132+ if ( options . Transport != TransportTypes . Sse )
126133 {
127134 mcpServerBuilder . WithStdioServerTransport ( ) ;
128135 }
0 commit comments