Fixes › Claude Code, Cursor, Claude Desktop, VS Code, Codex, Gemini CLI

Remote MCP server says "Needs authentication" or 401 after it used to work

Claude CodeCursorClaude DesktopVS CodeCodexGemini CLI

The error

Needs authentication • Needs login • 401 Unauthorized • invalid_grant / invalid client after an update

Why it happens

Hosted MCP servers (Linear, Atlassian, Notion, Vercel, Sentry and others) sign you in with OAuth and keep a token on your computer. Tokens expire, get revoked, or stop matching when the provider changes its endpoint or client registration. Atlassian, for example, notes that some clients need cached client IDs cleared after its move to the v2 endpoint. The fix is to throw away the old sign-in and sign in again.

How to fix it

  1. Sign in again from your app
    Claude Code: /mcp, pick the server, then Clear authentication and authenticate again. Cursor: click Needs login in Customize. Codex: codex mcp login NAME. Gemini CLI: /mcp auth NAME. Devin Desktop: Authenticate on the server.
    codex mcp login linear
    # Gemini CLI, inside the app:
    /mcp auth linear
  2. If you use mcp-remote, clear its saved credentials
    mcp-remote stores tokens in ~/.mcp-auth. Deleting it forces a fresh sign-in the next time your app starts the server.
    rm -rf ~/.mcp-auth
  3. Check the URL is current
    Providers move endpoints. Atlassian recommends https://mcp.atlassian.com/v2/mcp; Linear's is https://mcp.linear.app/mcp. Old /sse URLs are being retired (details).
  4. Claude Code: update first
    Claude Code 2.1.323 (November 12, 2026) fixed MCP tool calls failing with the sign-in server's error (such as TOKEN_EXPIRED) instead of asking you to sign in again. Claude Code 2.1.325 (November 13, 2026) fixed a server staying on "needs authentication" after a token refresh was refused only for a moment. Claude Code 2.1.327 (November 17, 2026) fixed remote servers staying disconnected after a longer outage such as a VPN drop: most remote servers reached over https are now retried in the background for about a day. Claude Code 2.1.329 (November 19, 2026) fixed claude mcp login and /mcp saying a service doesn't accept sign-ins from Claude Code when the service had retired its client registration (HTTP 410 Gone), and fixed a server signing in again after you cleared its authentication while a token refresh was running. Since 2.1.329, a remote server's page in /mcp also shows a Server message row with the error the server sent when it refused the connection. Run claude --version and update before clearing your sign-in.
    claude update
  5. Codex: update to 0.170.0 or later
    Codex 0.170.0 (November 18, 2026) fixed MCP OAuth sign-ins getting mixed up when a login, logout or cancellation happened at the same time as a token refresh. Codex 0.171.0 (November 19, 2026) fixed enterprise MCP sign-in with identity providers that issue ID tokens without refresh tokens. Update Codex, then run codex mcp login NAME again if the server still says it needs sign-in.
    codex --version
  6. Using an API key instead?
    Some servers accept a key in a header instead of OAuth. Make sure the key hasn't expired and the header is spelled exactly as the provider shows, usually Authorization: Bearer YOUR_KEY.

Related servers

Sources