Skip to content

Cannot connect to SSE/StreamableHttp remote MCP server from Docker container #87

Open
@akolotov

Description

@akolotov

Could be related to #60

Initially tried to use this "one-liner"

docker run --rm -i -p 9696:9696 \
  node:20-alpine \
  npx -y mcp-remote https://mcp.higress.ai/mcp-time/{api-key} 9696 --host 0.0.0.0

where api-key can be received on https://mcp.higress.ai/server/server9031

It fails with the error:

[18] Debug mode enabled - detailed logs will be written to ~/.mcp-auth/
[18] Using callback hostname: 0.0.0.0
[2025-05-21T02:15:54.191Z][18] Starting mcp-remote with server URL: https://mcp.higress.ai/mcp-time/{api-key}
[18] Using specified callback port: 9696
[2025-05-21T02:15:54.192Z][18] Using specified callback port: 9696
[18] [18] Connecting to remote server: https://mcp.higress.ai/mcp-time/{api-key}
[2025-05-21T02:15:54.193Z][18] [18] Connecting to remote server: https://mcp.higress.ai/mcp-time/{api-key}
[18] Using transport strategy: http-first
[2025-05-21T02:15:54.193Z][18] Using transport strategy: http-first
[2025-05-21T02:15:54.193Z][18] Attempting to connect to remote server { sseTransport: false }
[2025-05-21T02:15:54.194Z][18] Starting transport directly
[2025-05-21T02:15:54.194Z][18] Creating test transport for HTTP-only connection test
[2025-05-21T02:15:54.195Z][18] Reading OAuth tokens
[2025-05-21T02:15:54.195Z][18] Token request stack trace: Error
    at NodeOAuthClientProvider.tokens (file:///root/.npm/_npx/705d23756ff7dacc/node_modules/mcp-remote/dist/chunk-ZLWDMQIP.js:7275:72)
    at async StreamableHTTPClientTransport._commonHeaders (file:///root/.npm/_npx/705d23756ff7dacc/node_modules/mcp-remote/dist/chunk-ZLWDMQIP.js:6377:22)
    at async StreamableHTTPClientTransport.send (file:///root/.npm/_npx/705d23756ff7dacc/node_modules/mcp-remote/dist/chunk-ZLWDMQIP.js:6534:23)
[2025-05-21T02:15:54.196Z][18] Token result: Not found
[18] Connection error: TypeError: fetch failed
    at node:internal/deps/undici/undici:13510:13
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async StreamableHTTPClientTransport.send (file:///root/.npm/_npx/705d23756ff7dacc/node_modules/mcp-remote/dist/chunk-ZLWDMQIP.js:6544:24) {
  [cause]: AggregateError [ETIMEDOUT]: 
      at internalConnectMultiple (node:net:1122:18)
      at internalConnectMultiple (node:net:1190:5)
      at Timeout.internalConnectMultipleTimeout (node:net:1716:5)
      at listOnTimeout (node:internal/timers:583:11)
      at process.processTimers (node:internal/timers:519:7) {
    code: 'ETIMEDOUT',
    [errors]: [ [Error], [Error], [Error], [Error] ]
  }
}

Then I tried with

docker run --rm -i -p 9696:9696 \
  node:20-alpine \
  npx -y mcp-remote https://mcp.higress.ai/mcp-time/{api-key}/sse 9696 --transport sse-only --host 0.0.0.0

and it fails with the error:

[18] Debug mode enabled - detailed logs will be written to ~/.mcp-auth/
[18] Using transport strategy: sse-only
[18] Using callback hostname: 0.0.0.0
[2025-05-21T02:17:36.314Z][18] Starting mcp-remote with server URL: https://mcp.higress.ai/mcp-time/{api-key}/sse
[18] Using specified callback port: 9696
[2025-05-21T02:17:36.316Z][18] Using specified callback port: 9696
[18] [18] Connecting to remote server: https://mcp.higress.ai/mcp-time/{api-key}/sse
[2025-05-21T02:17:36.316Z][18] [18] Connecting to remote server: https://mcp.higress.ai/mcp-time/{api-key}/sse
[18] Using transport strategy: sse-only
[2025-05-21T02:17:36.317Z][18] Using transport strategy: sse-only
[2025-05-21T02:17:36.317Z][18] Attempting to connect to remote server { sseTransport: true }
[2025-05-21T02:17:36.318Z][18] Starting transport directly
[2025-05-21T02:17:36.318Z][18] Reading OAuth tokens
[2025-05-21T02:17:36.319Z][18] Token request stack trace: Error
    at NodeOAuthClientProvider.tokens (file:///root/.npm/_npx/705d23756ff7dacc/node_modules/mcp-remote/dist/chunk-ZLWDMQIP.js:7275:72)
[2025-05-21T02:17:36.319Z][18] Token result: Not found
[18] Connection error: SseError: SSE error: TypeError: fetch failed: connect ETIMEDOUT 47.86.23.112:443, connect ENETUNREACH 240b:4001:275:5101:f51b:3d66:8ba2:d831:443 - Local (:::0), connect ETIMEDOUT 47.83.161.179:443, connect ENETUNREACH 240b:4001:275:5100:4d3d:e21a:9fe7:633d:443 - Local (:::0)
    at _eventSource.onerror (file:///root/.npm/_npx/705d23756ff7dacc/node_modules/mcp-remote/dist/chunk-ZLWDMQIP.js:6215:23)
    at EventSource.scheduleReconnect_fn (file:///root/.npm/_npx/705d23756ff7dacc/node_modules/mcp-remote/dist/chunk-ZLWDMQIP.js:6132:53)
    at file:///root/.npm/_npx/705d23756ff7dacc/node_modules/mcp-remote/dist/chunk-ZLWDMQIP.js:5982:174
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: undefined,
  event: {
    type: 'error',
    message: 'TypeError: fetch failed: connect ETIMEDOUT 47.86.23.112:443, connect ENETUNREACH 240b:4001:275:5101:f51b:3d66:8ba2:d831:443 - Local (:::0), connect ETIMEDOUT 47.83.161.179:443, connect ENETUNREACH 240b:4001:275:5100:4d3d:e21a:9fe7:633d:443 - Local (:::0)',
    code: undefined,
    defaultPrevented: false,
    cancelable: false,
    timeStamp: 736.611167
  }
}

At the same time the same approach works good to get the list of tools from the remote server by using curl:

$ docker run --rm -it \
  node:20-alpine \
  sh -c "apk add curl && curl -X POST https://mcp.higress.ai/mcp-time/{api-key} -H \"Content-Type: application/json\" -d '{\"method\": \"tools/list\"}'"

{"jsonrpc": "2.0","id":0,"result":{"nextCursor":"","tools":[{"description":"Because your understanding of dates comes from training data and you do not have an internal clock, you must use this tool to get the current time (including the day of the week) when you need date/time information to complete other instructions.\n","inputSchema":{"properties":{"timeZone":{"default":"Asia/Shanghai","description":"IANA timezone name (e.g., 'America/New_York', 'Europe/London'),One can try to locate the user's position through IP, thereby obtaining the timezone.\n","type":"string"}},"type":"object"},"name":"get-current-time"}]}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions