Repository navigation
Description
Summary
The auto-detected MCP URL that Trinity advertises to external clients (Settings → MCP URL, the connector snippets, GET /api/settings/mcp-url) is always http://<hostname>:8080/mcp, even when the request arrived over HTTPS through a reverse proxy or tunnel. On a Cloudflare Tunnel, Caddy (DigitalOcean 1-Click), or any nginx + Let's Encrypt install the correct, already-working endpoint is https://<hostname>/mcp — src/frontend/nginx.conf has proxied /mcp to the MCP container since #2281 — but the default URL still points users at plain HTTP on a port that a hardened install does not even publish.
Context
_get_default_mcp_url in src/backend/routers/settings/mcp_url.py builds the URL from the Host header alone: it hardcodes the http:// scheme and the :8080 port and ignores X-Forwarded-Proto. The frontend nginx already sets X-Forwarded-Proto $scheme on the /api/ route, so the information is on the request and simply unused.
Consequences today:
- A tunnel/Caddy install shows an MCP URL that is either unreachable (port 8080 not published) or downgrades the client to plaintext when 8080 is open. The operator has to know to set the
mcp_external_urloverride by hand. docs/memory/requirements/mcp.md§7.6 requires the MCP port to be exposed over TLS only whenMCP_INLINE_AUTH_ENABLEDis on (the keyless session id is a bearer credential on the wire), yet the platform's own default URL steers keyless connector users tohttp://.- The agent-side
.mcp.jsonvalidator (docker/base-image/agent_server/mcp_validator.py) rejects any owner-supplied HTTP MCP server that is nothttps://, so Trinity holds third parties to a rule its own advertised URL does not meet.
Out of scope here: the agent-container hop (TRINITY_MCP_URL defaulting to http://mcp-server:8080/mcp on the internal Docker bridge) and TLS termination inside the MCP container. Those are separate, larger changes; this issue is only the advertised external URL.
Acceptance Criteria
- When the request carries
X-Forwarded-Proto: https, the auto-detected default ishttps://<hostname>/mcp(no:8080), since the proxy serves/mcpon the same origin. - When the request carries
X-Forwarded-Proto: httpor no forwarded header, behaviour is unchanged:http://<hostname>:8080/mcp(http://localhost:8080/mcpfor localhost / 127.0.0.1), so bare-VM and local dev installs are not affected. - A forwarded
X-Forwarded-Host(when present) takes precedence overHostfor the hostname, matching how the other proxied routes are resolved; if the codebase has no precedent for trustingX-Forwarded-Host, document the decision to stick withHostin the PR. - The stored
mcp_external_urloverride continues to win over auto-detection; theGET /api/settings/mcp-urlresponse still returns bothurlanddefault_url. - Connector snippets (
src/backend/services/connector_service.py) and the enterprise connector route (src/backend/routers/connector.py) pick up the corrected default throughresolve_mcp_urlwith no change on their side. - Unit tests cover the three cases: forwarded https, forwarded http, no header; plus the override-wins case.
- The Settings → MCP URL panel shows honest status: the auto-detected value is labelled as detected from the proxy, and the override hint still explains when to set one.
Technical Notes
- Change site:
_get_default_mcp_url(request)insrc/backend/routers/settings/mcp_url.py. Readrequest.headers.get("x-forwarded-proto"), take the first value if comma-separated (multi-hop proxies), and compare case-insensitively. - Only trust the forwarded scheme to upgrade the URL shape; never downgrade an explicit
httpsoverride. docs/DEPLOYMENT.md"TLS on a bare VM" already documents the three edge options (tunnel, private network, own reverse proxy); a one-line note that the MCP URL is now detected from the proxy scheme belongs there.- Related: feat: DigitalOcean Marketplace 1-Click Droplet listing for Trinity (vendor application + Packer snapshot, AI Agents category) #2281 (nginx
/mcpproxy for hosted installs).
Activity
obasilakis commentedon Oct 19, 2026
/claim
github-actions commentedon Oct 19, 2026
Claimed by @obasilakis. Label
status-in-progressadded.Next steps:
feature/2907-<short-slug>Fixes #2907fix: webhook and MCP URLs use https behind an HTTPS proxy (#3601, #2907…