Make "Stateless" mode sessionless (#760)

- This removes the requirement to configure data protection which is the motivating reason for this change
- This means that McpServer.ClientInfo will always be null in stateless mode
This commit is contained in:
Stephen Halter 2025-10-02 15:57:01 -07:00 • committed by GitHub
commit 47b9582fd7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -416,7 +416,7 @@ public abstract partial class McpServer : McpSession, IMcpServer
{
if (ClientCapabilities?.Sampling is null)
{
if (ServerOptions.KnownClientInfo is not null)
if (ClientCapabilities is null)
{
throw new InvalidOperationException("Sampling is not supported in stateless mode.");
}
@ -429,7 +429,7 @@ public abstract partial class McpServer : McpSession, IMcpServer
{
if (ClientCapabilities?.Roots is null)
{
if (ServerOptions.KnownClientInfo is not null)
if (ClientCapabilities is null)
{
throw new InvalidOperationException("Roots are not supported in stateless mode.");
}
@ -442,7 +442,7 @@ public abstract partial class McpServer : McpSession, IMcpServer
{
if (ClientCapabilities?.Elicitation is null)
{
if (ServerOptions.KnownClientInfo is not null)
if (ClientCapabilities is null)
{
throw new InvalidOperationException("Elicitation is not supported in stateless mode.");
}