Skip to main content
Back to blog
Product

Dialing in scopes for MCP sign-ins

David Danialy

David Danialy

Published · 5 min read

Dialing in scopes for MCP sign-ins

MCP authorization has a scope-selection problem during OAuth sign-in. Ask for too few scopes and the MCP server can't do its job. Ask for too many and people face a consent screen longer than a terms-of-service page, or an identity provider that rejects the request outright.

Speakeasy asks the MCP server which OAuth scopes it needs. Sign-ins request those scopes and fall back to the identity provider's full list only when no other source supplies them.

How do MCP servers request OAuth scopes?

The MCP authorization spec gives a server two ways to tell us.

First, when a request arrives without a valid token, the server replies 401 with a WWW-Authenticate header (RFC 6750). Its scope value lists what the request needs, and the spec treats that list as authoritative.

The server can also publish its supported scopes at a well-known URL in protected resource metadata (RFC 9728).

For a server at https://mcp.example.com/mcp, the challenge response can request scopes like this:

HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer scope="issues:read issues:write"

The client retrieves that document from the server’s well-known URL:

GET /.well-known/oauth-protected-resource/mcp HTTP/1.1
Host: mcp.example.com

The server responds with the metadata document:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "resource": "https://mcp.example.com/mcp",
  "authorization_servers": ["https://auth.example.com"],
  "scopes_supported": ["issues:read", "issues:write", "projects:read"]
}

The flow shows how each piece fits into a sign-in:

Ask the MCP server firstA remote MCP sign-in through Speakeasy. The MCP server's 401 challenge carries a scope parameter, which Speakeasy records. At sign-in, Speakeasy fetches the server's RFC 9728 protected resource metadata, checks that its resource value matches the server URL exactly, and reads scopes_supported. It then sends the person to the authorization server's authorize endpoint with the chosen scopes.SCOPE DISCOVERYAsk the MCP server firstSPEAKEASYsign-inMCP SERVERmcp.example.comAUTH SERVERauth.example.comMCP request, no usable token1401 WWW-Authenticate: Bearerscope="issues:read issues:write"kept from the last challengeA person signs inSpeakeasy runs steps 3 to 52GET /.well-known/oauth-protected-resource/mcp3200 resource, scopes_supportedresource must match exactlyPick by precedenceno client scope override: challenge wins4redirect to /authorize?scope=issues:read issues:writeonly the challenged scopes in this example5

The metadata must name the server URL exactly, including whether it ends in a slash. We skip it if the resource value does not match. The advertised scopes may omit what a server later requires; challenges and pins handle those additional scopes.

How are requested MCP OAuth scopes chosen?

Six sources can supply the scopes. We check them in order, and the first one with an answer wins:

  1. Client scope override. Scopes an admin sets on the remote session client page. The client is the connection Speakeasy uses to sign in to the identity provider.
  2. Server challenge scopes. The scope from the server's latest rejection, its WWW-Authenticate header.
  3. Pinned server scopes. A fixed list an admin sets in the Pinned scopes field of an MCP server's Settings › Identity, sent exactly as written, even if the server doesn't list those scopes. A pin belongs to the server's URL, so every server in the project at that URL shares it.
  4. Server advertised scopes. The scopes_supported list from the server's advertised menu.
  5. Provider scope override. A fixed list set on the identity provider.
  6. Provider scope catalog. Every scope the identity provider offers, as a last resort. Turn on Request default scopes when the MCP server advertises none on the identity provider to send no scopes instead, and the identity provider applies its own default scopes or, depending on its policy, rejects the request (RFC 6749 §3.3).

The diagram also shows who controls each source:

First non-empty source winsThe scope precedence ladder for remote MCP sign-ins: client scope override, server challenge scopes, pinned server scopes, server advertised scopes, provider scope override, and provider scope catalog. The first non-empty source decides. Operator-set lists go out as written. Standard scopes are appended to challenge scopes only when the MCP server advertises them.SCOPE PRECEDENCEFirst non-empty source winsChecked top to bottom. An empty source falls through.01Client scope overrideSet on the remote session clientOPERATOR02Server challenge scopesscope= in the server's last WWW-AuthenticateMCP SERVER03Pinned server scopesPer upstream URL, sent as writtenOPERATOR04Server advertised scopesRFC 9728 scopes_supportedMCP SERVER05Provider scope overrideSent verbatim, nothing appendedOPERATOR06Provider scope catalogAll its scopes_supported, or none if set to omitPROVIDER+ openid email profile offline_accessadded to 02 only when the MCP server advertises them

For example, a server challenge takes precedence over pinned server scopes. When the server provides no challenge or advertised scopes, a pin or provider override can still supply the request. If no source supplies scopes, the identity provider setting determines whether Speakeasy requests its full catalog or sends no scopes so the provider can apply its defaults.

Scopes an admin sets go out exactly as written, whether that's a client scope override, pinned server scopes, or a provider scope override. If the server's challenge scopes win, we add openid, email, profile, and offline_access only when the server itself advertises them. Advertised lists go out as published. Want to know who signed in, or keep them signed in? Include openid or offline_access in the scopes you set.

How can you preview OAuth scopes before MCP sign-in?

To check what a sign-in will ask for, open the MCP server's Settings › Identity. A note under Pinned scopes says which of the six sources is in charge. Here, the pin wins:

The Identity section of an MCP server's settings, with "read" set as a pinned scope and the note "Sign-ins request these scopes."

If a pin is set but something higher up wins, the note says what. Teammates who can view the server but not edit it see a read-only "Requested at sign-in" summary instead, with the scopes and where they came from, like "Advertised by the MCP server."

What happens to existing MCP connections after scope changes?

Changing the scope settings does not change an active connection or revoke its existing grant. The connection keeps its granted scopes until the client starts another sign-in. Speakeasy requests the updated set then, and the identity provider handles any consent step under its own policy.

How to configure OAuth scopes for MCP servers

Sign-ins already ask each server what it needs. Change settings in these cases:

  • The server's menu asks for more than your team should approve. Pin server scopes on its URL. A pin outranks the server's menu, though a client scope override or the server's challenge scopes still win over it.
  • The server says nothing. With no challenge scopes and no menu, sign-ins fall through to the identity provider's settings. Pin server scopes to choose the set yourself. Without a pin or a provider scope override, turn on Request default scopes when the MCP server advertises none so the identity provider applies its defaults (or rejects the request, depending on its policy) instead of being asked for its whole catalog.
  • A sign-in asks for something unexpected. Open the server's Settings › Identity, where the note under Pinned scopes names the source in charge. If the server's menu is being skipped, check that its resource value matches the server URL exactly. A trailing slash is enough to break the match.

Standards

Scope discovery follows the MCP authorization spec, RFC 9728 for protected resource metadata, RFC 6750 for bearer token challenges, and RFC 6749 §3.3 for the scope parameter.

Open the Speakeasy MCP Gateway, connect a remote MCP server, and see what its sign-ins will ask for.

AI everywhere.

Control here.