Repository navigation
fix(server): use canonical OAuth health in MCP upstream list - #1525
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Thank you @neylwalecki, this is an excellent fix and it's merged. You had it as a draft pending the CI lint lane; that lane (and the full suite) is green, so I marked it ready and merged it. What made it easy to land:
I also reviewed it with an independent second model; there were no defects, and the full CI suite passed on the merge with current Thanks again for this and for your earlier #1291 and #1057. Contributions like these make mcpproxy better for everyone. |
|
Glad to help ;-) |
…ostics (#1622) ## Problem `Server.GetAllServers` sits behind `GET /api/v1/servers/{id}/diagnostics`, the REST server-list fallback and the other controller readers. It rebuilt each server's health from connection state only, without the OAuth token status or expiry. As a result, a connected OAuth server with a valid stored token and listed tools was reported as "Authentication required" (`sign_in_required`, `usable=false`). For the same server, the runtime, the CLI and the MCP `upstream_servers` list (since #1525, issue #1522) all reported it as Ready. ## Fix - Reuse the runtime's canonical health projection, the same way #1525 did for `handleListUpstreams`. - The runtime projection reads its own snapshot, so its health is used only when its admin state (`enabled`, `quarantined`) matches the row's own snapshot. A row therefore never mixes two admin states. - Otherwise, including when the runtime has no entry for the server yet, the existing connection-based calculation is used as the fallback. - How authentication is enforced does not change: - a missing or expired token still requires sign-in; - a valid token never makes a quarantined or disabled server usable. ## Tests New `TestServerGetAllServersOAuthHealth` in `internal/server/server_oauth_health_test.go`. It covers these cases: - valid token - token without expiry - expired token - missing token - quarantined server with a valid token - disabled server with a valid token It asserts that the REST/diagnostics health equals the runtime health, and checks the expected status and `usable` flag. - **On `main`:** the "valid token" and "token without expiry" cases fail, reporting `sign_in_required` / `usable=false`. The "expired token" case fails with summary "Authentication required" instead of "Token expired". - **With this change:** all cases pass. The existing #1525 `TestMCPUpstreamList*` tests also still pass. Other checks: - `go build ./...` and `go build -tags server ./...` pass. - `go vet` on `./internal/server/` and `./internal/httpapi/` passes, and `gofmt` is clean. - `internal/httpapi` and `internal/health` tests pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Roman Chernyak <rchernyak@halocollar.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
An enabled OAuth upstream with a valid stored token reports
Connected / ready / usable=truethrough the CLI/runtime, butAuthentication required / sign_in_required / usable=falsethrough MCPupstream_servers/list.Reuse the runtime's canonical health projection for the MCP listing instead of reconstructing it without OAuth status and expiry metadata. Keep the existing server visibility filters, scrub health text at the MCP boundary, and preserve the connection-based fallback before runtime state is available. Authentication enforcement and tool search are unchanged.
Fixes #1522.
Validation
f2e58df3; 16 scenarios cover valid/missing/expired tokens, refresh metadata, OAuth failures, logout, 401 rejection, static-header auth, disabled/quarantined servers, redaction/scope, and absent runtime state.-race -count=3: pass.go vet ./internal/server/... ./internal/runtime/... ./internal/health/...: pass.server-everythingfixture. The global npm cache returned EACCES; its permissions and contents were preserved.internal/serverfails onlyTestProfileMiddleware_RefusalWorkIndependentOfFleet. The same flake reproduces on the clean, unmodified base in 4/15 isolated runs, tracked separately in [Bug]: Profile-gate allocation parity still flakes under race on Go 1.27/macOS #1523. No assertion was relaxed or skipped to hide it.The regression uses synthetic tokens,
.invalidendpoints and temporary storage. No installed proxy or real OAuth session was changed.