[BUG] Claude Code can't find refresh_token in connecting with MCP Server using OAuth

Resolved 💬 4 comments Opened Nov 28, 2025 by Colbert-Ran Closed Jan 28, 2026

Preflight Checklist

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

What's Wrong?

I’m using Claude Code version 2.0.55 and trying to add an external streamable MCP server. The connection flow completes successfully, but Claude Code loses its OAuth tokens immediately afterward. As a result, it repeatedly falls back into the “needs-auth” state.

What’s strange is that the exact same MCP server works perfectly in Cursor, including both tool calls and prompt calls, so the issue seems specific to Claude Code’s token handling.

I ran Claude with claude --debug, and the relevant logs are included below.

[DEBUG] MCP server "longbridge": Cleared stored tokens

[DEBUG] MCP server "longbridge": Using redirect port: 51968
[DEBUG] MCP server "longbridge": Generated new OAuth state
[DEBUG] MCP server "longbridge": Starting SDK auth
[DEBUG] MCP server "longbridge": Server URL: https://openapi.longb.....[omitted]
[DEBUG] MCP server "longbridge": No client info found
[DEBUG] MCP server "longbridge": Token expired without refresh token
[DEBUG] MCP server "longbridge": Saving code verifier
[DEBUG] MCP server "longbridge": Redirecting to authorization URL
[DEBUG] MCP server "longbridge": Authorization URL: https://openapi.longbridge.xyz/oauth2/authorize?response_type=code&client_id=6e77494f-5069-4e83-93f4-9c4dc3c5ae00.....[omitted]
[DEBUG] MCP server "longbridge": Opening authorization URL: https://openapi.longbridge.xyz/oauth2/authorize?response_type=code&client_id=6....[omitted]
[DEBUG] MCP server "longbridge": Initial auth result: REDIRECT
_[DEBUG] MCP server "longbridge": Completing auth flow with authorization code
[DEBUG] MCP server "longbridge": Found client info
[DEBUG] MCP server "longbridge": Returning code verifier
_
[DEBUG] MCP server "longbridge": Saving tokens
[DEBUG] MCP server "longbridge": Token expires in: 3600
[DEBUG] MCP server "longbridge": Has refresh token: true
[DEBUG] MCP server "longbridge": Auth result: AUTHORIZED
_[DEBUG] MCP server "longbridge": No token data found
[DEBUG] MCP server "longbridge": Tokens after auth: Missing
[DEBUG] MCP server "longbridge": Starting server reconnection after auth
[DEBUG] MCP server "longbridge": No token data found
[DEBUG] MCP server "longbridge": No client info found_

[DEBUG] MCP server "longbridge": Token expired without refresh token
[DEBUG] MCP server "longbridge": Generated new OAuth state
[DEBUG] MCP server "longbridge": Saving code verifier
[DEBUG] MCP server "longbridge": Redirection handling is disabled, skipping redirect
[DEBUG] MCP server "longbridge": HTTP Connection error: {"url":"https://openapi.longbridge.xyz/mcp","error":"Unauthorized","stack":"Error: Unauthorized\n at V2A.send (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1207:25433)"}

[DEBUG] MCP server "longbridge": Authentication required for HTTP server
[DEBUG] MCP server "longbridge": Reconnected: 0 tools, 0 commands, 0 resources

What Should Happen?

Claude should store token successfully

Error Messages/Logs

> [DEBUG] MCP server "longbridge": Cleared stored tokens
[DEBUG] MCP server "longbridge": Using redirect port: 51968
[DEBUG] MCP server "longbridge": Generated new OAuth state
[DEBUG] MCP server "longbridge": Starting SDK auth
[DEBUG] MCP server "longbridge": Server URL: https://openapi.longbridge.xyz/mcp
[DEBUG] MCP server "longbridge": No client info found
[DEBUG] MCP server "longbridge": Token expired without refresh token
[DEBUG] MCP server "longbridge": Saving code verifier
[DEBUG] MCP server "longbridge": Redirecting to authorization URL
[DEBUG] MCP server "longbridge": Authorization URL: https://openapi.longbridge.xyz/oauth2/authorize?response_type=code&client_id=6e77494f-5069-4e83-93f4-9c4dc3c5ae00.....[omitted]
[DEBUG] MCP server "longbridge": Opening authorization URL: https://openapi.longbridge.xyz/oauth2/authorize?response_type=code&client_id=6....[omitted]
[DEBUG] MCP server "longbridge": Initial auth result: REDIRECT
_**[DEBUG] MCP server "longbridge": Completing auth flow with authorization code
[DEBUG] MCP server "longbridge": Found client info
[DEBUG] MCP server "longbridge": Returning code verifier**_
**[DEBUG] MCP server "longbridge": Saving tokens**
[DEBUG] MCP server "longbridge": Token expires in: 3600
[DEBUG] MCP server "longbridge": Has refresh token: true
[DEBUG] MCP server "longbridge": Auth result: AUTHORIZED
**_[DEBUG] MCP server "longbridge": No token data found
[DEBUG] MCP server "longbridge": Tokens after auth: Missing
[DEBUG] MCP server "longbridge": Starting server reconnection after auth
[DEBUG] MCP server "longbridge": No token data found
[DEBUG] MCP server "longbridge": No client info found_**
[DEBUG] MCP server "longbridge": Token expired without refresh token
[DEBUG] MCP server "longbridge": Generated new OAuth state
[DEBUG] MCP server "longbridge": Saving code verifier
[DEBUG] MCP server "longbridge": Redirection handling is disabled, skipping redirect
[DEBUG] MCP server "longbridge": HTTP Connection error: {"url":"https://openapi.longbridge.xyz/mcp","error":"Unauthorized","stack":"Error: Unauthorized\n    at V2A.send (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1207:25433)"}

[DEBUG] MCP server "longbridge": Authentication required for HTTP server
[DEBUG] MCP server "longbridge": Reconnected: 0 tools, 0 commands, 0 resources

Steps to Reproduce

claude mcp add --transport http name url

Claude Model

None

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.0.55

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

_No response_

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