Add QA discoverability to MCP instructions and localhost guard for cloud browsers (#4984)

This commit is contained in:
Marc Kelechava 2026-03-04 16:56:11 -08:00 committed by GitHub
parent 9811ce6e3d
commit bdd1a26361
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 240 additions and 0 deletions

View file

@ -0,0 +1,25 @@
"""Localhost URL detection for cloud browser sessions."""
from __future__ import annotations
from urllib.parse import urlparse
_LOCALHOST_HOSTNAMES = frozenset(
{
"localhost",
"127.0.0.1",
"0.0.0.0", # noqa: S104 — detection, not binding
"::1",
"[::1]",
}
)
def is_localhost_url(url: str) -> bool:
"""Return True if *url* points to a loopback address."""
try:
parsed = urlparse(url)
hostname = (parsed.hostname or "").lower()
return hostname in _LOCALHOST_HOSTNAMES
except Exception:
return False