1st sse mcp connection ALWAYS fails on windows (reconnect always works)

At program start:-


What I did:-
pic_2025-04-23_09.27.58_172

What the logs say:

2025-04-23 09:26:45.269 [info] >>>>> MCP Startup
2025-04-23 09:26:45.270 [info] _sse: Handling CreateClient action
2025-04-23 09:26:45.270 [info] _sse: Creating SSE transport
2025-04-23 09:26:55.845 [error] _sse: Client error for command fetch failed
2025-04-23 09:26:55.845 [error] _sse: Error in MCP: fetch failed
2025-04-23 09:26:55.848 [info] _sse: Client closed for command
2025-04-23 09:26:55.848 [error] _sse: Error in MCP: Client closed
2025-04-23 09:26:55.863 [info] _sse: Handling ListOfferings action
2025-04-23 09:26:55.864 [error] _sse: No server info found
2025-04-23 09:28:19.682 [info] _sse: Handling ReloadClient action
2025-04-23 09:28:19.683 [info] _sse: Creating SSE transport
2025-04-23 09:28:19.780 [info] _sse: Successfully connected to sse server
2025-04-23 09:28:19.780 [info] _sse: Storing SSE client
2025-04-23 09:28:19.781 [info] _sse: Successfully reloaded client
2025-04-23 09:28:19.784 [info] _sse: Handling ListOfferings action
2025-04-23 09:28:19.785 [info] _sse: Listing offerings
2025-04-23 09:28:19.786 [info] _sse: Connected to sse server, fetching offerings
2025-04-23 09:28:19.828 [info] listOfferings: Found 12 tools
2025-04-23 09:28:19.828 [info] _sse: Found 12 tools, 0 resources, and 0 resource templates

What the sse server logs say:

