Fix stateless HTTP transport advertising listChanged capability (#1509)

This commit is contained in:
Jayaraman Venkatesan 2026-04-09 17:30:12 -04:00 • committed by GitHub
commit 07435dcb16
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -98,6 +98,18 @@ internal sealed partial class McpServerImpl : McpServer
_notificationHandlers.RegisterRange(notificationHandlers);
}
// In stateless mode, the server cannot send unsolicited notifications,
// so listChanged should not be advertised.
if (transport is StreamableHttpServerTransport { Stateless: true })
{
if (ServerCapabilities.Tools is not null)
ServerCapabilities.Tools.ListChanged = null;
if (ServerCapabilities.Prompts is not null)
ServerCapabilities.Prompts.ListChanged = null;
if (ServerCapabilities.Resources is not null)
ServerCapabilities.Resources.ListChanged = null;
}
// Now that everything has been configured, subscribe to any necessary notifications.
if (transport is not StreamableHttpServerTransport streamableHttpTransport || streamableHttpTransport.Stateless is false)
{