Files
reverse-engineering-anything/src/server/http
Adolaniumandmorluto 7b4d84a48e fix(mcp): refuse stale sessions and serialize initialize handovers (#13195)
* fix(mcp): refuse a stale session id without arming a transport

A request that already carries mcp-session-id went through the slot's
current session even when that id was not live. Initialize skips the
SDK session check, so the stale id opened a transport. A presented id
now gets 404 unless it is the live session, and it never arms one.

* fix(mcp): serialize initialize session handovers

Two sessionless initialize requests could both close the same live
session and then handle on the one transport that replaced it. The
second request was rejected because that server was already initialized.
Each initialize now waits until the previous handover has answered, then
replaces that session with its own.

* fix(mcp): reject an unmatched session id before joining a drain

A presented id that is not the live session waited on transport close.
A drain timeout, or a shutdown that won that wait, answered 503.
Compare the id first and return 404 without joining the drain.
A matching id still waits, then checks that the same id is live.

* test(mcp): read raced initialize results and always release session gates

The replacement race now requires a complete initialize result from each reply.
The stale-session test releases its connect gate, joins the arming request, and closes the slot when an assertion fails.

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-26 10:59:20 -05:00
..