2025-04-23 09:26:13.200 [PID:11008|TID:5284] Server started HTTPS on 127-0-0-1.local.example.com:9443 (127.0.0.1)
2025-04-23 09:26:13.200 [PID:11008|TID:5284] Server Press any key to stop the server...
2025-04-23 09:26:45.302 [PID:11008|TID:5284] Connect from ('127.0.0.1', 51179)
2025-04-23 09:26:45.305 [PID:11008|TID:2204] Request from ('127.0.0.1', 51179) < Method: GET Path: /sse\nHeaders: {'host': '127-0-0-1.local.example.com:9443', 'connection': 'keep-alive', 'accept': 'text/event-stream', 'accept-language': '*', 'sec-fetch-mode': 'cors', 'user-agent': 'node', 'pragma': 'no-cache', 'cache-control': 'no-cache', 'accept-encoding': 'br, gzip, deflate'}\nBody length: 0\nBody: b''
2025-04-23 09:26:45.308 [PID:11008|TID:2204] New SSE connection from ('127.0.0.1', 51179), session_id=bdcbaa1e60e14f6a8de07eadbd7b2127
2025-04-23 09:26:45.309 [PID:11008|TID:2204] Response  to ('127.0.0.1', 51179) > b'HTTP/1.1 200 OK\r\nContent-Type: text/event-stream; charset=utf-8\r\nConnection: keep-alive\r\nCache-Control: no-store\r\nX-Accel-Buffering: no\r\n\r\nevent: endpoint\r\ndata: /messages/?session_id=bdcbaa1e60e14f6a8de07eadbd7b2127\r\n\r\n'
2025-04-23 09:26:56.458 [PID:11008|TID:5284] Connect from ('127.0.0.1', 51206)
2025-04-23 09:27:00.337 [PID:11008|TID:2204] SSE Message to ('127.0.0.1', 51179) > : ping - 2025-04-23T09:27:00.337513+00:00\r\n\r\n
2025-04-23 09:27:15.359 [PID:11008|TID:2204] Error Failed to send SSE message to ('127.0.0.1', 51179): EOF occurred in violation of protocol (_ssl.c:2406)
2025-04-23 09:27:15.359 [PID:11008|TID:2204] Session Cleaning up session bdcbaa1e60e14f6a8de07eadbd7b2127
2025-04-23 09:28:19.709 [PID:11008|TID:5284] Connect from ('127.0.0.1', 51214)
2025-04-23 09:28:19.711 [PID:11008|TID:7136] Request from ('127.0.0.1', 51214) < Method: GET Path: /sse\nHeaders: {'host': '127-0-0-1.local.example.com:9443', 'connection': 'keep-alive', 'accept': 'text/event-stream', 'accept-language': '*', 'sec-fetch-mode': 'cors', 'user-agent': 'node', 'pragma': 'no-cache', 'cache-control': 'no-cache', 'accept-encoding': 'br, gzip, deflate'}\nBody length: 0\nBody: b''
2025-04-23 09:28:19.713 [PID:11008|TID:7136] New SSE connection from ('127.0.0.1', 51214), session_id=1ab442045dbe45e4b458ac829d58d96b
2025-04-23 09:28:19.714 [PID:11008|TID:7136] Response  to ('127.0.0.1', 51214) > b'HTTP/1.1 200 OK\r\nContent-Type: text/event-stream; charset=utf-8\r\nConnection: keep-alive\r\nCache-Control: no-store\r\nX-Accel-Buffering: no\r\n\r\nevent: endpoint\r\ndata: /messages/?session_id=1ab442045dbe45e4b458ac829d58d96b\r\n\r\n'
2025-04-23 09:28:19.737 [PID:11008|TID:5284] Connect from ('127.0.0.1', 51215)
2025-04-23 09:28:19.739 [PID:11008|TID:9272] Request from ('127.0.0.1', 51215) < Method: POST Path: /messages/?session_id=1ab442045dbe45e4b458ac829d58d96b\nHeaders: {'host': '127-0-0-1.local.example.com:9443', 'connection': 'keep-alive', 'content-type': 'application/json', 'accept': '*/*', 'accept-language': '*', 'sec-fetch-mode': 'cors', 'user-agent': 'node', 'accept-encoding': 'br, gzip, deflate', 'content-length': '253'}\nBody length: 253\nBody: b'{"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{"tools":true,"prompts":false,"resources":true,"logging":false,"roots":{"listChanged":false}},"clientInfo":{"name":"cursor-vscode","version":"1.0.0"}},"jsonrpc":"2.0","id":0}'
2025-04-23 09:28:19.740 [PID:11008|TID:9272] JSONRPC Request session=1ab442045dbe45e4b458ac829d58d96b, method=initialize, id=0
2025-04-23 09:28:19.741 [PID:11008|TID:9272] SSE Message to ('127.0.0.1', 51214) > data: {"jsonrpc": "2.0", "id": 0, "result": {"protocolVersion": "2024-11-05", "capabilities": {"experimental": {}, "prompts": {"listChanged": false}, "resources": {"subscribe": false, "listChanged": false}, "tools": {"listChanged": false}}, "serverInfo": {"name": "ragtag-memory-system", "version": "1.0.0-alpha.5", "workspace_contained": false}}}\r\n\r\n
2025-04-23 09:28:19.742 [PID:11008|TID:9272] Response  to ('127.0.0.1', 51215) > b'HTTP/1.1 202 Accepted\r\nContent-Type: text/plain\r\nContent-Length: 0\r\nConnection: close\r\n\r\n'
2025-04-23 09:28:19.772 [PID:11008|TID:5284] Connect from ('127.0.0.1', 51216)
2025-04-23 09:28:19.775 [PID:11008|TID:7152] Request from ('127.0.0.1', 51216) < Method: POST Path: /messages/?session_id=1ab442045dbe45e4b458ac829d58d96b\nHeaders: {'host': '127-0-0-1.local.example.com:9443', 'connection': 'keep-alive', 'content-type': 'application/json', 'accept': '*/*', 'accept-language': '*', 'sec-fetch-mode': 'cors', 'user-agent': 'node', 'accept-encoding': 'br, gzip, deflate', 'content-length': '54'}\nBody length: 54\nBody: b'{"method":"notifications/initialized","jsonrpc":"2.0"}'
2025-04-23 09:28:19.776 [PID:11008|TID:7152] JSONRPC Request session=1ab442045dbe45e4b458ac829d58d96b, method=notifications/initialized, id=None
2025-04-23 09:28:19.777 [PID:11008|TID:7152] Response  to ('127.0.0.1', 51216) > b'HTTP/1.1 202 Accepted\r\nContent-Type: text/plain\r\nContent-Length: 0\r\nConnection: close\r\n\r\n'
2025-04-23 09:28:19.813 [PID:11008|TID:5284] Connect from ('127.0.0.1', 51217)
2025-04-23 09:28:19.814 [PID:11008|TID:2168] Request from ('127.0.0.1', 51217) < Method: POST Path: /messages/?session_id=1ab442045dbe45e4b458ac829d58d96b\nHeaders: {'host': '127-0-0-1.local.example.com:9443', 'connection': 'keep-alive', 'content-type': 'application/json', 'accept': '*/*', 'accept-language': '*', 'sec-fetch-mode': 'cors', 'user-agent': 'node', 'accept-encoding': 'br, gzip, deflate', 'content-length': '46'}\nBody length: 46\nBody: b'{"method":"tools/list","jsonrpc":"2.0","id":1}'
2025-04-23 09:28:19.816 [PID:11008|TID:2168] JSONRPC Request session=1ab442045dbe45e4b458ac829d58d96b, method=tools/list, id=1
2025-04-23 09:28:19.818 [PID:11008|TID:2168] SSE Message to ('127.0.0.1', 51214) > data: {"jsonrpc": "2.0", "id": 1, "result": {"tools": [{"name": "cards", "description": "A shuffled deck of cards. \nUse this when you need to determine participant ordering, play games, or have other use-cases that can be solved by drawing and comparing cards at random.\n...[ HUGE OUTPUT SNIPPED ]..."title": "Data", "type": "string"}}, "required": ["data"], "title": "whereami_arguments", "type": "object"}}]}}\r\n\r\n
2025-04-23 09:28:19.821 [PID:11008|TID:2168] Response  to ('127.0.0.1', 51217) > b'HTTP/1.1 202 Accepted\r\nContent-Type: text/plain\r\nContent-Length: 0\r\nConnection: close\r\n\r\n'
2025-04-23 09:28:34.729 [PID:11008|TID:7136] SSE Message to ('127.0.0.1', 51214) > : ping - 2025-04-23T09:28:34.729314+00:00\r\n\r\n
2025-04-23 09:28:49.729 [PID:11008|TID:7136] SSE Message to ('127.0.0.1', 51214) > : ping - 2025-04-23T09:28:49.729501+00:00\r\n\r\n

Note the precise times - there’s a delay “at startup” (where there should be none) which is the clue to the location of this bug in your code.

Version: 0.49.4 (user setup)
VSCode Version: 1.96.2
Commit: ec408037b24566b11e6132c58bbe6ad27046eb90
Date: 2025-04-22T00:23:40.780Z
Electron: 34.3.4
Chromium: 132.0.6834.210
Node.js: 20.18.3
V8: 13.2.152.41-electron.0
OS: Windows_NT x64 10.0.26100

p.s.

Edition Windows 11 Pro
Version 24H2
Installed on ‎20/‎02/‎2025
OS build 26100.3775
Experience Windows Feature Experience Pack 1000.26100.66.0