MCP OAuth "Registration failed: 404", "does not support dynamic client registration" and "Token exchange failed"

By MV2 of Munim, Inc., with AI agents. Written on 13 November 2026 from the source of the MCP Python SDK (mcp v2.1.1, v2.2.0, v2.3.0 and v1.30.0) and the MCP TypeScript SDK (1.32.2), plus the issues linked below. Read from the source, not run. See the limits.

You add a remote MCP server that needs a login. Before a browser window ever opens, or right after you approve access, the client stops with one of these:

OAuthRegistrationError: Registration failed: 404 {"detail":"Not Found"}
OAuthRegistrationError: Registration failed: 307 (redirected to https://…/register; not followed) …
Incompatible auth server: does not support dynamic client registration
HTTP 404: Invalid OAuth error response: SyntaxError: … Raw body: <!DOCTYPE html>…
Authorization server registered the client for 'client_secret_basic' but issued no client_secret
OAuthTokenError: Token exchange failed (401): {"error":"invalid_client", …}

The first four happen at client registration: before an MCP client can send you to a login page, it needs a client_id. If it has none stored, it tries to get one by Dynamic Client Registration (DCR, RFC 7591): a POST of its own name and callback URL to the authorization server's registration_endpoint. Many big providers don't offer DCR at all and expect you to create an OAuth app in their console and give the client that app's client_id and client_secret. The last one happens after you log in, when the client trades the code for a token.

The short answer

You seeMost likely meaningFix
Registration failed: 404 (Python SDK) or Incompatible auth server: does not support dynamic client registration (TypeScript SDK)The authorization server has no DCR, or the client couldn't read its metadata and guessed a /register URL that doesn't exist. See where the request goes.Get a client ID and secret from the provider and give them to the client (how), or fix the server's metadata if it's yours.
Registration failed: 307 / 302 / 308 (redirected to …; not followed)The registration URL redirects somewhere else. Python mcp 2.2.0 and 1.30.0 (7 September 2026) and later follow redirects only on the same origin, in the login steps too.Point the metadata's registration_endpoint straight at the final URL. See MCP "Redirect to … not followed".
Registration failed: 400 with invalid_redirect_uri or invalid_client_metadataThe server has DCR but refuses what the client asked for, usually its callback URL (for example only approved redirect URIs are allowed).Allow the client's callback URL on the server, or pre-register a client.
Registration failed: 401 / 403Registration needs an initial access token, or a firewall or WAF blocks it.Pre-register a client, or allow the request on the server.
Authorization server registered the client with unsupported token_endpoint_auth_method … or … for 'client_secret_basic' but issued no client_secretRegistration worked, but the server answered with a client the Python 2.x SDK can't use, for example private_key_jwt, or a secret-based method with no secret.Fix the server's registration answer, or pre-register a client.
Token exchange failed (401) / (400) with invalid_client, or (422) asking for client_secretLogin worked, but the client didn't send its secret the way the token endpoint wants it.For a pre-registered client in Python, set token_endpoint_auth_method (why).

Where the registration request really goes

This is the part most reports miss. The URL in a 404 is often not where the provider takes registrations; it is a guess the SDK made.

SituationPython SDK, OAuthClientProvider (2.1.1 to 2.3.0 and 1.30.0)TypeScript SDK 1.32.2
Authorization-server metadata found, has registration_endpointPOSTs to that URLPOSTs to that URL
Metadata found, no registration_endpoint (the provider has no DCR)POSTs anyway, to /register on the MCP server's own origin (urljoin(fallback_base, "/register"), where fallback_base is built from server_url). Usually a 404, often an HTML page.Sends nothing and throws Incompatible auth server: does not support dynamic client registration
No metadata could be read (every well-known URL failed)The same guess: /register on the MCP server's origin/register on the authorization server URL it has

So with the Python SDK, a provider whose MCP server is mcp.example.com and whose login lives on auth.example.com can produce POST https://mcp.example.com/register → Registration failed: 404, which looks like a broken MCP server but really means "no DCR" or "metadata not readable". That pattern shows up in real reports: HubSpot (agor#1957: its metadata lists no registration_endpoint, and mcp.hubspot.com/register answers with a 404 HTML page), Google-hosted MCP servers (unsloth#7653), and TradingView in Hermes Agent, where the advertised endpoint was on another host (hermes-agent#113771, which first worked out the guessed URL; the reporter later found the app's own code path also played a part). The 307 case was call-e-integrations#155: it worked on mcp 2.1.1, failed on 2.2.0 with Registration failed: 307 (... not followed), and was fixed by serving the metadata where clients look for it so the client went straight to the real endpoint.

Check it yourself in one minute

# 1. Which authorization server does the MCP server name? (path form first, then root)
curl -s https://mcp.example.com/.well-known/oauth-protected-resource/mcp
curl -s https://mcp.example.com/.well-known/oauth-protected-resource

# 2. Does that authorization server offer DCR?
curl -s https://auth.example.com/.well-known/oauth-authorization-server | grep -o '"registration_endpoint":"[^"]*"'
curl -s https://auth.example.com/.well-known/openid-configuration      | grep -o '"registration_endpoint":"[^"]*"'

Use a pre-registered client instead

Both SDKs skip registration when they already have client information. Create an OAuth app in the provider's console, add your client's callback URL there, and hand the client its ID and secret.

Python mcp 2.x: the provider reads it from your TokenStorage. Return it from get_client_info():

from mcp.client.auth import OAuthClientProvider, TokenStorage
from mcp.shared.auth import OAuthClientInformationFull, OAuthToken

class PreRegisteredStorage(TokenStorage):
    def __init__(self):
        self.tokens: OAuthToken | None = None

    async def get_tokens(self):
        return self.tokens

    async def set_tokens(self, tokens):
        self.tokens = tokens

    async def get_client_info(self):
        return OAuthClientInformationFull(
            client_id="YOUR_CLIENT_ID",
            client_secret="YOUR_CLIENT_SECRET",          # read it from an env var, not source
            token_endpoint_auth_method="client_secret_post",  # or "client_secret_basic"; see below
            redirect_uris=["http://localhost:3030/callback"],
        )

    async def set_client_info(self, client_info):
        pass

Leave issuer unset. Since the SEP-2352 issuer binding in 2.x, stored credentials with no issuer are treated as having "no binding to enforce" and are reused as they are; credentials bound to a different issuer are thrown away and the client registers again.

TypeScript SDK: return the same fields from your OAuthClientProvider's clientInformation(). If clientInformation() returns nothing and the provider has no saveClientInformation, 1.32.2 throws OAuth client information must be saveable for dynamic registration.

Apps built on the SDKs need their own setting for this. Some have added one after exactly these reports (for example unsloth#7665, swarms#3223); others are still asking (vscode#257415, codex#19154, claude-code#3273). Check your client's docs for a client ID option before writing code.

A third way, if the server supports it: Client ID Metadata Documents. When the authorization server's metadata says client_id_metadata_document_supported: true and you give the client a client_metadata_url (HTTPS, with a path), both SDKs use that URL as the client_id and skip DCR.

"Token exchange failed" after you log in

The two SDKs differ when a client has a secret but no token_endpoint_auth_method:

SDKClient has a secret, method not set
Python mcp (2.3.0, 1.30.0)Sends no secret. Only client_secret_basic (HTTP Basic header, ID and secret URL-encoded first) and client_secret_post (form fields) add it; anything else, including a missing method, is treated as a public client. A confidential client then gets Token exchange failed (401) with invalid_client, or a provider-specific message such as Required parameter: client_secret (hermes-agent#29680).
TypeScript 1.32.2Picks one from the server's token_endpoint_auth_methods_supported; if the server lists none, it uses client_secret_basic when there is a secret and none when there isn't.

So when you pre-register a confidential client for the Python SDK, set token_endpoint_auth_method to the method the provider expects. If one method gives invalid_client, try the other: some servers only accept form fields, some only the Basic header.

Exact messages by version

PackageMessage
Python mcp 2.1.1Registration failed: {status} {body} and Token exchange failed ({status}): {body}
Python mcp 2.2.0, 2.3.0, 1.30.0Registration failed: {status}{note} {body} and Token exchange failed ({status}){note}: {body}, where {note} is (redirected to {location}; not followed) for a redirect it refused and empty otherwise. Only 200 and 201 count as a successful registration.
Python mcp 2.1.1 to 2.3.0 (not in 1.30.0)Authorization server registered the client with unsupported token_endpoint_auth_method {method!r}; Authorization server registered the client for {method!r} but issued no client_secret (check_registration_usable, run before the browser opens)
TypeScript 1.32.2Incompatible auth server: does not support dynamic client registration. For a failed registration or token request with a JSON OAuth error, an error class named after the error code (InvalidClientMetadataError, InvalidClientError, …) whose message is only the error_description, which may be empty, and no status. With any other body, HTTP {status}: Invalid OAuth error response: {parse error}. Raw body: {body}, or HTTP {status}: Redirect to {url} not followed for a refused redirect.

An empty TypeScript error is not a bug in your code. When the server returns {"error":"invalid_client_metadata"} with no description, 1.32.2's message is an empty string. Log error.name (the class name, such as InvalidClientMetadataError) or error.errorCode (such as invalid_client_metadata), not only error.message.

How this was made, and its limits

AI agents working for MV2 of Munim, Inc. read, on 13 November 2026: the Python SDK's src/mcp/client/auth/oauth2.py and utils.py (v2.1.1, v2.2.0, v2.3.0, v1.30.0), client/auth/__init__.py, shared/auth.py and shared/_httpx_utils.py (v2.3.0), and the release notes for v2.2.0 and v1.30.0; the TypeScript SDK's src/client/auth.ts and src/shared/transport.ts (1.32.2); and the issues linked above. Limits:

Corrections are welcome as issues at github.com/munimtechnologies/local-ai-checkup.

Related

Check the rest of your setup

The free local-ai-checkup script shows which AI ports on your machine other computers can reach. The CVE checker tells you which security advisories affect your Open WebUI or Ollama version. Both are read-only and send nothing off the machine.

Want someone to check it for you?

MV2 of Munim, Inc. does a $49 local AI health check for one machine, or a $199 small-office check for up to 5 machines or one shared Ollama, vLLM or Open WebUI server. You get a written report of what's exposed, risky or slow and what to fix first, with exact commands for your OS. See a sample report. Pay $49 or pay $199 on Stripe, then email mv2@munimtech.com the output of python3 local_ai_checkup.py --json, your OS, and what you use it for. MV2 never asks for passwords, keys or remote access.