Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

MCP session disposal throws ObjectDisposedException by accessing an expired HttpContext

Offen
#249 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 2 Tagen

@mkrueger arbeitet bereits daran.

Seit 13.10.2026.

  • #250 von @mkrueger — offen

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
35/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Veraltet
Tech-Stack
csharp
Bereich
backend, cli

Rechercherichtung

Start with McpServer.cs around line 129 and trace RunSessionHandler through its finally block. Review the existing EndedSession_RemovesLocationSubscription test and add regression coverage for disposal after the initialization request ends. Done means teardown releases subscriptions and applicable legacy admission state without throwing an ObjectDisposedException; pull request #250 is already open against this issue.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Description

Observed with Cosmos DB Shell 1.1.280-preview on macOS through a VS Code MCP client. The account connection succeeded; session cleanup subsequently logged:

Error disposing session.
System.ObjectDisposedException: IFeatureCollection has been disposed.
Object name: 'Collection'.
   at Microsoft.AspNetCore.Http.DefaultHttpRequest.get_Path()
   at Azure.Data.Cosmos.Shell.Mcp.McpServer...
      ConfigureHttpTransport... in McpServer.cs:line 137
   at ModelContextProtocol.AspNetCore.StreamableHttpSession.DisposeAsync()
   at ModelContextProtocol.AspNetCore.StatefulSessionManager.DisposeSessionAsync(...)

The unsafe access remains in McpServer.cs on main. The updated local main and origin/main both pointed to 6875685c6a2670ffcf85cdecff13420eea3a0a9b when checked.

Cause

RunSessionHandler awaits RunSessionAsync, then its finally block accesses httpContext.Request.Path and potentially httpContext.RequestServices. The originating HTTP request can already be disposed when the longer-lived MCP session ends.

This also affects non-legacy stateful sessions: evaluating the "/sse" condition itself dereferences the disposed context.

Expected Behavior

Session teardown completes without accessing expired request state, while releasing subscriptions and applicable legacy admission state.

Suggested Fix

Capture the legacy-transport decision and required singleton services before awaiting the session. Use only those captured values during cleanup.

Regression Coverage

Exercise session disposal after the initialization HTTP request has ended. Assert both successful cleanup and absence of disposal exceptions.

The existing EndedSession_RemovesLocationSubscription test checks subscription removal, but that cleanup occurs before the failing outer finally; it therefore does not establish error-free teardown.

Scope

The observed failure is in session cleanup. It does not establish that preceding tool calls failed or that unrelated Azure deployment operations were affected.

Vorherrschende Sprache
C#
Sterne
4
Forks
7
Ø Merge
1 T. 20 Std.
Gemergte PRs (30 T.)
28

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus Azure/CosmosDBShell

Alle Issues in Azure/CosmosDBShell

Ähnliche Issues

Weitere Issues zu C#

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.