Bug: 100% session token drain in <20s due to Anthropic MCP proxy 502 Bad Gateway retry loop

Open 💬 0 comments Opened Jun 18, 2026 by caiohenrique02

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 executed a simple web search command. The tool hit a 502 Bad Gateway error on a connected Anthropic MCP server (claude.ai Clinical Trials via mcp-proxy.anthropic.com). Instead of failing gracefully, the CLI agent appeared to enter a rapid, invisible retry loop in the background. This consumed 100% of my session token limit in less than 20 seconds without returning any result.

What Should Happen?

When encountering an MCP 502 Bad Gateway or similar HTTP error, the CLI agent should fail gracefully and display the error to the user. It should not silently enter an endless retry loop that completely drains the user's session token quota.

Error Messages/Logs

1 MCP server not connected — run /mcp to authenticate, retry, or see details:
claude.ai Clinical Trials: failed — Streamable HTTP error: Error POSTing to endpoint: {"type":"https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/error-502/","title":"Error 502: Bad gateway","status":502,"detail":"The origin web server returned an invalid or incomplete response to Cloudflare. This typically indicates the origin is overloaded or misconfigured.","instance":"a0dc356fbbf801ad","error_code":502,"error_name":"origin_bad_gateway","error_category":"origin","ray_id":"a0dc356fbbf801ad","timestamp":"2026-06-18T18:03:06Z","zone":"mcp-proxy.anthropic.com","cloudflare_error":true,"retryable":true,"retry_after":60,"owner_action_required":true,"what_you_should_do":"**Wait and retry.** Back off for at least 60 seconds. If the error persists, the website operator should check their origin server health and configuration.","footer":"This error was generated by Cloudflare on behalf of the website owner."}

Steps to Reproduce

Steps to Reproduce*
Run Claude Code CLI on Windows.

Have a built-in MCP server connected that routes through mcp-proxy.anthropic.com which is currently experiencing an outage and returning a Cloudflare 502 error with "retryable":true.

Issue a standard prompt that triggers the agent to use the failing tool/server.

Observe the agent hanging for <20 seconds, after which it fails and reports that 100% of the session usage/tokens have been consumed.

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.179

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Windows Terminal

Additional Information

The output of /doctor shows that the mcp-proxy.anthropic.com server returned a Cloudflare 502 error. The error payload includes "retryable":true and "retry_after":60. It seems the CLI is ignoring the 60-second backoff and aggressively retrying the request in the background, causing a massive spike in token usage. The bundled search tool reported OK, so the drain is directly tied to the MCP connection failure.

View original on GitHub ↗