Authentication · troubleshooting record
Remote MCP server returns HTTP 401 Unauthorized
The remote server did not receive valid credentials. A 401 is an authentication result, not proof that the URL is wrong. The fix is to identify which credential the endpoint expects and whether the client actually attached it.
Symptoms
- Remote MCP server shows 401 Unauthorized.
- Tools fail to load while the endpoint responds to unauthenticated requests.
- A curl command with a token works, but the client connection does not.
Confirmed causes
These causes have a documented basis. They may not be the cause of your specific failure.
The token is missing, expired, or scoped to a different account
MCP remote servers commonly authenticate with bearer tokens or headers; an absent or invalid token yields 401.
The credential is in a header the server does not read
Providers may expect Authorization: Bearer, a custom API-key header, or an OAuth flow rather than a static header.
Environment variable substitution did not happen
A literal ${TOKEN} sent as the header value is not a valid token and produces 401.
Possible causes
- OAuth authorization was never completed or was revoked.
- The token's organization or project scope does not include the resource.
- A proxy strips the Authorization header.
- The server expects a different authentication scheme.
What still needs verification
- The provider's documented auth header and token type.
- Whether the client expands the placeholder syntax used in the config.
- The token's scopes and expiry date.
Affected environments
Fixes
Reproduce authentication outside the client
- Send a request to the endpoint with curl and the exact header the docs specify.
- If curl fails, fix the token or scope before touching the client.
- Avoid sharing the token in terminal history or logs.
Attach credentials in the client's supported form
- Use the client's documented header field or OAuth flow.
- Use a placeholder syntax the client actually expands, such as ${VAR} or ${env:VAR} per its docs.
- Restart the client after updating secrets.
Verify the fix
- The endpoint accepts the credential from the client host.
- The client completes initialization without a 401.
- The tool list loads with the expected permissions.
Paste the configuration into the Config Doctor. It runs in your browser, never uploads the file, and can show structural issues and safe fixes.
Why we believe this
- code.claude.com/docs/en/mcpOfficial documentation · checked Oct 23, 2026 · documented
Claude Code documents remote server headers and environment expansion for authentication.
- cursor.com/docs/mcpOfficial documentation · checked Oct 23, 2026 · documented
Cursor documents headers and ${env:VAR} interpolation for remote server authentication.