mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-01-30 14:32:04 +00:00
Fixes critical bug where session restoration successfully restored InstanceContext but failed to reconnect the transport layer, causing all requests on restored sessions to hang indefinitely. Root Cause: The handleRequest() method's session restoration flow (lines 1119-1197) called createSession() which creates a NEW transport separate from the current HTTP request. This separate transport is not linked to the current req/res pair, so responses cannot be sent back through the active HTTP connection. Fix Applied: Replace createSession() call with inline transport creation that mirrors the initialize flow. Create StreamableHTTPServerTransport directly for the current HTTP req/res context and ensure transport is connected to server BEFORE handling request. This makes restored sessions work identically to fresh sessions. Impact: - Zero-downtime deployments now work correctly - Users can continue work after container restart without restarting MCP client - Session persistence is now fully functional for production use Technical Details: The StreamableHTTPServerTransport class from MCP SDK links a specific HTTP req/res pair to the MCP server. Creating transport in createSession() binds it to the wrong req/res (or no req/res at all). The initialize flow got this right, but restoration flow did not. Files Changed: - src/http-server-single-session.ts: Fixed session restoration (lines 1163-1244) - package.json, package.runtime.json, src/mcp-engine.ts: Version bump to 2.19.3 - CHANGELOG.md: Documented fix with technical details Testing: All 13 session persistence integration tests pass, verifying restoration works correctly. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>