Skip to content

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

Closed
andrewpark-scaleai wants to merge 1 commit into
mainfrom
andrewpark/vuln-3253-sidecars-behind-gateway
Closed

andrewpark-scaleai wants to merge 1 commit into
mainfrom
andrewpark/vuln-3253-sidecars-behind-gateway

Conversation

@andrewpark-scaleai

@andrewpark-scaleai andrewpark-scaleai commented Nov 17, 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: 4/5

Name the console probe's limits before merging to meet the repository rule.

Fix All in CursorFindings

  1. P2 Console limits lack names ▶
  2. P2 Computer names fail too late. ▶
Fix with agent prompt
### Issue 1
src/agent_env/providers/env_providers/env_gateway_provider.py:1232
**Console limits lack names.** The new probe hardcodes a 30-second timeout and a two-attempt limit. The repository rule requires magic numbers to be stored as class or instance variables with descriptive names. Give these limits named settings so developers can find and tune them without reading through the probe.

### Issue 2
src/agent_env/providers/env_providers/env_gateway_provider.py:1763-1764
The new check reserves console keys only for websites. A computer named `pgweb`, including a website browser computer, still passes `MultiEnv`'s name checks. Deployment then creates its sandboxes and puts `pgweb` in `REST_PROXY_URLS`, where the new `Gateway` clash check stops startup. Check computer names against the console keys before creating sandboxes, and cover this case with a test.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

The PR adds control-token-protected database consoles under the gateway and records their gateway URLs.

  • The gateway serves pgweb and db-mcp at protected /svc/ routes.
  • Deploy records and CLI output include the gateway URLs for both SQL consoles.

The new probe limits need names to meet the repository rule.

Reviews (2) · Last reviewed commit: "feat(gateway): serve pgweb and db-mcp at..." · Reviewed by Greptile

@andrewpark-scaleai
andrewpark-scaleai force-pushed the andrewpark/vuln-3253-sidecars-behind-gateway branch from 9459d49 to 7985a79 Compare November 18, 2026 23:54
@andrewpark-scaleai andrewpark-scaleai changed the title feat(gateway): serve pgweb and db-mcp at /svc/ behind the control token (VULN-3253) feat(gateway): serve pgweb and db-mcp at /svc/ routes Nov 19, 2026
@earakely-scale
earakely-scale marked this pull request as ready for review November 19, 2026 18:23
@earakely-scale
earakely-scale requested a review from a team as a code owner November 19, 2026 18:23
Comment on lines +1763 to +1764
problems += [f"website name {w.environment_name!r} is the /svc key of a SQL console the gateway serves"
for w in website_configs or [] if w.environment_name in _CONSOLE_PATHS]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Computer names fail too late. The new check reserves console keys only for websites. A computer named pgweb, including a website browser computer, still passes MultiEnv's name checks. Deployment then creates its sandboxes and puts pgweb in REST_PROXY_URLS, where the new Gateway clash check stops startup. Check computer names against the console keys before creating sandboxes, and cover this case with a test.

Knowledge Base Used: Environment lifecycle and runtime access

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agent_env/providers/env_providers/env_gateway_provider.py
Line: 1763-1764

Comment:
**Computer names fail too late.** The new check reserves console keys only for websites. A computer named `pgweb`, including a website browser computer, still passes `MultiEnv`'s name checks. Deployment then creates its sandboxes and puts `pgweb` in `REST_PROXY_URLS`, where the new `Gateway` clash check stops startup. Check computer names against the console keys before creating sandboxes, and cover this case with a test.

**Knowledge Base Used:** [Environment lifecycle and runtime access](https://app.greptile.com/-/switch-tenant?tenant=scale-ai&next=%2Fcustom-context%2Fknowledge-base%2Fscaleapi%2Fagentenv-framework%2F-%2Fdocs%2Fenvironment-lifecycle.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Cursor Fix in Claude Code Fix in Codex

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.
@andrewpark-scaleai
andrewpark-scaleai force-pushed the andrewpark/vuln-3253-sidecars-behind-gateway branch from 7985a79 to 5d14668 Compare November 19, 2026 18:48
return False
return True

async with httpx.AsyncClient(timeout=30) as client:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Console limits lack names. The new probe hardcodes a 30-second timeout and a two-attempt limit. The repository rule requires magic numbers to be stored as class or instance variables with descriptive names. Give these limits named settings so developers can find and tune them without reading through the probe.

Rule Used: Store magic numbers as class or instance variables with descriptive names rather than using them inline in the code. (source)

Learned From
scaleapi/scaleapi#126388

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agent_env/providers/env_providers/env_gateway_provider.py
Line: 1232

Comment:
**Console limits lack names.** The new probe hardcodes a 30-second timeout and a two-attempt limit. The repository rule requires magic numbers to be stored as class or instance variables with descriptive names. Give these limits named settings so developers can find and tune them without reading through the probe.

**Rule Used:** Store magic numbers as class or instance variables with descriptive names rather than using them inline in the code. ([source](https://app.greptile.com/-/switch-tenant?tenant=scale-ai&next=%2Fcustom-context%3Fmemory%3D002e0051-41ad-46c1-9098-47433c580150))

**Learned From**
[scaleapi/scaleapi#126388](https://github.com/scaleapi/scaleapi/pull/126388)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Cursor Fix in Claude Code Fix in Codex

@andrewpark-scaleai
andrewpark-scaleai deleted the andrewpark/vuln-3253-sidecars-behind-gateway branch November 19, 2026 18:52
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.

1 participant