Skip to content

feat(gateway): serve pgweb and db-mcp at /svc/ routes - #821

Merged
earakely-scale merged 5 commits into
mainfrom
andrewpark/gateway-console-routes
Nov 20, 2026
Merged

earakely-scale merged 5 commits into
mainfrom
andrewpark/gateway-console-routes

Conversation

@andrewpark-scaleai

@andrewpark-scaleai andrewpark-scaleai commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Why

The gateway already fronts each env's MCP servers and state routes at /svc/<key>/. This PR adds pgweb and db-mcp to that set, so every harness caller reaches the database consoles the same way: one host, one auth scheme, the deployment's control token.

What changed

  • The gateway serves /svc/pgweb/ and /svc/db-mcp/ from a new CONSOLE_URLS variable. Both take the control token, like the gateway's other guarded routes.
  • The consoles live in their own map, not in REST_PROXY_URLS, so they never become backing servers in the env card.
  • The compose path points the gateway at pgweb:8081 and db-mcp:8000 on env-network. The container path points it at the console sandboxes.
  • On the container path, db-mcp binds every address family (--streamable-http-host= with an empty value).
  • The deploy records db_web_gateway_url ({gateway}/svc/pgweb/) and db_mcp_gateway_url ({gateway}/svc/db-mcp/mcp). db_web_url and db_mcp_url stay as they are, so consumers keep working until they move.
  • The CLI (env deploy, env get-instance, task run, run --keep) prints the gateway URLs.
  • A website can no longer be named pgweb or db-mcp, since those are now /svc keys.

Blast Radius

  • New deploys hand the gateway one more environment variable and record two more fields. No existing field or route changes.
  • A website or MCP backing key named pgweb or db-mcp would now clash. The deploy refuses such a website by name.

Verification

  • tst/unit/env/gateway/console_routes_test.py is new, with 83 cases.
  • Unit trees tst/unit/env, tst/unit/providers and tst/unit/cli pass. ruff check src tst passes.
  • Local stack with real pgweb 0.16.2, db-mcp from Dockerfile.db-mcp and this branch's gateway: both consoles answer through the gateway with the token.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no new blocking issues were found.

Summary

Adds control-token-protected database consoles behind the gateway while keeping their existing direct URLs in deployment records.

  • Gateway routes now carry pgweb and db-mcp requests to their consoles.
  • Deploy records and CLI output now include the gateway URLs for database consoles.
  • Websites and computers can no longer take the pgweb or db-mcp route names.

No new actionable issues found. Both earlier findings are addressed.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    C[Caller] -->|Control token| G[Gateway]
    G -->|/svc/pgweb/| P[pgweb]
    G -->|/svc/db-mcp/mcp| D[db-mcp]
    P --> DB[(PostgreSQL)]
    D --> DB
    G --> R[Deployment record]
    R --> CLI[CLI displays gateway URLs]
Loading

Reviews (5) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

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.
Comment thread src/agent_env/env/gateway/gateway.py Resolved
earakely-scale and others added 4 commits November 19, 2026 11:32
…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>
- CONSOLE_SERVICE_NAMES, beside the console service names, is the one set the
  website and computer name checks refuse.
- consoles_environment() writes CONSOLE_URLS for both deploy paths, as
  computers_environment() and the other gateway variables are written.

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

# Conflicts:
#	src/agent_env/env/env.py
#	tst/unit/providers/env_providers/env_gateway_provider_test.py
@earakely-scale
earakely-scale merged commit 07bc001 into main Nov 20, 2026
35 checks passed
@earakely-scale
earakely-scale deleted the andrewpark/gateway-console-routes branch November 20, 2026 01:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants