A remote MCP server that wraps an existing API usually lets the agent do whatever the API token allows. Some hold one API key for everyone, some forward the user's OAuth token, and some check the API's scopes before each tool runs. In each case the agent is scoped the way an API client is. openapi-mcp-gateway signs each agent in with a token of its own, the MCP token, and keeps the user's API token, the upstream token, to itself. The MCP token carries scopes drawn for the agent, per operation, and the gateway checks both tokens at every sign-in and every call. When a call needs more, the agent asks for it and the user approves on a consent page, a step called step-up.

This applies to servers reached over HTTP. A local stdio server has no sign-in, since it reads a key from its environment.

The Gap in API Scopes

An API's OAuth scopes were drawn for programs a developer wrote and reviewed, each signing in as its own client. Agents break three assumptions behind them.

  • Shared Client: a company API often accepts only OAuth clients that IT registers, so a remote MCP server signs every agent in through one. Claude Code, a support bot, and a report agent then reach the API as the same client and the same user. Only the MCP server can tell them apart, so only it can give each its own scope.
  • Coarse or Missing Scopes: the vendor's scopes follow the vendor's resource model. No GitHub classic scope narrower than repo reaches a private repository, and repo covers its code and everything else in it. Many internal APIs check only that a token is valid. An agent's risk lies in what a call can change, so it needs reads and writes split per operation, and you cannot add a scope to someone else's API.
  • Unpredictable Caller: a program does what its code says. An agent acts on what it reads, and text planted in an issue or a web page can turn it against the user. It should hold read access until a task needs write, and the user should approve each widening.

Three agents, one OAuth client, one user. Claude Code holds an MCP token with products:read and products:write, a support bot holds orders:read, and a weekly report agent holds orders:read and products:read. All three reach the gateway, which checks MCP scopes and calls the shop API with upstream tokens from one OAuth client for one user. IT registered one OAuth client for the gateway, so the shop cannot tell the agents apart, and only the gateway can give each its own scope.

The same five operations, scoped two ways. For a GitHub OAuth app, one scope, repo, covers listing issues, creating an issue, adding labels, merging a pull request, and updating a file. The gateway gives them four MCP scopes instead: issues:read, issues:write for creating an issue and adding labels, pulls:write, and repos:write.

The upstream token in this example still carries repo. It never leaves the gateway, though, and the gateway refuses any call the agent's MCP token does not cover.

So the agent needs scopes of its own, set per operation and widened only with the user's consent. The MCP spec already keeps the two tokens apart. A server must not pass through the token its client sent, and the gateway puts the agent's scopes on that client-facing token.

Current Approaches

Products that put an agent in front of an API limit it in one of three ways.

Approach Examples What It Leaves Out
The API's own permissions The remote MCP servers of GitHub, Notion, and Linear The agent holds whatever the token or the user holds. Narrower limits stop at a read-only mode or a set of tools. GitHub's server can step up, but only between GitHub's own scopes
Agent scopes drawn by the vendor Atlassian, with scopes such as read:jira:agent-interface Only the API's owner can draw them
A gateway policy per tool Kong consumer lists, Apigee API products, Cedar policies in AWS AgentCore Gateway, OPA policies in Maverics An admin writes the rule, so the client has no scope to ask for. None of them documents consent or step-up

openapi-mcp-gateway takes the second approach in front of an API it does not own. It draws OAuth scopes for agents, as Atlassian did for its own API. Because they are OAuth scopes, a client asks for them at consent and steps up when a call needs more.

The Scope Model

Every operation carries two requirements, one per kind of scope, and a call must meet both.

  • MCP Scopes: the gateway's own, on the MCP tokens it mints for each client. They decide which operations an agent may reach.
  • Upstream Scopes: the API's, read from each operation's OpenAPI security. They decide what the user's upstream token must hold.

The scopes a token holds are its grant. The upstream may grant less than a sign-in asks for, for example when the user's own role lacks a scope, so an operation the agent may reach can still be out of the user's reach.

A Venn diagram of the two grants. The MCP grant is what this agent may do, and the upstream grant is what the user's token may do. archiveProduct sits only in the MCP grant, so the gateway hides it, since the upstream grant lacks its scope. listOrders sits only in the upstream grant, so it is not given to this agent. listProducts and createProduct sit in both, so the call runs. A call runs only inside both grants, and the gateway can only narrow what the upstream allows.

