In depth
When MCP expanded beyond local stdio servers to remote HTTP deployments, it needed a standard authentication mechanism. The spec adopted OAuth 2.1 (the modern consolidation of OAuth 2.0 + PKCE + refresh tokens + best practices) and defined how clients and servers negotiate tokens.
The flow: the user tries to use a remote MCP. The client opens a browser to the server's OAuth authorization endpoint. The user logs in with their real credentials (via the SaaS, not the MCP). The server redirects back with an authorization code. The client exchanges the code for an access token + refresh token. Subsequent `Mcp-Session-Id` requests include the token as a Bearer header.
Tokens are refreshed automatically — access tokens are typically short-lived (1 hour); refresh tokens are longer (30+ days) and stay in the host's secure store. The user can revoke at the provider side and the agent loses access immediately.
OAuth in MCP also supports Dynamic Client Registration (RFC 7591), so MCP clients don't need manual registration at each provider — they register themselves at first use.