#1009·mcp-go

feature: bind OAuth client credentials to the authorization server that issued them (SEP-2352)

Author: po-etCreated Sep 26, 2026Updated Sep 26, 2026

Problem Statement

The 2026-07-28 authorization spec (SEP-2352, client registration, "Authorization Server Binding") says clients MUST associate client credentials, whether pre-registered or persisted from dynamic registration, with the authorization server that issued them, keyed by its issuer. When protected resource metadata moves to another authorization server, clients MUST NOT reuse the old credentials there and MUST register again; for pre-registered credentials they SHOULD surface an error.

OAuthHandler doesn't track which server its credentials or tokens came from. After a 401 carrying resource_metadata, it rediscovers and finds the new server, but:

  • the client ID from the previous registration stays, so the usual flow (GetClientID() == "" → RegisterClient, then GetAuthorizationURL) presents it to the new server;
  • if the new server lets that through, the code exchange sends it the old client secret as well;
  • an expired access token is refreshed at the new server's token endpoint with the old server's refresh token and client credentials.

The conformance client scenario auth/authorization-server-migration fails its three sep-2352 checks for these reasons.

Proposed Solution

I have a branch that covers the in-process part, and before opening a PR I'd like to check the API side with you:

  • Record the issuer of the client credentials (set by RegisterClient, or on the first successful code exchange for configured credentials) and of the stored token (set on each code exchange and refresh).
  • GetAuthorizationURL: on a different issuer, register again with the new server under the same client name, dropping the old ID and secret; for configured credentials return an error.
  • Code exchange and refresh: refuse to send credentials or a refresh token to a server other than the one they came from.
  • Credentials persist across processes, so the binding has to as well. That needs something like OAuthConfig.CredentialsIssuer plus a getter, so an app can save the issuer next to the client ID and secret, and an exported error for "the authorization server changed" that apps using configured credentials can check for.

Does that shape work for you, or would you rather keep the binding internal and leave persistence to the token store?

MCP Spec Reference

https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization/client-registration#authorization-server-binding