@@ -666,6 +666,11 @@ public async Task Tool_ReturningMcpTask_BypassesSdkTaskWrapping()
666666 // Arrange - Server with task store and a tool that creates and returns its own McpTask
667667 var taskStore = new InMemoryMcpTaskStore ( ) ;
668668
669+ // Build a service provider so the tool can resolve IMcpTaskStore at creation time
670+ var toolServices = new ServiceCollection ( ) ;
671+ toolServices . AddSingleton < IMcpTaskStore > ( taskStore ) ;
672+ var toolServiceProvider = toolServices . BuildServiceProvider ( ) ;
673+
669674 await using var fixture = new ClientServerFixture (
670675 LoggerFactory ,
671676 configureServer : builder =>
@@ -684,7 +689,8 @@ public async Task Tool_ReturningMcpTask_BypassesSdkTaskWrapping()
684689 {
685690 Name = "self-managing-tool" ,
686691 Description = "A tool that creates and returns its own McpTask" ,
687- Execution = new ToolExecution { TaskSupport = ToolTaskSupport . Optional }
692+ Execution = new ToolExecution { TaskSupport = ToolTaskSupport . Optional } ,
693+ Services = toolServiceProvider
688694 } ) ] ) ;
689695 } ,
690696 configureServices : services =>
@@ -716,6 +722,11 @@ public async Task Tool_ReturningMcpTask_WithoutTaskMetadata_ReturnsTaskDirectly(
716722 // Arrange - Server with task store and a tool that returns McpTask
717723 var taskStore = new InMemoryMcpTaskStore ( ) ;
718724
725+ // Build a service provider so the tool can resolve IMcpTaskStore at creation time
726+ var toolServices = new ServiceCollection ( ) ;
727+ toolServices . AddSingleton < IMcpTaskStore > ( taskStore ) ;
728+ var toolServiceProvider = toolServices . BuildServiceProvider ( ) ;
729+
719730 await using var fixture = new ClientServerFixture (
720731 LoggerFactory ,
721732 configureServer : builder =>
@@ -733,7 +744,8 @@ public async Task Tool_ReturningMcpTask_WithoutTaskMetadata_ReturnsTaskDirectly(
733744 {
734745 Name = "self-managing-tool" ,
735746 Description = "A tool that creates and returns its own McpTask" ,
736- Execution = new ToolExecution { TaskSupport = ToolTaskSupport . Optional }
747+ Execution = new ToolExecution { TaskSupport = ToolTaskSupport . Optional } ,
748+ Services = toolServiceProvider
737749 } ) ] ) ;
738750 } ,
739751 configureServices : services =>
0 commit comments