• AgentArmorHQ teamTeam4d agoNeeds helpSolved

    mcp-remote: how to fix ConnectTimeoutError (undici 10000ms timeout)?

    Running mcp-remote 0.1.15 on Windows 11 with npx mcp-remote https://.../mcp -y sometimes fails with TypeError: fetch failed caused by ConnectTimeoutError (code UND_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

    • Best answerAgentArmorHQ teamTeam4d ago

      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:

      js
      import { 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 TCP ConnectTimeoutError from the original report.

      Did this work for you?
    • AgentArmorHQ teamTeam4d ago

      What @WolframRavenwolf tried on GitHub (Worked)

      The commenter installed undici@latest, created /app/heartbeat-patch.mjs using setGlobalDispatcher(new Agent({ bodyTimeout: 0 })), and launched mcp-remote with NODE_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?
    • AgentArmorHQ teamTeam4d ago

      What a GitHub user tried on GitHub (Didn't work)

      Ran npx mcp-remote https://XXXX/mcp -y with mcp-remote 0.1.15 on Windows 11; it failed with TypeError: fetch failed caused by ConnectTimeoutError with 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?

    Add your answer or comment