2026 MCP HTTP 401: Check the OAuth Discovery Chain First

A remote MCP connector receives HTTP 401 and never opens a login flow.

Fastest fix: inspect WWW-Authenticate and the Protected Resource Metadata it points to, then verify authorization-server discovery, client registration, and token validation. A 401 can be a normal OAuth challenge; it is not proof that every 401 is healthy.

This guide is for developers maintaining self-hosted MCP over HTTP and teams diagnosing a connector that stops at 401.
If the service uses stdio, follow its environment-credential path instead; the HTTP OAuth discovery chain does not apply.

Last reviewed November 19, 2026, against the MCP authorization tutorial, the authorization-server discovery specification, and the client-registration specification.

Start by separating an authorization challenge from an outage

An HTTP 401 says the request did not satisfy the endpoint’s authentication requirements. In an OAuth-protected MCP service, the response can also tell a client how to begin authorization. The distinction matters: a server can be reachable and working while the client has not discovered, obtained, or sent a suitable token.

Do not treat a successful TCP connection, a browser page, or a generic health check as proof that MCP authorization works. A health endpoint may be public while the MCP route requires a bearer token. Conversely, a 401 from the protected route may be the expected first response when an unauthenticated client asks for a resource.

Check the transport before following any protocol instructions:

  • Remote MCP over HTTP: inspect the HTTP response and follow its authorization challenge and metadata links.
  • MCP over stdio: check the process environment, credential injection, and local launcher configuration. There is no HTTP WWW-Authenticate response to follow in that path.

For a service exposed through a reverse proxy, compare the response from the public URL with the upstream response. This separates an MCP server’s behavior from proxy rules that might remove headers, rewrite paths, or send requests to the wrong backend. If the service has a separate health endpoint, keep its contract distinct from the protected MCP route; the guide to HTTP health-check response contracts can help prevent an authentication challenge from being misread as a health-check failure.

Read the challenge before changing OAuth settings

The first useful evidence is the raw response from the MCP endpoint. Record the status, response headers, and a redacted response body. In particular, inspect WWW-Authenticate. The MCP authorization tutorial describes how an HTTP client can use the challenge to discover authorization metadata and continue the flow.

A quick request can expose the headers without printing credentials:

curl -sS -D - -o /dev/null https://mcp.example.invalid/mcp

The example domain is intentionally fictional. This request sends no bearer token. Do not add a real token to a command that may be saved in shell history or copied into a ticket.

Check whether the challenge is present, whether it identifies the bearer authentication scheme, and whether it includes a resource-metadata location. Then compare the header at the public edge with the response from the upstream service. A proxy can leave the status untouched while stripping or replacing the challenge, which makes a reachable service look impossible for a client to authorize.

What should the WWW-Authenticate header contain?

The client needs enough information to begin the discovery path. If the header is absent, malformed, or points to an unexpected metadata location, the connector may have no way to find the resource’s authorization requirements. A login page appearing in a browser does not replace a usable protocol challenge.

If the endpoint returns 401 but there is no usable challenge, investigate the server’s authentication middleware and proxy response handling before changing identity-provider settings. Those settings cannot repair a discovery hint that never reaches the client.

Use the symptom to choose the next check

Observed behavior Most likely area to inspect Next diagnostic action
The client stops at 401 and shows no authorization step Missing or unusable challenge; client cannot read metadata Compare WWW-Authenticate at the public edge and upstream, then request the referenced metadata directly
The metadata URL returns 404 or non-JSON content Incorrect well-known path, proxy routing, or an intercepted response Check the exact path, status, content type, and response body from a public network
The client reaches authorization but the callback or token exchange fails Authorization-server metadata, client registration, redirect handling, or issuer mismatch Compare advertised endpoints and issuer values with the client’s configured values
Authorization completes, but MCP calls still return 401 or 403 Missing token, wrong resource audience, insufficient scope, or altered authorization header Verify the request’s Authorization header and token claims without disclosing the token
Direct upstream calls work but public calls fail Reverse-proxy rules, TLS termination, redirects, or path rewrites Compare request and response headers across the proxy boundary

Treat this as a triage aid, not a diagnosis by status code alone. The same visible 401 can occur at different points in the flow. Capture the response at each boundary and follow the evidence to the first point where it diverges.

Follow Protected Resource Metadata to the right server

Protected Resource Metadata tells a client which authorization servers protect a resource and how to identify that resource. The path and the advertised resource value both matter. A document that exists but describes a different MCP URL can send a client into a valid OAuth flow for the wrong resource.

Request the metadata URL indicated by the challenge from outside the host’s private network. Confirm that the response is reachable without credentials, is valid JSON, and describes the MCP resource the client actually calls. Compare scheme, host, port, and path carefully. A mismatch can result from a public URL that differs from the internal upstream URL, or from a proxy prefix that is added or removed.

Why does the discovery document return 404?

First check whether the client requested the exact well-known path associated with the resource URL. Then check whether the web server, container router, or proxy sends that path to the MCP service instead of a frontend fallback or unrelated backend. A 404 from the application and a 404 generated by the proxy may look similar to the client, but they point to different fixes.

