Skip to content

fix: avoid orphaned sessions from oauth discovery post probe#1050

Closed
DaleSeo wants to merge 1 commit into
mainfrom
fix/oauth-probe-session-cleanup
Closed

fix: avoid orphaned sessions from oauth discovery post probe#1050
DaleSeo wants to merge 1 commit into
mainfrom
fix/oauth-probe-session-cleanup

Conversation

@DaleSeo

@DaleSeo DaleSeo commented Jul 24, 2026

Copy link
Copy Markdown
Member

Fixes #1048.

Motivation and Context

When a GET request to the MCP endpoint returns a 404 or 405, which is expected for servers without SSE support, AuthorizationManager falls back to sending a synthetic JSON-RPC initialize request. This is meant to trigger a 401 response with a WWW-Authenticate header.

However, on servers where authorization is optional, or where initialize is available before authentication, the request is accepted. A session is created, and an Mcp-Session-Id is returned. The client then discards the session without sending a DELETE request, leaving one orphaned session after every discovery attempt.

This PR fixes the issue by sending an HTTP DELETE request for the session whenever a probe response includes an Mcp-Session-Id header. The client does this before processing the response. Any cleanup failures are logged at the debug level and never cause discovery to fail.

How Has This Been Tested?

Add tests

Breaking Changes

None

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

@github-actions github-actions Bot added T-core Core library changes T-transport Transport layer changes labels Jul 24, 2026
@DaleSeo
DaleSeo force-pushed the fix/oauth-probe-session-cleanup branch from e4cebf7 to 43af94c Compare July 24, 2026 21:17
@DaleSeo

DaleSeo commented Jul 24, 2026

Copy link
Copy Markdown
Member Author

Close this in favor of #1052

@DaleSeo DaleSeo closed this Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-core Core library changes T-transport Transport layer changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OAuth discovery initialize POST probe can create server sessions that are never DELETEd

1 participant