Skip to content

refactor(env): reach pgweb and db-mcp only through the gateway's /svc routes - #823

Draft
andrewpark-scaleai wants to merge 4 commits into
mainfrom
andrewpark/gateway-only-console-ports
Draft

andrewpark-scaleai wants to merge 4 commits into
mainfrom
andrewpark/gateway-only-console-ports

Conversation

@andrewpark-scaleai

Copy link
Copy Markdown
Contributor

DO NOT MERGE until every consumer of db_web_url and db_mcp_url reads the gateway URLs from #821 instead.

Why

After #821, the gateway serves pgweb and db-mcp at /svc/. This PR makes that the only way in, so deploys expose one port (the gateway's) and records carry one set of console URLs.

What changed

  • The VM path asks the sandbox provider to expose only the gateway's port.
  • The compose file publishes no port for pgweb or db-mcp. Containers on env-network still reach them.
  • The container path creates the pgweb and db-mcp sandboxes with expose_externally=False, as it already does for other sidecars.
  • DeployedGateway drops db_web_url and db_mcp_url, so no deploy writes them. DeployedGatewayEnv still reads them from older records for one release.

Blast Radius

  • Any reader of db_web_url or db_mcp_url gets None on a new deploy's record. Every one must move to db_web_gateway_url / db_mcp_gateway_url first.
  • OpenClaw's environment card loses its "database" link on new envs. Its owner confirmed on 2026-11-19 that nobody uses it.
  • A deploy whose gateway image predates feat(gateway): serve pgweb and db-mcp at /svc/ routes #821 can't reach the consoles. Promote the gateway image first.
  • Envs that pin an older framework keep their old ports until they are rebuilt.

Verification

  • The VM deploy test asserts create_vm gets only the gateway and sidecar ports.
  • tst/unit/env/test_env.py loads a record from an older deploy.
  • Unit trees tst/unit/env, tst/unit/providers and tst/unit/cli pass. ruff check src tst passes.
  • Local Docker and a live modal_vm: the consoles answer through the gateway with the token.

Ubuntu and others added 4 commits November 19, 2026 18:34
The gateway serves the env's SQL consoles at /svc/pgweb/ and /svc/db-mcp/
from a new CONSOLE_URLS variable, behind the deployment's control token like
its other guarded routes. The deploy records db_web_gateway_url and
db_mcp_gateway_url once it has checked the gateway serves both, and keeps
db_web_url and db_mcp_url as they are. db-mcp binds every address family on
the container path. The CLI prints the gateway URLs, and a website can no
longer be named pgweb or db-mcp.
…etry the console probe

- A multi env's computer can't be named pgweb or db-mcp. The gateway serves a
  computer at /svc/<name>/, so such a computer used to pass the env's name
  checks and stop the gateway at startup, after every sandbox was made.
- Requests to a SQL console are forwarded without a write window. Only the
  control token reaches a console, so a write through one is no role's, and it
  no longer runs the changelog queries on the event loop.
- The deploy asks each console up to four times: a dropped or refused
  connection is asked again, as a timeout or a 502-504 already was.
- _verify_list_tools uses the MCP SDK's client (30 s, redirects), as it did
  before it took headers, and the tests check the record names db-mcp at the
  gateway before using it.
- A bad CONSOLE_URLS or WEBSITE_URLS entry names its own variable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… routes

The VM path exposes only the gateway's port, the compose file publishes no
port for pgweb or db-mcp, and the container path creates their sandboxes
with expose_externally=False. DeployedGateway drops db_web_url and db_mcp_url,
so new records name the consoles only at db_web_gateway_url and
db_mcp_gateway_url. DeployedGatewayEnv still reads both from older records
for one release.
@andrewpark-scaleai
andrewpark-scaleai force-pushed the andrewpark/gateway-only-console-ports branch from fc74893 to 572b192 Compare November 19, 2026 20:22
Base automatically changed from andrewpark/gateway-console-routes to main November 20, 2026 01:07

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants