Skip to content

Missing Token Refresh Mechanism for MCP Server Integrations #5706

Closed

Description

@fokkedekker

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

[]

Activity

  1. harrymower commented on Sep 10, 2025

    @harrymower

    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.

  2. plappag commented on Oct 6, 2025

    @plappag

    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

  3. plappag commented on Oct 6, 2025

    @plappag

    Also btw to acknowledge OP: You can just use API key if you need to use it without any Oauth system.

  4. github-actions commented on Dec 8, 2025

    @github-actions

    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.

  5. added
    autoclose
    on Dec 8, 2025
  6. agusdmb commented on Dec 9, 2025

    @agusdmb

    i have built an MCP server using fastmcp and i am having this problem too

  7. removed
    autoclose
    on Dec 9, 2025
  8. plappag commented on Dec 9, 2025

    @plappag

    Set JWT to 30 days.. don't do refresh

  9. skishtapuram-loyaltymethods commented on Dec 10, 2025

    @skishtapuram-loyaltymethods

    Im seeing the same issue. @plappag - I dont have option to tweak the JWT

  10. mauricekleine commented on Dec 17, 2025

    @mauricekleine

    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

  11. pjcdawkins commented on Dec 17, 2025

    @pjcdawkins

    Set JWT to 30 days.. don't do refresh

    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:

    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.

  12. theshadow27 commented on Jan 8, 2026

    @theshadow27
  13. 13 remaining items

  14. danmana commented on Feb 27, 2026

    @danmana

    @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

  15. danmana commented on Feb 27, 2026

    @danmana

    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

  16. pjcdawkins commented on Mar 2, 2026

    @pjcdawkins

    Yes it seems Claude Code is now refreshing (with v2.1.63): it is definitely no longer missing a token refresh mechanism.

  17. danmana commented on Mar 9, 2026

    @danmana

    Yes, I haven't had any issues with Notion at least in the last week.
    So I think this is fixed.

  18. taylorwilsdon commented on Mar 9, 2026

    @taylorwilsdon

    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.

  19. dylancwood commented on Mar 16, 2026

    @dylancwood

    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.

  20. etanlightstone commented on Apr 10, 2026

    @etanlightstone

    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.

  21. dylancwood commented on Apr 10, 2026

    @dylancwood

    @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.

  22. etanlightstone-domino commented on Apr 10, 2026

    @etanlightstone-domino

    @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.

    @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.

  23. shigechika commented on Apr 10, 2026

    @shigechika

    @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.

    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.

  24. dylancwood commented on Apr 10, 2026

    @dylancwood

    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.

  25. localden commented on May 23, 2026

    @localden
    Collaborator

    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.

  26. github-actions commented on Jul 13, 2026

    @github-actions

    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.

  27. locked as resolved and limited conversation to collaborators on Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:autharea:mcpenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions