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 (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.

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 <token>. The specification puts two duties on the server that are worth knowing as a buyer:

Later, a call that needs more than the token allows gets 403 with error="insufficient_scope", and a client acting for a person should go back through authorization for the larger scope (the specification calls this step-up).

The protocol gives you a person-bound, server-bound token. It does not decide your policy. Before you approve a remote MCP server for the team, ask:

For Sandscale's remote MCP server, the docs answer those: each call runs as the person who approved it, with a short-lived credential that never leaves the server; each app can make up to 120 calls a minute and each person up to 60; every call is in the organization's audit log with the tool, the region, the outcome and the app, never the arguments; and a person can revoke one connector with DELETE /api/v1/me/mcp-connectors/{id}, which ends that app's sessions at once.

You do not need a client to look at any of this. Two requests show what a remote MCP server expects:

curl -si -X POST https://mcp.sandscale.dev/mcp -H 'Content-Type: application/json' -d '{}' | grep -i www-authenticate
curl -s https://mcp.sandscale.dev/.well-known/oauth-protected-resource

Point them at any remote server your team is considering. A server that has no protected resource document, or whose authorization server lists no S256, is one a conforming client should refuse to sign in to.

Originally published on the Sandscale blog.

原文来源:dev.to