Skip to content

Commit 94d5f18

Browse files
committed
Make McpSession field private
1 parent c6e9958 commit 94d5f18

2 files changed

Lines changed: 2 additions & 5 deletions

File tree

src/ModelContextProtocol/Server/McpServer.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ private McpServer(McpServerOptions options, ILoggerFactory? loggerFactory, IServ
7272

7373
_toolsChangedDelegate = delegate
7474
{
75-
_ = _session?.SendMessageAsync(new JsonRpcNotification()
75+
_ = SendMessageAsync(new JsonRpcNotification()
7676
{
7777
Method = NotificationMethods.ToolListChangedNotification,
7878
});
@@ -141,9 +141,6 @@ public async Task AcceptSessionAsync(CancellationToken cancellationToken = defau
141141
/// <inheritdoc />
142142
public async Task RunAsync(CancellationToken cancellationToken = default)
143143
{
144-
// Below is effectively an assertion. The McpServerFactory should not return before the _transport is initialized.
145-
Throw.IfNull(_session);
146-
147144
try
148145
{
149146
// Start processing messages

src/ModelContextProtocol/Shared/McpJsonRpcEndpoint.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ internal abstract class McpJsonRpcEndpoint : IAsyncDisposable
1919
private readonly RequestHandlers _requestHandlers = [];
2020
private readonly NotificationHandlers _notificationHandlers = [];
2121

22+
private McpSession? _session;
2223
private CancellationTokenSource? _sessionCts;
2324
private int _started;
2425
private int _disposed;
2526

2627
protected readonly ILogger _logger;
27-
protected McpSession? _session;
2828

2929
/// <summary>
3030
/// Initializes a new instance of the <see cref="McpJsonRpcEndpoint"/> class.

0 commit comments

Comments
 (0)