claude-code - 💡(How to fix) Fix [BUG] Re-authenticate menu crashes with JSON parse error on bearer-only MCP servers in v2.1.120 (not covered by #52158 fix) [1 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#53087Fetched 2026-04-25 06:12:41
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Author
Timeline (top)
labeled ×5commented ×1

Error Message

SDK auth failed: HTTP 404: Invalid OAuth error response: SyntaxError: JSON Parse error: Unexpected identifier "Not". Raw body: Not Found

Code Example

SDK auth failed: HTTP 404: Invalid OAuth error response: SyntaxError: JSON Parse error: Unexpected identifier "Not". Raw body: Not Found

---

# Fresh shell, fresh ~/.claude.json
claude mcp add --transport http --scope user chainstack-repro https://mcp.chainstack.com/mcp
claude
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?

The /mcp → server → Re-authenticate menu item still throws a JSON parse crash on streamable-HTTP MCP servers that don't implement OAuth. This is not the same code path as #52158, which the v2.1.119 changelog covered:

"Fixed MCP HTTP connections failing with 'Invalid OAuth error response' when servers returned non-JSON bodies for OAuth discovery requests"

That fix addressed the connection-handshake OAuth probe. The Re-authenticate menu hits a separate OAuth-discovery code path that still crashes when the server returns a non-JSON 4xx on /.well-known/oauth-protected-resource or /.well-known/oauth-authorization-server.

Anthropic's bot is currently auto-closing related reports (e.g. #47424, #34008) as duplicates of #52158 with the comment "fixed in 2.1.119" — but this Re-authenticate-menu repro on v2.1.120 demonstrates the bug is still live.

A separate UX issue compounds the confusion: the /mcp panel shows Auth: ✓ authenticated for any HTTP MCP server whose initial handshake didn't 401, regardless of whether a Bearer header is configured or valid. So users hit "Re-authenticate" expecting a recovery path, and instead see this stack trace.

What Should Happen?

When the OAuth discovery probe (whether connection-time or Re-authenticate-time) gets a non-JSON 4xx body on the well-known endpoints:

  1. The MCP SDK should not crash on JSON.parse(). It should treat the response as "this server doesn't expose OAuth metadata."
  2. The Re-authenticate menu should surface that as a graceful "this server doesn't support OAuth re-authentication — please configure auth via your MCP config" message, not a SyntaxError stack trace.

Error Messages/Logs

SDK auth failed: HTTP 404: Invalid OAuth error response: SyntaxError: JSON Parse error: Unexpected identifier "Not". Raw body: Not Found

Steps to Reproduce

Public, anyone-can-repro server: https://mcp.chainstack.com/mcp (Chainstack's MCP server — uses static-Bearer auth, no OAuth provider).

# Fresh shell, fresh ~/.claude.json
claude mcp add --transport http --scope user chainstack-repro https://mcp.chainstack.com/mcp
claude

In the Claude Code TUI:

  1. Run /mcp
  2. Select chainstack-repro
  3. Pick 2. Re-authenticate

Expected: a graceful "this server does not support OAuth re-authentication" or similar. Actual: SDK auth failed: HTTP 404: Invalid OAuth error response: SyntaxError: JSON Parse error: Unexpected identifier "Not". Raw body: Not Found

The /mcp panel also shows Auth: ✓ authenticated even though no Authorization header was configured — which is a separate UX bug that makes the broken Re-authenticate flow more confusing.

Why this is NOT a duplicate of #52158

  • #52158's v2.1.119 changelog entry says: "Fixed MCP HTTP connections failing…" — i.e. the connection-handshake OAuth probe.
  • The repro above is on v2.1.120, triggered by the Re-authenticate menu after the connection has already succeeded. The crash is in the OAuth-discovery code path that the /mcp menu invokes, not the connection path.
  • The customer-facing impact is identical to #52158, but the code path is different, hence the partial fix.

Claude Model

Opus

Is this a regression?

Partial regression — #52158 was advertised as fixed in v2.1.119, but the fix did not cover the Re-authenticate menu path.

Last Working Version

n/a — Re-authenticate has never worked on bearer-only MCP servers (would have to verify pre-v2.1.117 behavior).

Claude Code Version

2.1.120 (also reproduces on 2.1.119)

Platform

Anthropic API

Operating System

Linux (Ubuntu) — also reproduces on macOS

Terminal/Shell

bash / zsh

Additional Information

Cross-reference: Codex CLI (OpenAI) on the same MCP server gracefully labels auth as Unsupported instead of crashing, and a related fix shipped in modelcontextprotocol/typescript-sdk PR #1108 (merged 2025-11-13). Multiple existing issues describe the same bug class: #42716, #47424, #34008, #46640, #44774.

extent analysis

TL;DR

The Re-authenticate menu in Claude Code still throws a JSON parse crash on streamable-HTTP MCP servers that don't implement OAuth, which can be fixed by handling non-JSON responses from the OAuth discovery probe.

Guidance

  • The issue arises from the OAuth discovery code path not handling non-JSON responses correctly, leading to a JSON parse crash.
  • To fix this, the MCP SDK should be modified to treat non-JSON responses as an indication that the server does not expose OAuth metadata.
  • The Re-authenticate menu should be updated to surface a graceful error message instead of a SyntaxError stack trace when the server does not support OAuth re-authentication.
  • Verifying the fix involves testing the Re-authenticate menu on an MCP server that does not implement OAuth and checking that it displays a user-friendly error message instead of crashing.

Example

// Pseudo-code example of handling non-JSON responses
try {
  const oauthResponse = await fetch('/.well-known/oauth-protected-resource');
  const jsonData = await oauthResponse.json();
  // Handle JSON data
} catch (error) {
  if (error instanceof SyntaxError) {
    // Handle non-JSON response
    console.log('This server does not support OAuth re-authentication.');
  } else {
    // Handle other errors
  }
}

Notes

The provided fix is based on the assumption that the issue is caused by the OAuth discovery code path not handling non-JSON responses correctly. The example code snippet is a simplified illustration of how this could be addressed and may require modifications to fit the actual implementation.

Recommendation

Apply a workaround to handle non-JSON responses from the OAuth discovery probe, as the root cause of the issue is understood and a fix can be implemented to prevent the JSON parse crash.

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] Re-authenticate menu crashes with JSON parse error on bearer-only MCP servers in v2.1.120 (not covered by #52158 fix) [1 comments, 2 participants]