@@ -395,6 +395,54 @@ public void Register_Tools_From_Current_Assembly()
395
395
Assert . Contains ( services . GetServices < McpServerTool > ( ) , t => t . ProtocolTool . Name == "Echo" ) ;
396
396
}
397
397
398
+ [ Theory ]
399
+ [ InlineData ( false ) ]
400
+ [ InlineData ( true ) ]
401
+ public void WithTools_Parameters_Satisfiable_From_DI ( bool parameterInServices )
402
+ {
403
+ ServiceCollection sc = new ( ) ;
404
+ if ( parameterInServices )
405
+ {
406
+ sc . AddSingleton ( new ComplexObject ( ) ) ;
407
+ }
408
+ sc . AddMcpServer ( ) . WithTools ( typeof ( EchoTool ) ) ;
409
+ IServiceProvider services = sc . BuildServiceProvider ( ) ;
410
+
411
+ McpServerTool tool = services . GetServices < McpServerTool > ( ) . First ( t => t . ProtocolTool . Name == "EchoComplex" ) ;
412
+ if ( parameterInServices )
413
+ {
414
+ Assert . DoesNotContain ( "\" complex\" " , JsonSerializer . Serialize ( tool . ProtocolTool . InputSchema ) ) ;
415
+ }
416
+ else
417
+ {
418
+ Assert . Contains ( "\" complex\" " , JsonSerializer . Serialize ( tool . ProtocolTool . InputSchema ) ) ;
419
+ }
420
+ }
421
+
422
+ [ Theory ]
423
+ [ InlineData ( false ) ]
424
+ [ InlineData ( true ) ]
425
+ public void WithToolsFromAssembly_Parameters_Satisfiable_From_DI ( bool parameterInServices )
426
+ {
427
+ ServiceCollection sc = new ( ) ;
428
+ if ( parameterInServices )
429
+ {
430
+ sc . AddSingleton ( new ComplexObject ( ) ) ;
431
+ }
432
+ sc . AddMcpServer ( ) . WithToolsFromAssembly ( ) ;
433
+ IServiceProvider services = sc . BuildServiceProvider ( ) ;
434
+
435
+ McpServerTool tool = services . GetServices < McpServerTool > ( ) . First ( t => t . ProtocolTool . Name == "EchoComplex" ) ;
436
+ if ( parameterInServices )
437
+ {
438
+ Assert . DoesNotContain ( "\" complex\" " , JsonSerializer . Serialize ( tool . ProtocolTool . InputSchema ) ) ;
439
+ }
440
+ else
441
+ {
442
+ Assert . Contains ( "\" complex\" " , JsonSerializer . Serialize ( tool . ProtocolTool . InputSchema ) ) ;
443
+ }
444
+ }
445
+
398
446
[ Fact ]
399
447
public async Task Recognizes_Parameter_Types ( )
400
448
{
0 commit comments