Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

MCP session disposal throws ObjectDisposedException by accessing an expired HttpContext

Abierto
#249 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

@mkrueger ya está trabajando en esto.

Desde el 13/10/2026.

  • #250 de @mkrueger — abierto

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
csharp
Área
backend, cli

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
C#
Estrellas
4
Forks
7
Merge medio
2 d 13 min
PR fusionados (30 d)
30

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Azure/CosmosDBShell

Todos los issues de Azure/CosmosDBShell

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.