MCP OAuth for remote servers, explained with a real server's metadata A developer walkthrough of the MCP authorization specification (version 2025-11-25) traces how remote MCP servers handle OAuth, using Sandscale's published metadata as a worked example. The flow begins with a token-less request returning a 401 whose WWW-Authenticate header points to protected-resource metadata, then moves through authorization-server discovery, PKCE enforcement (clients must refuse to continue if code_challenge_methods_supported is missing), and resource binding via the canonical resource field. The writeup stresses that authorization servers must display the redirect URI's host on the consent page, giving teams a checkpoint to catch unexpected connectors. When someone on your team adds a remote MCP server to Claude Code, Codex, Cursor or Gemini CLI, a browser opens, they sign in, and the tools appear. Several standards are doing work in those few seconds, and each one answers a question a team cares about: who is this client, what may it do, and which server is the token for. This post walks through the flow in the MCP authorization specification https://modelcontextprotocol.io/specification/2025-11-25/basic/authorization version 2025-11-25 , using the documents Sandscale's remote MCP server publishes as the worked example. Anything quoted from that server below is what it returned when we requested it on 2 December 2026. The specification says HTTP-based transports should follow it, and stdio servers should not: a stdio server gets its credentials from the environment it was started in. So OAuth is the story for remote servers over Streamable HTTP. A local server started by the agent, such as sandscale mcp , signs in however its own CLI signs in. We compared the two transports in MCP over stdio or Streamable HTTP https://sandscale.dev/blog/mcp-stdio-vs-streamable-http?ref=devto-mcp-oauth-for-remote-servers-explained . The client sends its first request with no token. The server answers 401 Unauthorized with a WWW-Authenticate header that points at its metadata. Sandscale's server answers a token-less request to https://mcp.sandscale.dev/mcp with: WWW-Authenticate: Bearer resource metadata="https://mcp.sandscale.dev/.well-known/oauth-protected-resource/mcp", scope="mcp" Two things are in there. resource metadata tells the client where to read about this server. scope tells it which scope to ask for. The specification says clients should use the challenged scope first, and fall back to the metadata's scopes supported only when the header has none. The client reads that document. Every MCP server that does authorization must publish one, and it must list at least one authorization server. Sandscale's says: {"resource":"https://mcp.sandscale.dev/mcp","authorization servers": "https://auth.sandscale.dev" ,"scopes supported": "mcp","offline access" ,"bearer methods supported": "header" ,"resource name":"Sandscale","resource documentation":"https://sandscale.dev/docs/reference/mcp"} The important field for security is resource : it is the server's canonical address, and it comes back in step 5. bearer methods supported says tokens go in the Authorization header, not in a query string. The client then reads the authorization server's own metadata, from OAuth 2.0 Authorization Server Metadata RFC 8414 or OpenID Connect Discovery. The specification requires clients to support both. For Sandscale, https://auth.sandscale.dev/.well-known/oauth-authorization-server lists the authorization, token and revocation endpoints, code challenge methods supported with S256 , client id metadata document supported set to true , and a registration endpoint . That PKCE field is not decoration. The specification says that if code challenge methods supported is missing, the client must refuse to continue. An authorization server has to know which app is asking. MCP has three ways to answer, and clients that support all of them should try them in this order: Sandscale's authorization server advertises the second and third, so clients that do either can connect. For a team, the useful consequence is on the consent page. The specification requires the authorization server to show the redirect URI's host during authorization. Sandscale's approval page names the app and says it is not made by Sandscale. Teach people to read that page: a connector they did not expect, or a redirect to a host they do not recognize, is a reason to cancel. The client opens the browser with an authorization code request. Two parameters matter: S256 hash as code challenge , and later proves it holds the verifier when it exchanges the code. Someone who intercepts the code cannot use it. resource RFC 8707 . The person signs in and approves. The client exchanges the code for an access token, and, if it asked for offline access , a refresh token. From here, each MCP request carries Authorization: Bearer