Repository navigation
Description
What happened?
I moved nine upstreams from OAuth to a plain static token in the Authorization header. In the config, oauth is now null for all of them.
They all work fine. Tool calls succeed every time. But the status still says:
level: unhealthy
summary: Token expired
action: login
It has said that for about two weeks, across many restarts. There is no login to do, because these servers do not use OAuth any more.
The reason is an old OAuth token left behind in config.db. Switching the server to header auth does not delete it.
In the oauth_tokens bucket I still see one record per server:
cloudflare_cffd8ffdbe422719
cloudflare-workers_2a776bac1041e57b
cloudflare-dns_a856b1a089eba814
cloudflare-graphql_8789ed3254155ec0
... one for each of the nine
The API then builds an oauth object out of that dead record and returns it, even though the config says null:
"oauth": {
"auth_url": "",
"token_url": "",
"client_id": "",
"token_expires_at": "2026-08-17T03:43:04Z"
}That date is in the past, so internal/health/calculator.go takes this branch:
if input.OAuthStatus == "expired" {
Summary: "Token expired", Action: ActionLogin, Level: LevelUnhealthy
}So the old saved token wins over the current config.
One more thing. POST /api/v1/servers/<name>/logout does clear the token record, and oauth becomes null in the API. But after a restart the status changes to Refresh token expired instead. So there seems to be a second leftover record (the refresh state) that logout does not clean up.
Expected behavior
A server with "oauth": null and a working Authorization header should show as healthy and connected.
Old OAuth records should be removed when a server stops using OAuth, or at least ignored when the config has no OAuth.
Steps to reproduce
- Add an HTTP upstream that uses OAuth and log in, so a token gets saved.
- Wait until that token's expiry time has passed.
- Change the same server to use a static token instead: set
oauthtonulland put the token in anAuthorizationheader. - Restart mcpproxy.
- Look at the server status. It says
Token expiredwith aloginaction, but tool calls work.
MCPProxy version
MCPProxy v0.63.0 (personal) linux/amd64
Operating system
Linux
Relevant logs
The status is wrong even when the connection is completely clean. Here is the same server answering a real tool call at the moment its health said Token expired:
$ cloudflare-workers:workers_list
{"workers":[ ... 31 workers ... ],"count":31}
And the older refresh error that first put the record into a failed state, from before the switch to header auth:
Re-authentication required: failed to refresh OAuth token: server not found: cloudflare-workers
Why this matters
The status field becomes useless for these servers. It is permanently red, so a real problem later would not stand out. In my case I had three servers that were genuinely broken (missing API token permissions) sitting in the same list as six that were fine, and every one of them looked identical.
Possible fixes
- When a server's config no longer has
oauth, delete its stored OAuth token and refresh state. - Or, in the health calculator, do not use a stored token when the current config has no OAuth and the server has an
Authorizationheader. - Make
logoutalso clear the refresh state, not just the token.
Happy to test a fix. I can reproduce this on demand.
Pre-submission checklist
- I searched existing issues and did not find a duplicate. The closest are OAuth refresh goes deadloop loop #310 and OAuth login loops after logout/restart: DCR placeholder token is treated as persisted token #305, both closed and both about different symptoms (retry loops, not a stuck status).
Activity
antongulin commentedon Sep 4, 2026
Still reproduces on v0.64.0 (personal, linux/amd64). Re-checked after upgrading from v0.63.0 today.
This install happens to be a natural A/B for the diagnosis in the issue: 10 upstreams point at the same provider's remote MCP servers, and they differ only in their stored OAuth state.
config.dbconnectedhealthtrue, tools servedunhealthy/"Token expired"/action: loginlogouttrue, 23 toolshealthytrue, 2 toolshealthyAll ten are connected and serving tools; only the eight with a leftover
oauth_tokensrecord report unhealthy. The one that was explicitly logged out sits in the same config shape as the other eight and reports correctly — which is what the issue predicts ifinternal/health/calculator.gois trusting the stored record over the live"oauth": nullconfig.Two things changed between v0.63.0 and v0.64.0 that may be useful:
detailis now empty. On v0.63.0 the same servers carrieddetail: "Re-authentication required: failed to refresh OAuth token: server not found: <name>". On v0.64.0summaryis still"Token expired"butdetailis"", so the only hint about why is gone."Refresh token expired"(the second stale refresh-state record described in the issue). After the upgrade it reports healthy, with no further action taken on it — so something in v0.64.0 appears to have cleared or stopped consulting that second record, while the first-order case is untouched.Happy to pull any specific field out of these installs if it helps narrow it down.
fix(oauth): honour the oauth block for upstreams that authorise per m…
fix(health): stop judging header-auth servers by a stale OAuth token …