Claude Code MCP Unauthorized? Reauthenticate One Session

Claude Code MCP Unauthorized? Reauthenticate One Session

Aident AI

A cyan ribbon passes through a luminous coral ring while a violet ribbon curls back from the same opening.

Claude Code MCP Unauthorized? Reauthenticate One Session

If a remote MCP server suddenly returns Unauthorized after two Claude Code sessions start together, stop the overlapping Claude processes, keep one interactive session open, and reauthenticate that server once. In Claude Code, run /mcp, select the affected server, and choose Re-authenticate. From a terminal, the equivalent command is:

claude mcp login <server-name

This restores the current connection. It does not permanently fix a client-side refresh race, so verify one read-only request before restarting other sessions.

Do not edit Claude's credential files, paste tokens between machines, or repeatedly log every process back in at the same time. Those actions can recreate the race or expose a reusable secret.

Confirm the Concurrent Refresh Signature

The strongest signature is not simply an MCP login failure. It is a server that worked, followed by an access-token refresh while multiple Claude Code processes were active.

Look for these conditions:

  1. The same remote MCP server is configured in two or more Claude Code sessions, scheduled jobs, terminal tabs, or headless processes.

  2. The sessions start or resume close together.

  3. One session reconnects, while another reports Unauthorized, HTTP 401, invalid_grant, or a rejected refresh token.

  4. Reauthenticating restores access temporarily, but the error returns when concurrent sessions resume.

On macOS or Linux, use a read-only process listing to find overlapping Claude processes:

ps -Ao pid,ppid,etime,command | grep -E '[c]laude'

On Windows, check Task Manager for multiple Claude Code processes and any scheduled task that launches Claude. Close sessions normally after saving their work. Do not terminate an unknown process just because it contains claude in its command line.

Observation

More likely cause

Next step

One server fails just after concurrent sessions resume

Refresh-token race

Keep one session, reauthenticate once, then test one read-only request

Every server fails before the browser ever reaches authorization

Callback, proxy, or redirect configuration

Use the MCP OAuth callback guide

A server always requires a fresh login in one environment

Credential storage or scope mismatch

Compare the server configuration and supported auth flow without copying tokens

A headless session cannot open the browser

Interactive authorization is unavailable

Use the documented --no-browser login flow from one terminal

Reauth works until a second long-running process starts

Recurring coordination problem

Give one process ownership of the rotating credential or use a provider-supported alternative

Why One Refresh Can Invalidate Every Session

OAuth access tokens are intentionally short-lived. A refresh token lets a client obtain a new access token without asking the user to authorize again. Current MCP security guidance recommends refresh-token rotation for public clients: after a successful refresh, the authorization server returns a replacement refresh token and retires the one that was just used.

That is safe when one client owns the sequence. It can fail when two independent processes read the same stored token:

  1. Process A and process B both load refresh token R1.

  2. Process A exchanges R1 and receives R2.

  3. Process B sends the now-retired R1.

  4. The authorization server rejects the stale token and may revoke the token family as a reuse defense.

  5. Other sessions that shared the family begin returning Unauthorized.

Anthropic issue 85236 reports this exact MCP pattern in Claude Code 2.1.222 and 2.1.226: concurrent processes started within seconds, one refresh succeeded, another received invalid_grant, and every session needed authorization again. A separate, older Claude account OAuth issue collected independent reports of similar multi-process refresh failures across macOS, Linux, and Windows. The older issue concerns Claude account OAuth rather than MCP OAuth, so it is corroborating evidence for the concurrency pattern, not proof that both paths use the same implementation.

Recover the MCP Connection Safely

1. Pause new launches

Temporarily pause scheduled jobs, background agents, and scripts that start Claude Code. Save work in interactive sessions, then close all but one normally. The objective is to leave one process capable of owning the next refresh.

2. Identify the affected server

List configured MCP servers:

claude mcp list

Record the exact server name and connection state. Do not log out unrelated servers.

3. Reauthenticate from one session

In the remaining interactive Claude Code session, run:

/mcp

Select the affected server and choose Re-authenticate. Anthropic's current documentation says Claude Code points users to this flow when a rejected token needs fresh authorization.

You can instead use the CLI:

claude mcp login <server-name

For an SSH session where the remote machine cannot open a browser, use the documented device-style flow:

claude mcp login <server-name> --no-browser

Complete that flow in one place. Do not run the login command simultaneously in every terminal.

4. Verify a read-only request

Check the server state again, then make one harmless read-only request through the server. Success means the server shows connected and the read succeeds without another authentication prompt.

If the request is still unauthorized, confirm that no scheduled process restarted Claude during the login. Close the extra process normally and repeat the single-session reauthentication once. Avoid clearing all Claude state or deleting credential directories.

5. Restart only the sessions you need

Restart other sessions gradually. If the next token refresh invalidates them again, treat the single-session procedure as a recovery, not a durable fix. Preserve the Claude Code version, server name, operating system, sanitized error, and timing between process starts for an upstream report.

Reduce Recurrence in Long-Running Workflows

Until Claude Code coordinates refreshes across processes, avoid giving many long-lived processes ownership of the same rotating MCP credential.

