claude-code - 💡(How to fix) Fix [BUG] MCP HTTP OAuth: refresh token never used; multi-session sharing broken [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#53803Fetched 2026-04-28 06:46:57
View on GitHub
Comments
2
Participants
2
Timeline
9
Reactions
1
Author
Timeline (top)
labeled ×5commented ×2subscribed ×1unlabeled ×1

Error Message

Error Messages/Logs

Root Cause

This duplicates #28262 (closed as "not planned"), #44416, #18442, and #19456. Filing fresh because the closed status communicates this is acceptable behavior, and it isn't — for users on remote MCP servers that gate real work (Jira, Notion, Linear), it's a steady tax on every working day. Atlassian fixed the server side in atlassian/atlassian-mcp-server#12; the gap is in Claude Code.

RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Claude Code's MCP HTTP OAuth layer never uses the stored refresh token. Access tokens for the Atlassian MCP (https://mcp.atlassian.com/v1/mcp) expire roughly every 8 hours, and instead of silently refreshing using the refresh token already in ~/.claude/.credentials.json, Claude Code forces a full browser-based /mcp re-authentication.

This duplicates #28262 (closed as "not planned"), #44416, #18442, and #19456. Filing fresh because the closed status communicates this is acceptable behavior, and it isn't — for users on remote MCP servers that gate real work (Jira, Notion, Linear), it's a steady tax on every working day. Atlassian fixed the server side in atlassian/atlassian-mcp-server#12; the gap is in Claude Code.

New evidence — multi-session state is also broken: today I authenticated in session A (terminal 1). Switched to session B (terminal 2, same machine) and was forced to authenticate again, even though .credentials.json had been freshly updated by session A. Sessions appear to cache OAuth state in memory and don't re-read .credentials.json on the next failed call. So the cost scales with concurrent sessions: I'm hitting 4–5 re-auths per week.

What Should Happen?

  • On token expiry, Claude Code calls the OAuth refresh endpoint using the stored refresh token, without browser interaction.
  • All concurrent sessions read the latest tokens from .credentials.json before failing a call.
  • Refreshed tokens are persisted back to .credentials.json.

Error Messages/Logs

Steps to Reproduce

  1. Configure Atlassian MCP via claude mcp add with HTTP transport, server URL https://mcp.atlassian.com/v1/mcp.
  2. Authenticate via /mcp in session A.
  3. Open a second terminal with another Claude Code session (session B).
  4. In session B, try to call any Atlassian MCP tool (e.g., searchJiraIssuesUsingJql) → "Authentication required".
  5. Re-auth in session B. Now session A may also need re-auth on its next call.
  6. Even with only one session: leave Claude Code idle for ~8 hours and the next call requires re-auth, despite a valid refresh token sitting in ~/.claude/.credentials.json.

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.1.119

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

WSL (Windows Subsystem for Linux)

Additional Information

Inspected ~/.claude/.credentials.json — the mcpOAuth.atlassian|<id> entry contains both accessToken and refreshToken, plus expiresAt set ~8h in the future after each fresh auth. The refresh token is present but never used.

Bug also reproduced on 2.1.117 and 2.1.118.

Related: #28262, #44416, #18442, #19456, atlassian/atlassian-mcp-server#12.

extent analysis

TL;DR

The most likely fix involves modifying Claude Code to utilize the stored refresh token for silent authentication upon access token expiry.

Guidance

  • Investigate the OAuth refresh endpoint implementation in Claude Code to ensure it correctly uses the stored refresh token from ~/.claude/.credentials.json.
  • Verify that the expiresAt value in ~/.claude/.credentials.json is being checked to trigger refresh token usage before access token expiry.
  • Review the multi-session state handling to ensure that each session reads the latest tokens from ~/.claude/.credentials.json before making calls, potentially by implementing a mechanism to update the in-memory cache upon token refresh.
  • Consider adding logging to track when refresh tokens are used and when re-authentication is required to better understand the authentication flow.

Example

No code snippet is provided due to the lack of specific implementation details in the issue.

Notes

The issue seems to stem from Claude Code not utilizing the refresh token as intended, and the multi-session state not being properly synchronized. The provided information does not specify the exact implementation of the OAuth flow in Claude Code, so the guidance is based on the expected behavior of OAuth refresh tokens.

Recommendation

Apply a workaround by modifying the Claude Code to correctly implement the OAuth refresh token flow, ensuring that it checks for and uses the refresh token when the access token expires, and that all sessions read the latest tokens from ~/.claude/.credentials.json. This approach is recommended because it directly addresses the identified issue with the current implementation.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] MCP HTTP OAuth: refresh token never used; multi-session sharing broken [2 comments, 2 participants]