Web UI dashboard re-lists every upstream every 30s via /api/v1/stats/tokens, ignoring tool_discovery_interval 0s
Summary
An open Web UI dashboard makes mcpproxy send a live tools/list to every connected upstream, every 30 seconds, for as long as the tab stays open. This ignores the per-server tool_discovery_interval (including "0s") and the tool cache, so upstreams that should be idle are woken constantly. For scale-to-zero upstreams (Cloud Run and similar) this means the instance never scales down and is billed the whole time a browser tab is left open somewhere.
Versions
- mcpproxy v0.73.0 (linux-amd64), run as a systemd service
- 15 connected upstreams (stdio, http, streamable-http)
Cause
frontend/src/views/Home.vue:819-822: the dashboard callsloadTokenSavings()on mount and again on a 30 ssetInterval.loadTokenSavings()→GET /api/v1/stats/tokens(internal/httpapi/server.go:1221,handleGetTokenStats) →Server.GetTokenSavings()→Runtime.CalculateTokenSavings().internal/runtime/runtime.go:2483-2492:CalculateTokenSavingsloops overGetAllServerNames()and callsclient.ListTools(r.appCtx)on each server, one after another. This is a live upstream call (session_reinit.go:337logsMaking direct tools list call to upstream server), not a read of the cached/indexed tool list.handleActivityUsage(internal/httpapi/activity.go:1408) also callsGetTokenSavings(), so any caller of that endpoint triggers the same sweep.
Repro
- Configure an upstream with
"tool_discovery_interval": "0s"and"health_check_interval": "0s". - Open the Web UI Home page and leave it open (the tab can be in the background).
- Watch the log:
journalctl -u mcpproxy -f | grep "Making direct tools list call".
Observed: every server, including the one with 0s intervals, is listed sequentially every ~30 s (one sweep takes ~5 s with 15 upstreams). Over 10 minutes we counted 259 upstream tools/list calls with no MCP client activity at all.
A single request reproduces it without the UI:
curl -H "X-API-Key: $KEY" http://<listen-addr>/api/v1/stats/tokens
took 5.3 s and was followed by one tools/list per connected upstream.
Closing every dashboard tab stops it; afterwards only the regular discovery sweep remains.
Suggested fix
- Compute token savings from the tools mcpproxy already has (the indexed tool set / per-server StateView snapshot that
GET /servers/{id}/toolsalready serves), never from a liveListTools. - Optionally cache the computed
ServerTokenMetricsfor a minute, since the dashboard is the only consumer.
Why it matters
The per-server tool_discovery_interval: "0s" setting reads as "never poll this upstream". A dashboard tab silently overriding it is very hard to diagnose: nothing in the log names the caller, and the traffic looks like a background poll.