The MCP Python SDK advertises client_secret_basic, then rejects it The MCP Python SDK's built-in OAuth authorization server advertises client_secret_basic in its metadata but rejects clients that use it, returning a 401 "invalid_client: Missing client_id" error, and the bug remains unfixed in version 2.3.0 on PyPI. The SDK's ClientAuthenticator in src/mcp/server/auth/middleware/client_auth.py reads client_id from the form body before checking the Authorization header, so clients following RFC 6749 section 2.3.1 are turned away; the SDK's own client masks the problem by always sending client_id in the body, per issue #3138. The defect is tracked in open issues #3545 and #1315 (from August 2025), and a fix, PR #3550, was closed without being merged. The MCP Python SDK advertises client secret basic, then rejects it Our MCP server's OAuth token endpoint turned away every client that sent its credentials the standard way. The cause is in the MCP Python SDK itself still in 2.3.0 , how to tell if your server has it, and a small fix you can add today. For four days, every health check Glama ran against our MCP server failed with a 401. The sign-in page worked. The consent screen worked. The user pressed Allow. Then the last step, swapping the authorization code for a token, failed, and nothing on screen said why. The cause turned out not to be in our code. It is in the MCP Python SDK, and if you run an MCP server with the SDK's built-in OAuth, your server very likely has it too. Press Run to call the API. Get your free API key https://nestdaddy.com/mcp What the logs showed The whole sign-in flow, in order: GET /.well-known/oauth-authorization-server/memory 200 GET /authorize?response type=code&client id=... 302 POST /token 401 The token endpoint answered: {"error": "invalid client", "error description": "Missing client id"} But the client had sent its client id. It was in the Authorization header. The standard says that is allowed OAuth 2.0 RFC 6749, section 2.3.1 https://datatracker.ietf.org/doc/html/rfc6749 section-2.3.1 gives a confidential client two ways to send its credentials to the token endpoint: - client secret basic : Authorization: Basic base64 client id:client secret , and nothing about the client in the form body. - client secret post : client id and client secret as form fields. Basic is the one the RFC says servers must support. Many OAuth libraries use it by default. What the SDK does The SDK's server side does two things that do not fit together: 1. Its metadata route announces both methods. In src/mcp/server/auth/routes.py the default is token endpoint auth methods supported= "client secret post", "client secret basic" . 2. Its ClientAuthenticator src/mcp/server/auth/middleware/client auth.py reads client id from the form body first, and raises Missing client id if it is not there, before it ever looks at the Basic header. So a client that reads the metadata, picks client secret basic , and follows the RFC is rejected. The Basic header is only checked when the client also repeats its client id in the body, which the RFC does not ask it to do. Why doesn't everyone notice? Because the SDK's own client sends client id in the body even when it uses Basic issue 3138 https://github.com/modelcontextprotocol/python-sdk/issues/3138 . SDK client talking to SDK server works. A client built on anything else may not. This is already reported: issue 3545 https://github.com/modelcontextprotocol/python-sdk/issues/3545 open , and an older issue 1315 https://github.com/modelcontextprotocol/python-sdk/issues/1315 from August 2025 open . A fix, PR 3550 https://github.com/modelcontextprotocol/python-sdk/pull/3550 , was closed without being merged. As of today the newest release on PyPI, 2.3.0, still has it. Does your server have it? You are affected if all of these are true: - you use the SDK's built-in authorization server mcp.server.auth , - your metadata lists client secret basic it does by default , - clients register themselves dynamic client registration and some of them choose Basic. Test it in one line. Register a client, then send a token request with Basic and no client id in the body, using a code you know is fake: curl -s -X POST https://your-server.example/token \ -u "$CLIENT ID:$CLIENT SECRET" \ -d grant type=authorization code -d code=fake \ -d redirect uri=https://your-client.example/callback -d code verifier=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx - invalid grant "authorization code does not exist" : client authentication passed. You are fine. - invalid client "Missing client id" : you have the bug. In your access log the pattern is a successful GET /authorize followed by a 401 on POST /token from the same client, and the user never gets connected. The fix we run Until the SDK changes, a small ASGI middleware in front of the app does the job. For POST /token and POST /revoke with a Basic header and no client id in the form, it copies the client id from the header into the form. The SDK then checks the secret exactly as before, so nothing gets weaker. python import base64 import urllib.parse from starlette.responses import JSONResponse class BasicClientIdFix: """RFC 6749 2.3.1: with client secret basic the client id may be only in the Authorization header. Copy it into the form so the SDK's authenticator finds it. The SDK still verifies the secret in full.""" PATHS = "/token", "/revoke" MAX BODY = 65536 def init self, app : self.app = app async def call self, scope, receive, send : if scope.get "type" = "http" or scope.get "method" = "POST" or scope.get "path" not in self.PATHS: return await self.app scope, receive, send headers = {k.lower : v for k, v in scope.get "headers", } auth = headers.get b"authorization", b"" .decode "latin-1" ctype = headers.get b"content-type", b"" .decode "latin-1" .lower if not auth.lower .startswith "basic " or "application/x-www-form-urlencoded" not in ctype: return await self.app scope, receive, send body, more = b"", True while more: msg = await receive if msg.get "type" = "http.request": return body += msg.get "body", b"" more = msg.get "more body", False if len body self.MAX BODY: return await JSONResponse {"error": "invalid request"}, status code=413 scope, receive, send form = urllib.parse.parse qs body.decode "utf-8", "replace" , keep blank values=True if not form.get "client id" : try: user = base64.b64decode auth 6: .strip , validate=True .decode "utf-8" .split ":", 1 0 client id = urllib.parse.unquote user except Exception: client id = "" if client id: extra = urllib.parse.urlencode {"client id": client id} .encode body = body + b"&" + extra if body else extra new headers = k, v for k, v in scope.get "headers", if k.lower = b"content-length" new headers.append b"content-length", str len body .encode scope = dict scope, headers=new headers sent = False async def replay : nonlocal sent if not sent: sent = True return {"type": "http.request", "body": body, "more body": False} return await receive await self.app scope, replay, send app = BasicClientIdFix mcp.streamable http app What we tested after the change: | Request | Before | After | |---|---|---| | Basic, no client id in body, fake code | 401 Missing client id | 400 invalid grant auth passed | | Basic with a wrong secret | 401 | 401 Invalid client secret | | Form only, client secret post | unchanged | unchanged | | MCP call without a token | 401 | 401 | And the real test: the client that had failed for four days connected on the next try, and its health check went green. What our registrations looked like Of the eleven clients that registered with our server through dynamic registration, five chose client secret post , five chose none public clients with PKCE , and one chose client secret basic . Only one in eleven, so the bug can sit there for a long time. But that one client was a directory that checks servers every hour, and it had marked us as failing every hour for days. If you run the SDK's auth server, run the curl test above. It takes a minute. We found this while running NestDaddy Memory https://nestdaddy.com/memory , a hosted MCP memory server built on the MCP Python SDK. We will update this post when the SDK ships a fix.