The MCP scopes come from config. They can be derived from the spec's tags, as products:read for every GET under the products tag, or written by hand. Each client, named by its metadata URL, gets a maximum in scopes and what a sign-in receives when it asks for nothing in default_scopes. This excerpt leaves out the server's name and spec:

auth: mcp: operation_scopes: auto: tags clients: https://claude.ai/oauth/claude-code-client-metadata: scopes: [products:read, products:write] default_scopes: [products:read] upstream: type: oauth2 flow: authorization_code client_id: ${SHOP_CLIENT_ID} client_secret: ${SHOP_CLIENT_SECRET} enforce_scopes: true required_scopes: [offline_access] 

The upstream side needs no list of its own. With enforce_scopes, each sign-in follows the MCP grant to the operations it opens, reads their security, and asks the upstream for exactly those scopes. An agent holding products:read never sends the user to approve write:products. This narrowing is called downscoping.

How an MCP grant becomes an upstream request. products:read opens listProducts and getProduct, whose security asks for read:products, so the sign-in asks the upstream for offline_access read:products. products:write, not granted, would open createProduct and updateProduct and need write:products, and it is greyed out because the sign-in does not ask for it. offline_access comes from required_scopes, which every sign-in asks for.

Step-Up

An agent starts with default_scopes and asks for more only when a call needs it. A call the MCP token does not cover returns 403 with an insufficient_scope challenge naming the scope it needs, as the MCP authorization spec describes. The client signs in again for its current scopes plus the new one. The consent page marks the new MCP scope and the new upstream scope, and the upstream sign-in asks for what the wider grant opens, so both tokens widen together.

The gateway's consent page during a step-up. Claude Code asks to use the shop server. It already holds products:read and now also asks for products:write, marked New, and the upstream sign-in at auth.shop.example.com will ask for read:products and the new write:products.

Before and after a step-up. Before, the MCP token holds products:read, and the upstream token holds offline_access and read:products. After a 403, consent, and sign-in, the MCP token also holds products:write, and the upstream token also holds write:products. Filled boxes are added by the step-up, and both tokens widen together.

The upstream can still refuse a call the gateway's record of the grant allowed, for example when the spec's security understates what the API wants. Under authorization_code, the gateway reads the API's own insufficient_scope challenge. When the missing scope lies within what the gateway may ask the upstream for, it sends the client a URL elicitation, a link the client opens for the user to sign in to the upstream again. The MCP token stays as it is, and the call retries once the sign-in finishes.

Step-up also decides what the model sees. An agent never calls a tool it cannot see, so it never starts a step-up for one. The gateway lists an operation when this client may be granted its MCP scope, even before the token holds it. It hides operations beyond the client's scopes, and those the user's upstream grant cannot run. Kong, Apigee, and AgentCore filter their lists too, as GitHub's server does for classic tokens. Metabase lists every tool on the same reasoning, since only a failed call prompts a client to ask for more.

Three nested layers of visibility. Every operation is the outer layer, and one beyond the client's scopes is hidden, such as deleteProduct. Inside it are the client's scopes. An operation the token does not hold yet is listed, and a call returns 403 to step up, such as createProduct. Innermost is what the token holds, listed and callable, such as listProducts.

Limits

The scope model leaves five things to the client, the upstream, or another tool.

  • Client Support: step-up needs a client on MCP protocol version 2026-07-28, which names the tool it calls in a header. An older client gets a tool error naming the missing scope, and cannot widen its grant.
  • Per-Client Scopes: everyone signing in through one client gets the same MCP scopes. Per-person limits stay with the upstream's own roles, or with an external issuer that grants scopes per user.
  • No Step-Down: nothing shrinks a grant during a session, since no call fails for holding too much. A later sign-in asking for fewer scopes narrows it, and one asking for none starts again from default_scopes.
  • Flat Scopes: no MCP scope implies another, so a broad scope lists every operation it opens.
  • Operation-Level Scopes: a scope opens an operation for any arguments. Holding an agent to one repository or one branch takes the upstream's own permissions, or a policy engine such as AgentCore's Cedar policies.

Wrapping Up

An agent no longer has to hold whatever the API token holds. MCP scopes set per client and per operation narrow it, and step-up widens it only with the user's consent. The Scopes guide covers the setup under every auth mode, and the Scope Model page holds the full rules. If you run agents against an API you do not own, open an issue with the scope split you needed.