Resource subscribe should be true if handler provided (#676)

Co-authored-by: Stephen Halter <halter73@gmail.com>
Co-authored-by: Mike Kistler <mikekistler@microsoft.com>
This commit is contained in:
Peder Holdgaard Pedersen 2025-12-12 05:41:43 +01:00 • committed by GitHub
commit 9bbae84c9b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -108,7 +108,7 @@ public class McpServerOptionsSetupTests
}
[Fact]
public void Configure_WithSubscribeToResourcesHandler_WithoutOtherResourcesHandler_DoesNotCreateResourcesCapability()
public void Configure_WithSubscribeToResourcesHandler_WithoutOtherResourcesHandler_DoesCreateResourcesCapability()
{
var services = new ServiceCollection();
services.AddMcpServer()
@ -116,12 +116,13 @@ public class McpServerOptionsSetupTests
var options = services.BuildServiceProvider().GetRequiredService<IOptions<McpServerOptions>>().Value;
Assert.Null(options.Handlers.SubscribeToResourcesHandler);
Assert.Null(options.Capabilities?.Resources);
Assert.NotNull(options.Handlers.SubscribeToResourcesHandler);
Assert.NotNull(options.Capabilities?.Resources);
Assert.True(options.Capabilities.Resources.Subscribe);
}
[Fact]
public void Configure_WithUnsubscribeFromResourcesHandler_WithoutOtherResourcesHandler_DoesNotCreateResourcesCapability()
public void Configure_WithUnsubscribeFromResourcesHandler_WithoutOtherResourcesHandler_DoesCreateResourcesCapability()
{
var services = new ServiceCollection();
services.AddMcpServer()
@ -129,8 +130,9 @@ public class McpServerOptionsSetupTests
var options = services.BuildServiceProvider().GetRequiredService<IOptions<McpServerOptions>>().Value;
Assert.Null(options.Handlers.UnsubscribeFromResourcesHandler);
Assert.Null(options.Capabilities?.Resources);
Assert.NotNull(options.Handlers.UnsubscribeFromResourcesHandler);
Assert.NotNull(options.Capabilities?.Resources);
Assert.True(options.Capabilities.Resources.Subscribe);
}
[Fact]