fix(discovery): persist and prefer canonical backend URL#3350
Conversation
- add optional backend_url support to discovery metadata while keeping legacy parsing - write the canonical localhost backend URL during server startup - prefer the canonical discovery URL before legacy host+port reconstruction in MCP Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit c9e7bab. Configure here.
| None => Some(read_port_info("vibe-kanban").await?), | ||
| }; | ||
|
|
||
| resolve_base_url_from_sources(log_prefix, backend_url, host, explicit_port, port_info) |
There was a problem hiding this comment.
Eager evaluation breaks VIBE_BACKEND_URL short-circuit precedence
High Severity
resolve_base_url eagerly reads the port file and parses port env vars (both with ? propagation) before resolve_base_url_from_sources gets to check VIBE_BACKEND_URL. If VIBE_BACKEND_URL is set but the port file doesn't exist, or a port env var contains a non-numeric value, the function returns an error instead of using the highest-precedence override. The old code short-circuited on VIBE_BACKEND_URL before touching any other source, so this is a regression.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit c9e7bab. Configure here.
Aggressive review summary — PR #3350221-line plumbing fix across Why the change is correctThe pre-PR discovery flow was: server writes The refactor of Findings
NITs
VerdictApprove. — Reviewed by automated single-pass review (discovery plumbing; full 4-tool battery skipped — refactor follows clean-input-output split with logged precedence). |


fix(discovery): persist and prefer canonical backend URL
What
backend_urlfield toPortInfoand keep legacy raw-port / JSON discovery parsing intactvibe-kanban.portduring server startupVIBE_BACKEND_URL, then explicit env host/port, then the discovered canonical backend URL before falling back to legacy host+port reconstructionWhy
Issue #3349 showed MCP could recover a stale or incomplete discovery record and rebuild
http://127.0.0.1:<port>even when the healthy desktop backend was serving onhttp://localhost:<port>/::1.Persisting the backend's canonical runtime URL lets MCP reuse the same endpoint the server actually bound, avoiding loopback-family mismatches while preserving existing overrides and legacy discovery compatibility.
How
crates/utils/src/port_file.rswithPortInfo::backend_url, aread_port_infohelper, and compatibility tests for legacy formatswrite_port_file_with_proxy_and_backend_url(...)fromcrates/server/src/startup.rsresolve_base_urlincrates/mcp/src/bin/vibe_kanban_mcp.rsinto source-precedence logic that prefers the canonical discovered URL when presentTesting
cargo test -p utils --libcargo test -p mcp --bin vibe-kanban-mcpcargo test -p server --lib --no-runRelated
localhost/::1#3349vibe-kanban-mcp) is incompatible with the self-hostedremote-server(path + envelope mismatch) #3340, Fix relay local address selection for packaged desktop builds (Vibe Kanban) #3119, fix(relay): use actual server bind address instead of hardcoded 127.0.0.1 (Vibe Kanban) #3238Note
Medium Risk
Changes backend discovery/URL resolution between server and MCP; mistakes could break local connectivity if the port file or precedence logic is wrong, but scope is limited and covered by new unit tests.
Overview
Persists a canonical
backend_urlalongside ports in the temp discovery file (PortInfo), while keeping backwards-compatible parsing for legacy raw-port and older JSON formats.On server startup, writes this canonical URL into the discovery record, and updates MCP base-URL resolution to prefer
VIBE_BACKEND_URL, then explicit env host/port, then the discovered canonical URL before falling back to reconstructinghttp://<host>:<port>. Adds unit tests covering discovery parsing and URL precedence.Reviewed by Cursor Bugbot for commit c9e7bab. Bugbot is set up for automated code reviews on this repo. Configure here.