Also inspect redirects and content negotiation. A proxy might redirect the metadata request to a login page, or an application might return an HTML error page with a misleading success status. The client needs the metadata document, not an interactive page. Test the path as an unauthenticated request and inspect the actual status, content type, and body.

Use the official MCP authorization tutorial and resource discovery requirements to check the expected discovery flow. Do not infer that a particular path is correct just because a similar path works for another service.

Verify authorization-server discovery and client registration

Once the resource metadata is readable, follow its authorization_servers entries. Request the authorization-server metadata at the applicable well-known location and compare the advertised issuer, authorization endpoint, token endpoint, and supported capabilities with the client’s expectations.

The issuer value is especially important. A mismatch between the issuer the server advertises and the issuer associated with the token can cause a client or resource server to reject an otherwise valid-looking flow. Check for differences introduced by TLS termination, internal hostnames, trailing paths, or public URL configuration. Do not “fix” a mismatch by disabling issuer validation; correct the metadata or deployment configuration instead.

Client registration is another compatibility boundary. The MCP authorization specification dated July 28, 2026, marks Dynamic Client Registration as deprecated and asks implementers to evaluate Client ID Metadata Documents. That is a specification change, not a guarantee that every client and server already supports the same registration method. Verify the current MCP client-registration rules against the exact client and server versions in use before changing registration behavior.

The linked OAuth 2.1 document is a draft, so treat it as draft guidance rather than a final standard. Its current status and language should be checked before using it to settle an implementation dispute. MCP-specific requirements remain the primary reference for the MCP discovery path.

Diagnose the failures that remain after login

A completed login does not prove that the MCP request carries an acceptable token. Check the request sent to the MCP resource, not only the browser callback or identity-provider logs. Confirm that the request includes the bearer authorization header and that an intervening proxy does not remove it.

Then verify that the token is intended for this resource. The resource indicators specification explains how a client can identify the protected resource for which it requests a token. A token issued for a different API is not interchangeable simply because the same identity provider created it. Review the token audience and granted permissions using safe tooling. Do not paste a live token into a decoder website, issue tracker, chat, or shell command that stores it in history.

The bearer-token specification describes bearer-token use and the role of the authorization header. It also provides a useful reference when distinguishing an absent credential from a token that the resource server does not accept. Keep the exact rejection reason in server-side diagnostics where possible, but redact token values, authorization codes, client secrets, and refresh tokens.

Credential safety: log whether an authorization header was present and which validation stage failed. Never log its value. If a secret has already entered logs or a support ticket, treat it as exposed and rotate it.

Redirects deserve a separate check. If a client sends a request with an authorization header to one host and is redirected to another, client behavior may differ. A proxy can also terminate TLS, redirect between paths, or forward a request without preserving the header. Compare the request at the public edge with what reaches the upstream service. Do not assume that a successful browser redirect proves the MCP client will forward credentials in the same way.

Run an external acceptance check before closing the incident

Use a public network path that resembles the client’s route. Keep the checks separate so the first broken boundary is visible.

  • Request the MCP endpoint without credentials. Record the status and the complete, redacted WWW-Authenticate header.
  • Fetch the indicated Protected Resource Metadata directly. Confirm that the response is accessible, valid JSON, and describes the same public MCP resource.
  • Follow the advertised authorization-server metadata. Check the issuer and endpoint values against the client’s configured discovery and registration behavior.
  • Complete authorization using the intended client. Confirm that the client obtains a token for the MCP resource rather than a different API.
  • Call a controlled, low-impact MCP tool. Confirm that the request carries authorization and that the service accepts it.
  • Repeat the public-path test through the reverse proxy. Compare the challenge, metadata response, redirect behavior, and forwarded authorization header with the direct upstream path.

A useful incident record names the failing boundary and the correction: for example, “the proxy removed the challenge header,” “the metadata path routed to the frontend,” or “the token was requested for another resource.” Avoid recording secret values. This record makes regressions easier to detect when a proxy, client, identity provider, or MCP implementation changes.

Choose an operating model after authorization works

OAuth troubleshooting is separate from server capacity planning. A 401 does not, by itself, indicate that a larger machine is needed. First confirm the discovery and token path. Then assess whether the service needs to remain online, whether its data should stay under the team’s control, and who will maintain its operating system, containers, backups, and access boundaries.

A lightweight test or a service used only during development may fit a local process or a small shared environment. A long-running remote MCP endpoint can be a better fit for a dedicated AMD physical server when the team needs an exclusively allocated machine and control over its deployment environment. Shared hosting can have neighbor contention, provider-managed limits, and less control over the underlying system. A dedicated server also brings direct operational responsibility: patching, monitoring, backup design, and secure credential handling remain with the operator.

For a service expected to stay online, compare the current hosting arrangement with the actual operational requirements before migrating. NodeAMD’s server options are worth reviewing only after the authorization chain works and the team has decided that a dedicated operating environment fits its maintenance capacity. Check the current product page for the available systems and terms; this article does not assume a particular server configuration or promise that hosting alone will fix an OAuth failure.

NodeAMD EPYC 7543P dedicated server, from $439/month

Configure a dedicated server with NodeAMD View NodeAMD rental pricing

From reading to server planning

Compare configurations, options, and billing to choose the right host for self-managed services.