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.

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.