Error: MCP server unreachable at…
- User
Error: MCP server unreachable at http://host.docker.internal:8000/mcp/sse?session_id=70bae0a9-f414-4502-b561-6413ea5304ab: fetch failed. Check that PROXY_BASE_URL is
reachable from inside the container. Assistant
Using systematic-debugging to investigate the MCP server connectivity issue.
Let me start with Phase 1: Root Cause Investigation by reading the error carefully and examining the relevant configuration.
Error:
MCP server unreachable at http://host.docker.internal:8000/mcp/sse?session_id=... : fetch failed. Check that PROXY_BASE_URL is reachable from inside the container.This tells us: a container (likely the sidecar) is trying to reach the backend at
host.docker.internal:8000but the connection fails.Let me gather evidence across the system components.
Assistant
I notice the
.envhas sensitive API keys exposed. Let me focus on the connectivity issue. Let me check the sidecar code and how the backend runs.Assistant
Let me check how the backend is started and what port it uses.
Assistant
Let me verify the connection from the sidecar to confirm my hypothesis.
Assistant
Root cause found. Phase 1 complete.
Root Cause
The backend (uvicorn) is bound to
127.0.0.1:8000(localhost only). The sidecar container resolveshost.docker.internalto192.168.107.1(the Docker gateway IP), but since the backend only listens on localhost, the connection is refused.The Makefile runs:
codecd backend && poetry run uvicorn app.main:app --reload --port 8000Uvicorn defaults to binding
127.0.0.1, which rejects connections from any non-localhost interface — including Docker'shost.docker.internal.Fix
Add
--host 0.0.0.0to the uvicorn command so it accepts connections from Docker containers:Assistant
You need to restart the backend with
make backend(ormake dev) for the fix to take effect. The backend will now listen on all interfaces (0.0.0.0:8000) instead of just localhost, allowing the sidecar container to connect viahost.docker.internal:8000.- User
Sidecar reported error: MCP server unreachable at http://host.docker.internal:8000/mcp/sse?session_id=e2a76e64-8eda-40e5-aee4-ebe8b88436bf: fetch failed. Check that PROXY_BASE_URL is reachable from inside the container. Sidecar stream ended without result message; sending done event
Assistant
The same error persists. Let me check if the backend is now binding to
0.0.0.0after the Makefile change.Assistant
Good — the backend is now listening on
*:8000(all interfaces). Let me test connectivity from a running sidecar container.Assistant
Still failing despite the backend listening on all interfaces. Let me dig deeper into the network configuration.
Assistant
Found it. The issue is in
_resolve_network_hosts(). It mapshost.docker.internalto the bridge network gateway (192.168.107.1), which is inside the Docker VM — not the macOS host where uvicorn runs. Let me verify the runtime being used.Assistant
Root cause confirmed. The
_resolve_network_hosts()method mapshost.docker.internalto the bridge network gateway192.168.107.1, but Docker Desktop's actual host-forwarding IP is0.250.250.254. The bridge gateway is NOT the macOS host.The second test proves that
host-gatewaymagic value works correctly withrunc— the connection to port 8000 succeeded (got HTTP 404, but TCP connected). Since you're usingrunc(notrunsc/gVisor), thehost-gatewayapproach works fine and Docker's built-in DNS would also work without any override.Let me fix
_resolve_network_hosts()to not overridehost.docker.internalwith the wrong IP. Forrunc, Docker's DNS handles it correctly. Forrunsc, we need to resolve the actual host-gateway IP rather than using the bridge gateway.Assistant
Good. The real host-gateway IP is
0.250.250.254. Now I'll fix the_resolve_network_hosts()method to resolve the actual host-gateway IP instead of using the bridge network gateway.Assistant
Now update the fallback in
create()to always usehost-gateway, since Docker's built-in DNS and thehost-gatewaymagic value both resolve correctly forrunc:Assistant
Now restart the backend and test. The fix:
- Previous bug:
host.docker.internalwas mapped to the bridge network gateway IP (192.168.107.1), which is inside the Docker VM — not the macOS host where uvicorn runs. - Fix: Use Docker's
host-gatewaymagic value, which resolves to the actual host-forwarding IP (0.250.250.254).
Restart the backend with
make backendormake devand try again.- Previous bug:
- User
create new branch based on changes and push and raise pr
Assistant
- User
commit and push