We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6449022 commit 0fe4cb4Copy full SHA for 0fe4cb4
1 file changed
src/ModelContextProtocol.AspNetCore/HttpMcpSession.cs
@@ -39,7 +39,11 @@ internal sealed class HttpMcpSession<TTransport>(
39
40
public IAsyncDisposable AcquireReference()
41
{
42
- Debug.Assert(_idleSessionSemaphore is not null, "Only StreamableHttpHandler should call AcquireReference.");
+ // We don't do idle tracking for stateless sessions, so we don't need to acquire a reference.
43
+ if (_idleSessionSemaphore is null)
44
+ {
45
+ return new NoopDisposable();
46
+ }
47
48
lock (_referenceCountLock)
49
@@ -131,4 +135,9 @@ public async ValueTask DisposeAsync()
131
135
}
132
136
133
137
138
+
139
+ private sealed class NoopDisposable : IAsyncDisposable
140
141
+ public ValueTask DisposeAsync() => ValueTask.CompletedTask;
142
134
143
0 commit comments