Skip to content

fix: quarantined servers over-report available tools (#1064) + three Web UI presentation defects (#1065) - #1072

Merged
Dumbris merged 2 commits into
mainfrom
claude/chat-hygiene-handoff-65dad9
Aug 27, 2026
Merged

Dumbris merged 2 commits into
mainfrom
claude/chat-hygiene-handoff-65dad9

Conversation

@Dumbris

@Dumbris Dumbris commented Aug 27, 2026

Copy link
Copy Markdown
Member

Pull Request

Description

Fixes #1064 and #1065 — one backend counting defect and three Web UI presentation defects. Two commits, independently reviewable.

#1064 — a quarantined server's tools were still counted as "available"

tool_count stayed at its pre-quarantine value, GET /api/v1/tools returned every one of them, and the Servers page rendered the total under "Available across all servers" — while the search index correctly excluded them (#1061) and every call to those tools was refused with a SECURITY BLOCK. Two surfaces describing the same catalog disagreed, and the one an operator reads was the wrong one.

Quarantine is neither disabled nor disconnected: a quarantined server stays dialed with status: ready on purpose, so the tray and Web UI can inspect it for review. It therefore passed the existing disabled/not-connected guard untouched. The stale count also survives the supervisor's disconnect-zeroing, because LoadConfiguredServers re-dials the server and the next reconcile re-sticks the retained snapshot — which is why this is fixed at the projections rather than at the source.

Adds one shared predicate, config.ServerContributesTools(enabled, quarantined), mirroring the answers runtime.serverEligibleForIndexing already gives the index writer and preflight.ClassifyTool gives dispatch, and adopts it at the surfaces that were each re-deriving "available" from a different field. GET /api/v1/annotations/coverage had the same bug and is not mentioned in the issue.

Deliberately unchanged, and the main thing to check at review:

  • GET /api/v1/servers/{id}/tools still returns the full list. That is the review surface — it is how an operator inspects and approves a quarantined server, and after security: quarantining a server via the config file leaves its tools in the search index, so retrieve_tools still discloses their descriptions #1061 the StateView is its only source. Same for Server.GetQuarantinedServers, which exists to say how many tools await review.
  • isToolCallable stays quarantine-blind. It is the search filter and must reproduce merge-base semantics exactly (Spec 085 FR-006/FR-011), which require retrieve_tools to keep surfacing a quarantined server's lingering indexed tools; the stricter toolVisibleToSession applies the quarantine gate. My first attempt gated here and broke three pinned tests. TestVisibleToolCount_QuarantinedServer now pins both halves so the two cannot be collapsed again.
  • stats.quarantined_servers and health admin_state=quarantined are untouched — they are the counterpart that must still show a non-zero number.

Behaviour change worth calling out: users with quarantined servers will now report lower tool counts in /api/v1/status, the SSE servers.changed embed, /api/v1/profiles, the Prometheus tools-total gauge, the telemetry heartbeat, and the TOOLS column of mcpproxy upstream list.

#1065 — three Web UI presentation defects

1. A card asserted two contradictory security states. Green Clean sat directly above yellow Quarantined — needs security review. Both true; stacked as peers they say opposite things, because the verdict is about CONTENT and quarantine is about REVIEW STATE. While quarantined the standalone badge is suppressed and the verdict becomes a subordinate clause inside the banner (Last scan: clean — still needs review), so there is one security headline per card — the subordination ServerDetail's spec-088 banner already does. Every verdict still ends in a request to review, including failed, which is an incomplete scan and never a threat verdict.

2. The Activity Type column mixed two vocabularies. formatType fell through || type, so raw snake_case landed in a column otherwise full of title-cased prose. Four backend types had no label, not the one reported — security_scan is already rendering raw today, since it gained a findings drawer in #1046. The map is completed and exported, and the passthrough is replaced with a snake_case -> Title Case fallback so an unmapped value can never leak raw again. The filter dropdown is now derived from the same map instead of being hand-copied (it was three types short).

The recurrence guard lives in Go, not vitest: .github/workflows/frontend.yml is path-filtered to frontend/**, so a vitest-only guard would never run on the Go-only change that adds an activity type.

3. A stale auth error survived a successful sign-in. Entering a valid key re-authenticated the header while the view body kept its red panel and zero rows until the user clicked Retry. Every view holds its load error in a component-local ref nothing outside can reach. Adds a monotonic authEpoch bumped only on a genuine failed→ok transition; App.vue keys <router-view> on it so a repaired auth remounts the current view. AuthErrorModal's "Refresh & Retry" now validates the reloaded key before reporting success — it previously cleared the auth flag without verifying anything, which is why it could not safely invalidate views.

Testing

  • I have tested these changes locally
  • I have added/updated tests that prove my fix is effective or my feature works
  • All existing tests pass

Every new test was confirmed to fail before the corresponding fix, not just pass after it.

Check Result
go test -race ./... (CI skip regex) green
golangci-lint run --config .github/.golangci.yml ./... 0 issues
vitest run 954 passed (95 files)
Server edition (-tags server) build + tests green
Generated files (contracts.ts, web/) no drift

Live verification against an isolated instance with a real server-memory upstream, quarantining and un-quarantining it:

surface before quarantined after unquarantine
tool_count 9 0 9
stats.total_tools 9 0 9
GET /api/v1/tools 9 0 9
/api/v1/status total 9 0 9
annotations/coverage 9 0 —
index/search 0 0 —
servers/{id}/tools (review surface) 9 9 9

Disabled-server behaviour re-checked and unchanged. All three #1065 defects were confirmed in the running Web UI: no bare "Clean" anywhere on the Servers page, the Type column renders Tool Quarantine Change / Security Scan, and signing in drops the red panel and renders rows with no manual Retry.

Not run: ./scripts/test-api-e2e.sh — it blanket-pkills other running cores and another local instance was live. Worth running before merge.

Notes for the reviewer

Cross-reviewed with an independent model, which found two real defects that are fixed here: the isToolCallable over-reach described above, and a v-memo key that tracked security_scan.status but not the warning count the new note renders. It also flagged that handleAuthModalRefresh left defect 3 unfixed on the Refresh path — hence the validation change to AuthErrorModal.

…ble (#1064)

A quarantined server kept reporting its tools as available. `tool_count` stayed
at its pre-quarantine value, `GET /api/v1/tools` returned every one of them, and
the Servers page rendered the total under "Available across all servers" — while
the search index correctly excluded them (#1061) and every call to those tools
was refused with a SECURITY BLOCK. Two surfaces describing the same catalog
disagreed, and the one an operator reads was the wrong one.

Quarantine is neither "disabled" nor "disconnected": a quarantined server stays
dialed with status ready on purpose, so the tray and Web UI can inspect it for
review. It therefore passed the existing disabled/not-connected guard untouched.
The stale count also survives the supervisor's disconnect-zeroing, because
LoadConfiguredServers re-dials the server and the next reconcile re-sticks the
retained snapshot.

Adds one shared predicate, config.ServerContributesTools(enabled, quarantined),
mirroring the answers runtime.serverEligibleForIndexing already gives the index
writer and preflight.ClassifyTool gives dispatch, and adopts it at the surfaces
that were each re-deriving "available" from a different field:

- Projections zero the per-server count at the wire boundary:
  Runtime.GetAllServers, Server.GetAllServers, and both GetUpstreamStats paths
  (including the manager fallback, whose cached tool count no quarantine path
  invalidates).
- Aggregates gate the sum: management.ListServers, Server.GetUpstreamStats,
  Manager.GetTotalToolCount.
- GET /api/v1/tools and GET /api/v1/annotations/coverage skip quarantined
  servers. Skipping is a deliberate exclusion, not a fetch failure, so neither
  sets `partial`/`failed_servers`.
- getVisibleToolCount returns 0 for a quarantined server.
- The Web UI's totalTools excludes them too.

Deliberately unchanged:

- GET /api/v1/servers/{id}/tools still returns the full list. That is the
  review surface — it is how an operator inspects and approves a quarantined
  server, and after #1061 the StateView is its only source. Same for
  Server.GetQuarantinedServers, which exists to say how many tools await review.
- isToolCallable stays quarantine-blind. It is the *search* filter and must
  reproduce merge-base semantics exactly (Spec 085 FR-006/FR-011), which require
  retrieve_tools to keep surfacing a quarantined server's lingering indexed
  tools; the stricter toolVisibleToSession applies the quarantine gate.
  TestVisibleToolCount_QuarantinedServer pins both halves so the two cannot be
  collapsed again.
- stats.quarantined_servers and health admin_state=quarantined are untouched —
  they are the counterpart that must still show a non-zero number.

Behaviour change worth calling out at review: users with quarantined servers
will now report lower tool counts in /api/v1/status, the SSE servers.changed
embed, /api/v1/profiles, the Prometheus tools-total gauge, the telemetry
heartbeat, and the TOOLS column of `mcpproxy upstream list`.
…, stale auth error (#1065)

1. A server card asserted two contradictory security states at once

   The card rendered a green "Clean" scan verdict directly above a yellow
   "Quarantined — needs security review" banner. Both are individually true, but
   stacked as peers they tell the operator opposite things: the scan verdict is
   about CONTENT, quarantine is about REVIEW STATE.

   While quarantined, the standalone verdict badge is suppressed and the verdict
   is folded into the banner as a subordinate clause ("Last scan: clean — still
   needs review"), so the card carries exactly one security headline. This is the
   subordination ServerDetail's spec-088 banner already does, and the same shape
   as the #938 held-tools downgrade one level up. Nothing changes when the server
   is not quarantined. Every verdict still ends in a request to review, including
   the failed case, which is an INCOMPLETE scan and never a threat verdict.

   The Servers v-memo key gains security_scan.status and finding_counts.warning:
   the store updates server objects in place to preserve identity, so without
   them a scan settling on an already-quarantined server left a stale verdict.

2. The Activity Type column mixed two vocabularies

   formatType fell through `|| type` for anything unmapped, so raw snake_case
   landed in a column otherwise full of title-cased prose. Four backend types had
   no label, not the one reported: tool_quarantine_change, security_scan (already
   rendering raw today — it has had a findings drawer since #1046),
   credential_broker and prompt_get.

   The map is completed and exported as ACTIVITY_TYPE_LABELS, and the passthrough
   is replaced with a snake_case -> Title Case fallback so an unmapped value can
   never leak raw again. Server-level and tool-level quarantine keep distinct
   labels. The filter dropdown is derived from the same map instead of being
   hand-copied (it was three types short), and ActivityWidget's duplicate icon map
   is deleted in favour of the shared one.

   The recurrence guard lives in Go, not vitest:
   internal/storage/activity_label_parity_test.go fails when a backend type has
   no Web-UI label. .github/workflows/frontend.yml is path-filtered to frontend/**,
   so a vitest-only guard would never run on the Go-only change that adds a type.
   A second test asserts ValidActivityTypes covers every declared constant, so the
   first cannot go vacuously green.

3. A stale auth error survived a successful sign-in

   With no stored key, /ui/activity showed the auth modal, an inline red
   "Invalid or missing API key" panel behind it, and a Disconnected chip. Entering
   a valid key re-authenticated the header — counts and the Live badge came back —
   but the view body kept the red panel and rendered zero rows until the user
   clicked Retry by hand. Every view holds its load error in a component-local ref
   that nothing outside the component can reach, and no auth-recovered signal
   existed to reach it.

   Adds a monotonic authEpoch to the system store, bumped by markAuthRecovered()
   only on a genuine failed->ok transition. App.vue keys <router-view> on it, so a
   repaired auth remounts the current view and its error, loading state and data
   reset to their declared initial values while onMounted re-runs. Keyed on
   authEpoch alone: folding in the route path would remount ServerDetail on every
   :serverName change and break the Dashboard's single instance across /, /usage
   and /overview.

   reloadAfterAuth() re-primes the surfaces the key cannot reach (fetchInfo,
   fetchRouting, checkAuth — the router guard does not run for a key-driven
   remount), and SidebarNav watches the epoch for its badge counts rather than
   being remounted, which would also reset its open submenu and scroll.

   AuthErrorModal's "Refresh & Retry" now validates the reloaded key before
   reporting success and emits `refresh(verified)`. It previously cleared the
   auth flag without verifying anything, which is why it could not safely
   invalidate views — and why the stale panel survived on that path.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying mcpproxy-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: a8b4ecb
Status: ✅  Deploy successful!
Preview URL: https://01e2626b.mcpproxy-docs.pages.dev
Branch Preview URL: https://claude-chat-hygiene-handoff.mcpproxy-docs.pages.dev

View logs

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 28.88889% with 32 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/server/server.go 0.00% 23 Missing ⚠️
internal/runtime/runtime.go 0.00% 5 Missing ⚠️
internal/httpapi/server.go 50.00% 1 Missing and 1 partial ⚠️
internal/server/mcp.go 71.42% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@github-actions

Copy link
Copy Markdown
Contributor

📦 Build Artifacts

Workflow Run: View Run
Branch: claude/chat-hygiene-handoff-65dad9

Available Artifacts

  • archive-darwin-amd64 (29 MB)
  • archive-darwin-arm64 (26 MB)
  • archive-linux-amd64 (17 MB)
  • archive-linux-arm64 (15 MB)
  • archive-windows-amd64 (29 MB)
  • archive-windows-arm64 (26 MB)
  • frontend-dist-pr (0 MB)
  • installer-dmg-darwin-amd64 (23 MB)
  • installer-dmg-darwin-arm64 (21 MB)

How to Download

Option 1: GitHub Web UI (easiest)

  1. Go to the workflow run page linked above
  2. Scroll to the bottom "Artifacts" section
  3. Click on the artifact you want to download

Option 2: GitHub CLI

gh run download 33064052359 --repo smart-mcp-proxy/mcpproxy-go

Note: Artifacts expire in 14 days.

@Dumbris
Dumbris merged commit caa9cc4 into main Aug 27, 2026
39 checks passed
@Dumbris
Dumbris deleted the claude/chat-hygiene-handoff-65dad9 branch August 27, 2026 10:58
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.

Quarantined servers' tools are still counted as "available" in tool_count, /api/v1/tools and the Servers page

2 participants