MCP server needs authentication in Claude Code: how to fix
Claude Code flags an MCP server as needing authentication after a 401 or 403 it can't clear. How to sign in again, and when an API key fits better.

In Claude Code, a remote MCP server "needs authentication" when it answered 401 Unauthorized or 403 Forbidden and Claude Code could not clear that with a stored OAuth token. Fix it by signing in: run /mcp in a session and follow the browser steps, or run claude mcp login <name> from your shell. With Sume's hosted MCP server, check two things first: whether you finished the sign-in, and whether the access token has expired, since in current code it lasts one hour and Sume issues no refresh token.
Claude Code's behavior comes from its MCP docs, read on 2026-09-27, and it changes between versions. Sume's side comes from the MCP quickstart and OAuth and API keys, plus current server code for token lifetimes. Sume's basics page says hosted MCP still works but is not the primary integration path today.
Why does Claude Code say a server needs authentication?
It depends on the status code and on how you connected the server:
| What happened | What Claude Code does |
|---|---|
401 or 403 from a server you haven't signed in to | Flags it in /mcp so you can complete the OAuth flow |
401 from an OAuth server you already signed in to | Refreshes the stored token and retries once; flags the server only if that retry also fails |
| The server rejects the stored refresh token | Shows a notice pointing at /mcp, where Re-authenticate signs you in again |
403 insufficient_scope on a tool call | Fails the call with a needs additional permissions message; the server shows as needing authentication |
A rejected Authorization header you configured | Reports a failed connection and does not fall back to OAuth |
Sign-in needed during claude -p or an Agent SDK run | Tells Claude the server's tools are unavailable until you authorize it, when tool search is on (the default) |
Why does Sume's server keep asking me to sign in?
- You added it but never signed in.
claude mcp addwrites the configuration; signing in is a separate step. In current code, Sume answers a request without a token with a401that points to its OAuth metadata, so run the quickstart's second command,claude mcp login sume. - Your token expired. In current code, a Sume MCP access token lasts one hour and the token response carries no refresh token, so the refresh Claude Code tries first cannot succeed. An expired or revoked token gets the same
401as a missing one. The flow itself is covered in MCP server OAuth flow on Sume.
How do I sign in again?
- In a session: run
/mcpand follow the steps in your browser. If the redirect fails after you sign in, paste the full callback URL from the address bar into the prompt Claude Code shows. - From your shell:
claude mcp login sume. Over SSH it prints the authorization URL instead of opening a browser; open it on your own machine, then paste the redirect URL back. Connect withssh -t, and pass--no-browserto force that prompt. - On Sume's consent page, Read is locked on and Write is off by default. Turn Write on only if Claude should run write or paid tools; a read-only token gets
insufficient_scopeon them. Current Sume code returns that inside a failed tool result, not as an HTTP403, so it is a permissions problem, not an expired sign-in: runclaude mcp logout sume, then log in again with Write on. Fix MCP insufficient_scope on Sume covers the other fixes. - Check with
claude mcp list, which should show the server as connected, then ask Claude to callmcp_healthortools_list.
What should I use for claude -p and CI?
An API key. In non-interactive mode there is no /mcp panel, so Claude Code can't run the OAuth flow for you, and in current code a Sume token lasts only an hour anyway. Sume keeps API-key remote MCP for automation: send the key as Authorization: Bearer or as x-api-key, not both (current code refuses a request that carries both), and the session sees the full hosted tool set, write and paid tools included. Keep the key in your CI secret store; never paste it into chat.
claude mcp add --transport http sume https://mcp.sume.com/mcp \
--header "Authorization: Bearer $SUME_API_KEY"What changes once a key header is set?
A rejected key now shows as a failed connection rather than as needing authentication, and Claude Code does not fall back to OAuth; check the key, or remove the header to sign in with OAuth instead. Switching an existing entry either way takes a remove first: claude mcp add with a name that already exists at the same scope fails, and claude mcp remove sume also deletes the OAuth tokens Claude Code stored for it. The rest of the setup is in Connect Claude Code, Cursor, or Codex to Sume.
Sources
Related posts
More in Developers
- MCP tool annotations: readOnlyHint and how clients use them
MCP tool annotations are optional hints such as readOnlyHint. What each one means, its default, and how ChatGPT, VS Code, and Copilot use them.
- Python image generation API: generate and save AI images
Generate images from Python with Requests: POST a prompt to an image API, read the URLs from a 200 or poll the 202 job, then save each file.
- Speech to text API in JavaScript: audio to text in Node.js
Call a speech to text API from JavaScript on your server: send the audio file's URL with the Sume SDK in Node.js, wait for the job, read the text.
- Speech to text in Python: transcribe audio with timestamps
Speech to text in Python with Requests: send the audio URL, poll the job, then read the transcript and word timestamps. A script for Sume STT 1.0.
Written by Sume