mcp-remote: how to fix ConnectTimeoutError (undici 10000ms timeout)?
Running mcp-remote 0.1.15 on Windows 11 with
npx mcp-remote https://.../mcp -ysometimes fails withTypeError: fetch failedcaused byConnectTimeoutError(codeUND_ERR_CONNECT_TIMEOUT, timeout 10000ms). Is there a CLI option to configure undici's fetch timeouts, or another workaround?Originally asked on GitHub: https://github.com/punkpeye/mcp-remote/issues/107
3 answers
Fixed in mcp-remote 0.3.0 according to the release bot; the exact change is not described in the thread. On 0.1.15, no CLI timeout option is shown in the thread, but one user worked around undici timeout problems by patching undici's global dispatcher.
Create
/app/heartbeat-patch.mjs:jsimport { setGlobalDispatcher, Agent } from 'undici'; setGlobalDispatcher(new Agent({ bodyTimeout: 0 }));Then run mcp-remote through the SSE server config with an up-to-date undici:
json{ "mcpServers": { "...": { "command": "bash", "args": ["-c", "npm install --no-save undici@latest >/dev/null 2>&1 && NODE_OPTIONS=--import=/app/heartbeat-patch.mjs npx mcp-remote https://.../sse 3334 --transport sse-only"] } } }The commenter reported that this fixed SSE timeouts and the connection being terminated after 5 minutes of inactivity. This patch specifically targets undici's
bodyTimeout; the thread does not say whether it also fixes the TCPConnectTimeoutErrorfrom the original report.Did this work for you?What @WolframRavenwolf tried on GitHub (Worked)
The commenter installed
undici@latest, created/app/heartbeat-patch.mjsusingsetGlobalDispatcher(new Agent({ bodyTimeout: 0 })), and launched mcp-remote withNODE_OPTIONS=--import=/app/heartbeat-patch.mjs npx mcp-remote https://.../sse 3334 --transport sse-only. They reported this fixed SSE timeouts and the 5-minute idle disconnection.Source: https://github.com/punkpeye/mcp-remote/issues/107#issuecomment-3110043531 (opens external site)
Did this work for you?What a GitHub user tried on GitHub (Didn't work)
Ran
npx mcp-remote https://XXXX/mcp -ywith mcp-remote 0.1.15 on Windows 11; it failed withTypeError: fetch failedcaused byConnectTimeoutErrorwith a 10000ms timeout. The reporter also stated that they did not find any way to configure undici's global timeouts in that version.Source: https://github.com/punkpeye/mcp-remote/issues/107 (opens external site)
Did this work for you?