Practical boundaries include:

  • Keep one persistent Claude process responsible for the remote MCP connection and serialize work that depends on it.

  • Stagger scheduled Claude launches so they do not all resume and refresh together.

  • Prefer a provider-supported non-OAuth credential only when the provider officially offers it and your secrets manager can inject it without exposing the value.

  • Do not convert a managed OAuth connection to a copied API key merely to hide the symptom. The API key versus OAuth guide explains the security tradeoff.

  • Update Claude Code when Anthropic ships a release that explicitly addresses the issue, then repeat the concurrent-session test before removing the boundary.

There is no evidence in the cited reports that deleting project files, reinstalling every MCP server, or editing stored token JSON repairs the coordination problem.

Check the Connection Without Exposing Credentials

Aident Loadout can inspect connection readiness and preflight a read-only Action while keeping provider credentials in Vault.

Start with this setup phrase:

Follow https://aident.ai/SETUP.md

Then ask:

Check Aident Loadout authentication and Vault status. Search the staging capability catalog for the current read-only Action backed by my affected service, inspect its schema, and preflight one minimal read. If the input is valid and the estimate is free, execute it and return only the connection result and non-sensitive response fields. Do not write, reconnect, disconnect, reveal tokens, or bypass the integration layer.

Success is measurable: Vault reports the intended connection ready, the preflight is valid, one read-only request succeeds, and no credential appears in the prompt or output.

Set up Aident Loadout and verify an MCP-backed connection.

Sources

Refresh this guide when Anthropic closes issue 85236 with a released fix, changes the /mcp reauthentication flow, or documents cross-process refresh coordination.

Home

Home

Home

Integrations

Integrations

Integrations

Vault

Vault

Vault

Audit

Audit

Audit

Arana Grande

Arana Grande

Arana Grande

Free

Free

Free

30-day audit summary

30-day audit summary

30-day audit summary

Daily action-call volume and the latest receipts from the Loadout audit trail.

Daily action-call volume and the latest receipts from the Loadout audit trail.

Daily action-call volume and the latest receipts from the Loadout audit trail.

View Audit

View Audit

View Audit

Loadout usage

Loadout usage

Loadout usage

617 action calls in the last 30 days

617 action calls in the last 30 days

617 action calls in the last 30 days

May 19 - Jun 17

May 19 - Jun 17

May 19 - Jun 17

10 active days

10 active days

10 active days

Less

Less

Less

More

More

More

Recent activity

Recent activity

Recent activity

Latest action-call receipts from connected agents

Latest action-call receipts from connected agents

Latest action-call receipts from connected agents

Apr 23, 09:23 AM

Apr 23, 09:23 AM

Apr 23, 09:23 AM

Shopify

Shopify

Shopify

Creates Or Updates An Asset For A Theme

Creates Or Updates An Asset For A Theme

Creates Or Updates An Asset For A Theme

Success

Success

Success

Apr 23, 09:21 AM

Apr 23, 09:21 AM

Apr 23, 09:21 AM

Shopify

Shopify

Shopify

Update Products Param Product Id

Update Products Param Product Id

Update Products Param Product Id

Success

Success

Success

Apr 23, 08:53 AM

Apr 23, 08:53 AM

Apr 23, 08:53 AM

Shopify

Shopify

Shopify

Update Products Param Product Id

Update Products Param Product Id

Update Products Param Product Id

Failed

Failed

Failed

Apr 22, 22:13 PM

Apr 22, 22:13 PM

Apr 22, 22:13 PM

Shopify

Shopify

Shopify

Create Product Image

Create Product Image

Create Product Image

Success

Success

Success

Apr 22, 22:12 PM

Apr 22, 22:12 PM

Apr 22, 22:12 PM

Shopify

Shopify

Shopify

Create Product Image

Create Product Image

Create Product Image

Success

Success

Success

Connected integration coverage

Connected integration coverage

Connected integration coverage

162

162

162

of 753 accessible connected

of 753 accessible connected

of 753 accessible connected

Callable actions

Callable actions

Callable actions

1,126

1,126

1,126

Vault credentials

Vault credentials

Vault credentials

8

8

8

Explore what's possible

Explore what's possible

Explore what's possible

See all Integrations

See all Integrations

See all Integrations

Google Ads

Google Ads

Google Ads

All available Goolge Ads tools via...

All available Goolge Ads tools via...

All available Goolge Ads tools via...

X (twitter)

X (twitter)

X (twitter)

All available X tools via...

All available X tools via...

All available X tools via...

Github

Github

Github

All available Github tools via...

All available Github tools via...

All available Github tools via...

Notion

Notion

Notion

All available Notion tools via...

All available Notion tools via...

All available Notion tools via...

Slack

Slack

Slack

All available Slack tools via...

All available Slack tools via...

All available Slack tools via...

Firecrawl

Firecrawl

Firecrawl

All available Firecrawl tools via...

All available Firecrawl tools via...

All available Firecrawl tools via...

753 integrations are available for loadouts.

753 integrations are available for loadouts.

753 integrations are available for loadouts.

The one tool

for every tool

your agent needs.

Give any AI agent real capabilities in seconds. Connect 1,000+ tools once, skip the setup headache, and let your agents execute.

Try Aident Loadout

Give your Agent real capabilities in minutes. Connect 1,000+ tools, and let your agents execute.

Try Aident Loadout

Give your Agent real capabilities in minutes. Connect 1,000+ tools, and let your agents execute.

Try Aident Loadout

Give your Agent real capabilities in minutes. Connect 1,000+ tools, and let your agents execute.