Table of Contents

Interface ISseEventStreamReader

Namespace
ModelContextProtocol.Server
Assembly
ModelContextProtocol.Core.dll

Provides read access to an SSE event stream, allowing events to be consumed asynchronously.

[Obsolete("Stateful Streamable HTTP mode is a back-compat-only escape hatch for legacy clients. Set HttpServerTransportOptions.Stateless = true (the default as of the 2026-07-28 protocol revision) for new code. See SEP-2567.", DiagnosticId = "MCP9006", UrlFormat = "https://github.com/modelcontextprotocol/csharp-sdk/blob/main/docs/list-of-diagnostics.md#obsolete-apis")]
public interface ISseEventStreamReader

Properties

SessionId

Gets the session ID associated with the stream being read.

string SessionId { get; }

Property Value

string

StreamId

Gets the ID of the stream.

string StreamId { get; }

Property Value

string

Remarks

This value is guaranteed to be unique on a per-session basis.

Methods

ReadEventsAsync(CancellationToken)

Gets the messages from the stream as an IAsyncEnumerable<T>.

IAsyncEnumerable<SseItem<JsonRpcMessage?>> ReadEventsAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token to cancel the operation.

Returns

IAsyncEnumerable<SseItem<JsonRpcMessage>>

An IAsyncEnumerable<T> of System.Net.ServerSentEvents.SseItem<T> containing JSON-RPC messages.

Remarks

If the stream's mode is set to Polling, the returned messages will only include the currently-available events starting at the last event ID specified when the reader was created. Otherwise, the returned messages will continue until the associated ISseEventStreamWriter is disposed.