You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Missing Token Refresh Mechanism for MCP Server Integrations #5706
Bug Description
This isn't technically a bug but rather a missing feature. Currently there is no way for Claude Code to refresh tokens for MCP servers. This means that we either have to have a very long lived token or manually refresh it.
Our platform deeply integrates with Claude Code and our MCP is effecively a state machine that has claude call various MCP calls to build and deploy applications. This building process can take 30-60 minutes.
The MCP spec does seem to call for a refresh token ability but I don't think Claude Code implements it. Happy to provide more feedback if you want you can reach me at [email protected]
Environment Info
Platform: darwin
Terminal: WarpTerminal
Version: 1.0.77
Feedback ID: 03061b16-5aa1-46a6-9c91-4125d664ee73
Errors
[]
Reacted by Ken Morishita , Paul Hernandez, Tony Ta, Stanislav Deviatykh, Yannick Epstein, Kai Mallea, Floris Vlasveld, Talal, Soleil Cotterell, Isaac Abouganem and 50 more
Reacted by Eddie, Tyler Jang, Jay(김재훈), Mate Boer , Saturnin Pugnet, Jisoo Park, Alik Khilazhev, Vince and Andrey Rubshtein
I am seeing this same issue. I can get Claude Code to authenticate our MCP sever via Oauth (using WorkOS as the provider) but when the token expires, it does not refresh the token. We send a 401 with the /.well-known/oath-protected-resource header. Claude Code calls that end point but never goes to the /.well-known/oauth-authorization-server to get the authentication endpoint.
Reacted by Tony Ta, Gautham Kishtapuram, shydefoo and Eszter Pálmai
Can someone actually comment if this is even working on WebUI? I currently have no way to know if we can refresh, like we never see any attempts and it's super frustrating. The idea may be to just allow for a long lived JWT but without the refresh mechanism it's kind of pointless
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
Facing the same issue, our custom MCP is protected by Microsoft OAuth, which issues access tokens that expire in 60-90 minutes. Manual re-auth is super tedious. Refresh tokens are issued but not consumed by Claude Code
I notice Linear's MCP server chose that workaround too: their access tokens expire in 7 days by default.
But I don't think it's the right solution, and neither do the MCP protocol authors, who say:
Authorization servers SHOULD issue short-lived access tokens to reduce the impact of leaked tokens.
The same page says MCP's authorization is based on OAuth 2.1, which says:
Authorization servers SHOULD issue short-lived bearer tokens, particularly when issuing tokens to clients that run within a web browser or other environments where information leakage may occur. Using short-lived bearer tokens can reduce the impact of them being leaked.
Somehow, Claude Code gives me an uninterrupted experience with the Linear MCP: I haven't had to reauthenticate or reauthorize in months. I don't think it can be dynamically registering a new client every time.
So I feel Claude Code must already implement refresh, but it's not working at shorter lifetimes?
Implementing or fixing refresh would make for a much smoother MCP experience.
@nkovacic I haven't seen the issue in the last day.
It seems now the token is refreshed when a new claude code is started, as well as if it expires during a session.
Unless there are more corner cases, I think this is fixed.
I'll keep an eye on this and post here if it happens again
Well the strangest thing happened right after posting that.
I closed a claude code session and started claude again, and on the first message I typed it said Not logged in · Please run /login
Logged in again, and then the Notion mcp needed Authorization again
In case this comes up again (OAuth is tricky, especially if multiple CC sessions are involved).
I built Bindify to solve exactly this. It's an MCP auth proxy that sits between Claude Code and GitHub, Todoist, etc. You authenticate once through Bindify, get a secret URL, and paste it into Claude Code (or Claude.ai) as a remote MCP server. Bindify handles the OAuth token refresh server-side. If you still run into issues, you can fall back to API token authentication, even with Claude.ai/mobile via Bindify's secure URLs.
Having this issue as well. I'm using oath middleware that refreshes a token used by headersHelper, which unfortunately doesn't handle token refresh for a remote hosted MCP Server. Yes I can do a local MCP Server proxy, but I'd rather not do that.
You can try Bindify.dev for handling your tokens with remote mcp servers. It does have a cost of $2/month after a free trial. It’s a good way to keep your workflow going strong while they sort these bugs out.
You can try Bindify.dev for handling your tokens with remote mcp servers. It does have a cost of $2/month after a free trial. It’s a good way to keep your workflow going strong while they sort these bugs out.
Disclaimer: I’m the developer behind Bindify.
@dylancwood
That's ok, I have my own solution / workaround. Also it's portable (will work seamlessly with other coding agents other than Claude Code). Local "lightweight" STDIO style MCP Server that acts as a proxy to the remote one and also handles OAuth refresh.
@etanlightstone-domino That's exactly the pattern mcp-stdio implements — a local stdio relay that bridges to a remote Streamable HTTP MCP server and handles OAuth token refresh transparently (401 → refresh → retry). Open source (MIT), single binary via pip/uvx/brew, only depends on httpx.
Tokens are cached in ~/.config/mcp-stdio/tokens.json (0600) and refreshed automatically when the upstream returns 401 mid-session. It also implements the full MCP authorization spec (RFC 9728 / 8414 / 8707 / 7636 / 7591 / 6750), so it works with providers that enforce strict scope or resource indicator requirements.
Thanks for the report. Token refresh for direct MCP connections was added and has been reliable since 2.1.69. If you are still being asked to re-authenticate on a current version, please open a new issue with the server URL and version.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.
Activity
harrymower commentedon Sep 10, 2025
I am seeing this same issue. I can get Claude Code to authenticate our MCP sever via Oauth (using WorkOS as the provider) but when the token expires, it does not refresh the token. We send a 401 with the /.well-known/oath-protected-resource header. Claude Code calls that end point but never goes to the /.well-known/oauth-authorization-server to get the authentication endpoint.
plappag commentedon Oct 6, 2025
Can someone actually comment if this is even working on WebUI? I currently have no way to know if we can refresh, like we never see any attempts and it's super frustrating. The idea may be to just allow for a long lived JWT but without the refresh mechanism it's kind of pointless
plappag commentedon Oct 6, 2025
Also btw to acknowledge OP: You can just use API key if you need to use it without any Oauth system.
github-actions commentedon Dec 8, 2025
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
agusdmb commentedon Dec 9, 2025
i have built an MCP server using fastmcp and i am having this problem too
plappag commentedon Dec 9, 2025
Set JWT to 30 days.. don't do refresh
skishtapuram-loyaltymethods commentedon Dec 10, 2025
Im seeing the same issue. @plappag - I dont have option to tweak the JWT
mauricekleine commentedon Dec 17, 2025
Facing the same issue, our custom MCP is protected by Microsoft OAuth, which issues access tokens that expire in 60-90 minutes. Manual re-auth is super tedious. Refresh tokens are issued but not consumed by Claude Code
pjcdawkins commentedon Dec 17, 2025
Well, it's an option.
I notice Linear's MCP server chose that workaround too: their access tokens expire in 7 days by default.
But I don't think it's the right solution, and neither do the MCP protocol authors, who say:
The same page says MCP's authorization is based on OAuth 2.1, which says:
Somehow, Claude Code gives me an uninterrupted experience with the Linear MCP: I haven't had to reauthenticate or reauthorize in months. I don't think it can be dynamically registering a new client every time.
So I feel Claude Code must already implement refresh, but it's not working at shorter lifetimes?
Implementing or fixing refresh would make for a much smoother MCP experience.
theshadow27 commentedon Jan 8, 2026
This is a huge issue for revo (@atlassian) https://community.atlassian.com/forums/Rovo-questions/The-MCP-Auth-expires-too-fast/qaq-p/3124036 ; it makes it basically unusable after ~5 minutes
13 remaining items
danmana commentedon Feb 27, 2026
@nkovacic I haven't seen the issue in the last day.
It seems now the token is refreshed when a new claude code is started, as well as if it expires during a session.
Unless there are more corner cases, I think this is fixed.
I'll keep an eye on this and post here if it happens again
danmana commentedon Feb 27, 2026
Well the strangest thing happened right after posting that.
I closed a claude code session and started claude again, and on the first message I typed it said
Not logged in · Please run /loginLogged in again, and then the Notion mcp needed Authorization again
pjcdawkins commentedon Mar 2, 2026
Yes it seems Claude Code is now refreshing (with v2.1.63): it is definitely no longer missing a token refresh mechanism.
danmana commentedon Mar 9, 2026
Yes, I haven't had any issues with Notion at least in the last week.
So I think this is fixed.
taylorwilsdon commentedon Mar 9, 2026
Can confirm I'm seeing refreshes land as well. Looks like it was fixed in that push last week but they didn't close out the issue.
dylancwood commentedon Mar 16, 2026
In case this comes up again (OAuth is tricky, especially if multiple CC sessions are involved).
I built Bindify to solve exactly this. It's an MCP auth proxy that sits between Claude Code and GitHub, Todoist, etc. You authenticate once through Bindify, get a secret URL, and paste it into Claude Code (or Claude.ai) as a remote MCP server. Bindify handles the OAuth token refresh server-side. If you still run into issues, you can fall back to API token authentication, even with Claude.ai/mobile via Bindify's secure URLs.
Setup guide: https://bindify.dev/fix/claude-todoist-mcp-expired — use code CLAUDEAUTHFIX to try it free for 2 months (limited to 10 people).
Disclaimer: I'm the developer behind Bindify. Feel free to reach out with questions.
etanlightstone commentedon Apr 10, 2026
Having this issue as well. I'm using oath middleware that refreshes a token used by headersHelper, which unfortunately doesn't handle token refresh for a remote hosted MCP Server. Yes I can do a local MCP Server proxy, but I'd rather not do that.
dylancwood commentedon Apr 10, 2026
@etanlightstone : that sounds like this bug has reappeared.
You can try Bindify.dev for handling your tokens with remote mcp servers. It does have a cost of $2/month after a free trial. It’s a good way to keep your workflow going strong while they sort these bugs out.
Disclaimer: I’m the developer behind Bindify.
etanlightstone-domino commentedon Apr 10, 2026
@dylancwood
That's ok, I have my own solution / workaround. Also it's portable (will work seamlessly with other coding agents other than Claude Code). Local "lightweight" STDIO style MCP Server that acts as a proxy to the remote one and also handles OAuth refresh.
shigechika commentedon Apr 10, 2026
@etanlightstone-domino That's exactly the pattern mcp-stdio implements — a local stdio relay that bridges to a remote Streamable HTTP MCP server and handles OAuth token refresh transparently (401 → refresh → retry). Open source (MIT), single binary via
pip/uvx/brew, only depends onhttpx.Example config for Claude Desktop / Claude Code:
{ "mcpServers": { "my-server": { "command": "mcp-stdio", "args": ["--oauth", "https://your-server.example.com/mcp"] } } }Tokens are cached in
~/.config/mcp-stdio/tokens.json(0600) and refreshed automatically when the upstream returns 401 mid-session. It also implements the full MCP authorization spec (RFC 9728 / 8414 / 8707 / 7636 / 7591 / 6750), so it works with providers that enforce strict scope or resource indicator requirements.dylancwood commentedon Apr 10, 2026
That's a great workaround, and the right way to go for coding agents. Bindify.dev is still necessary to solve the problem for claude mobile and web.
localden commentedon May 23, 2026
Thanks for the report. Token refresh for direct MCP connections was added and has been reliable since 2.1.69. If you are still being asked to re-authenticate on a current version, please open a new issue with the server URL and version.
github-actions commentedon Jul 13, 2026
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.