Skip to the page
Tecyfy

One MCP server, many users: per-user permissions without leaks

A shared MCP server that calls its APIs with one service key gives every user the key's rights and hides who did what. How the MCP authorization spec expects it to work instead: a token made for the server, scopes checked in each tool, and a separate token for each user downstream.

Tecyfy · Published · 8 min read

Bauhaus poster of one MCP door with a row of keyholes and 3 people each holding their own different key

A shared MCP server is safe for many users only if every tool call runs with the rights of the person behind it. The common shortcut, one service key the server uses for every API call, gives every user that key's rights and writes the server's name, not the user's, into every log. The MCP specification describes the alternative for servers reached over HTTP: each user's client gets an OAuth token issued for the MCP server itself, the server checks that token and its scopes in every tool, and when it calls an API behind it, it uses a credential for that user and that API, never the token it was given.

This is the step after building a server: you have one that works for you, and now a team, or a whole company, will point their agents at it.

Where the shared key goes wrong

Picture a CRM tool on a shared MCP server. Ana in sales may export accounts. Ben in support may read tickets and nothing else. Follow the same request, "export every EMEA account", through the 3 ways teams build this.

Try itOne request through a shared MCP server
Asking

Ben: support agent, may read tickets only

  1. Agent → MCP server

    nothing that names the user, or a token the server ignores

  2. MCP server → CRM API

    the server's own key, with export rights for every account

Leak or blind spotCRM log: crm-mcp-bot exported 4,210 accounts

Export runs and returns every EMEA account. Ben may not export, but the CRM only sees the server's key, so nothing stops him. The log blames the bot.

A made-up CRM and 2 made-up users. The third design follows the MCP authorization specification and OAuth token exchange (RFC 8693).

With one service key, the CRM only ever sees the server. It cannot apply Ben's permissions because it never learns Ben is asking, so the agent can do for Ben whatever the key allows. And when someone asks who exported 4,210 accounts on Tuesday, the log says the bot did. That is the access problem and the audit problem in one, which is why a server key is a non-human identity that needs an owner like any other.

Passing the user's token straight through looks like the fix and is the one design the specification bans outright.

Passthrough is forbidden

The rule in the MCP authorization specification is short: an MCP server must only accept tokens issued for its own resources, and must not accept or transit any other tokens. The client, for its part, must only send the server tokens from the server's own authorization server.

MCP's security guidance gives the reasons. A server that accepts a token issued for some other API has dropped the check that the token was meant for it, so a token stolen from one service works on another. Controls that depend on a token being issued for the right service, such as rate limits and request validation, are skipped. And the server cannot tell its clients apart, while the API's logs show a request from an identity that is not the one that sent it.

So there are 2 tokens in play, never 1: the user's token for the MCP server, and a credential for the API behind it.

The token for the server

For servers on HTTP, MCP authorization is OAuth 2.1 with the MCP server as the resource server. The parts that matter for permissions:

  • The server publishes Protected Resource Metadata (RFC 9728), which tells clients which authorization server issues its tokens.
  • The client must name the server in a resource parameter (RFC 8707) when it asks for a token, so the token is bound to that server.
  • The token travels in an Authorization: Bearer header on every request, never in the URL.
  • The server must check that the token was issued for it as the audience, and answer an invalid or expired token with 401.

Servers that run locally over stdio are outside this: the specification says they take credentials from the environment. Per-user permissions are a problem of remote, shared servers. If a remote server does not even appear in your client, our fix-it guide for MCP servers that don't show up covers that first.

Scopes, checked in every tool

A valid token says who the user is. Scopes say what this client may do for them. The MCP guidance is to start small: a minimal set of low-risk read scopes up front, and more only when a tool that needs them is first used. It names the common mistakes: publishing every scope in scopes_supported, wildcard scopes such as all or full-access, and treating the scopes listed in a token as enough without the server's own authorization logic.

That last one is the rule for tool code. Check the scope where the tool acts, not only at the door. When a user lacks one, the specification's answer is a 403 that names exactly what is missing, so the client can ask the user to grant it:

HTTP/1.1 403 Forbidden
WWW-Authenticate: Bearer error="insufficient_scope",
                         scope="crm:export",
                         resource_metadata="https://mcp.example.com/.well-known/oauth-protected-resource",
                         error_description="Exporting accounts needs crm:export"

The specification asks servers to put every scope the operation needs in one challenge, rather than one at a time over several retries.

A sketch of a tool that does both checks, with PyJWT for the token and the exchange shown in the next section:

import jwt  # PyJWT

SERVER = "https://mcp.example.com"

def caller(bearer: str) -> dict:
    # Rejects tokens issued for any other audience, expired or badly signed.
    return jwt.decode(bearer, signing_key, algorithms=["RS256"],
                      audience=SERVER, issuer=AUTH_SERVER)

def export_accounts(bearer: str, region: str):
    claims = caller(bearer)
    if "crm:export" not in claims.get("scope", "").split():
        raise InsufficientScope("crm:export")       # becomes the 403 above
    crm_token = token_for_user(bearer, audience="https://crm.example.com",
                               scope="accounts.export")
    return crm.export(region, token=crm_token)       # the CRM applies the user's own rights

signing_key, AUTH_SERVER, InsufficientScope and crm stand in for your own setup.

The token for the API behind it

The server now knows who is asking and that they may export. It still needs a credential the CRM will accept as that user. 2 ways work without passthrough:

A connection per user. The server is itself an OAuth client of the CRM, and each user connects their CRM account once. The server stores a token per user and picks the one for whoever is calling. This is where the confused deputy attack lives: MCP's guidance describes how a proxy server that uses one static client ID with the CRM, lets clients register themselves, and meets a CRM that remembers consent in a cookie, can be tricked into handing an authorization code to an attacker. The required fix is the server's own consent screen per client, naming the client, the scopes and where the token will go, plus exact redirect URI matching and a single-use state.

Token exchange. If the CRM trusts the same identity provider, the server can trade the user's token for a new one. OAuth token exchange (RFC 8693) was written for this: a resource server acts as a client, presents the token it received, and gets back a token for a backend service, which can be more narrowly scoped.

POST /oauth2/token HTTP/1.1
Host: idp.example.com
Content-Type: application/x-www-form-urlencoded

grant_type=urn:ietf:params:oauth:grant-type:token-exchange
&subject_token=<the user's token for the MCP server>
&subject_token_type=urn:ietf:params:oauth:token-type:access_token
&audience=https://crm.example.com
&scope=accounts.export

The user's token never leaves the server's hands toward the CRM; the CRM gets a token made for it, for one user, with one scope. Whether your identity provider allows this exchange, and for which audiences, is its policy to set.

Some calls are not on anyone's behalf: a nightly sync that the server runs itself. For those the specification has clients that act on their own behalf with OAuth client credentials, and that is the honest place for a service identity, with its own narrow rights and its own name in the logs.

For a whole company: enterprise-managed authorization

Connecting every user to every server by hand does not scale past a team. MCP has a stable extension for this, Enterprise-Managed Authorization. When the client and the servers both sign in through the company's identity provider, the client trades the user's sign-in for a grant from the identity provider, then trades that for a token from each server's authorization server. Users stop authorizing each server one at a time, and admins get to see and decide which MCP servers can be used at all. It is optional, and both your client and your servers' authorization servers have to support it.

A checklist for a shared server

  1. Every tool runs as the person asking. If the API behind a tool cannot tell who that is, the tool is a shared key.
  2. The server accepts only tokens issued for it, with the audience checked, and forwards none.
  3. Scopes start at read-only and grow by 403 insufficient_scope challenges, checked inside each tool.
  4. Downstream calls use a per-user connection or a token exchange, never the token the server received.
  5. A proxy to a third-party API has its own consent screen per client.
  6. Jobs nobody asked for run as a named service identity with its own small scope.
  7. Logs carry the user, the client and the tool for every call.

Before any of this, decide whether to trust the server at all: our guide to vetting an MCP server covers what to check before a team connects to one, and OAuthOAuthThe standard way to let one app act for you at another service without giving it your password; the app gets a limited, revocable access token instead. MCP servers use it to let AI agents sign in. explains the flow these tokens come from.

Questions

How does MCP server authentication work?
For MCP servers reached over HTTP, the MCP specification uses OAuth 2.1. The server acts as an OAuth resource server, publishes Protected Resource Metadata that names its authorization server, and accepts only access tokens issued for it, sent in the Authorization header of every request. Servers on the stdio transport take credentials from the environment instead.
Can an MCP server pass the user's token to the API behind it?
No. The MCP specification forbids token passthrough: a server must not accept tokens that were not issued for it, and must not forward them to other services. To call an API as the user, the server needs its own token for that API, for example from a per-user OAuth connection or an OAuth token exchange.
How do I give different users different permissions on one MCP server?
Give each user an access token for the server with scopes that match what they may do, check the scope in every tool before it acts, and call the APIs behind the server with that user's own credentials rather than one shared key. Return 403 with error insufficient_scope and the scope needed when a user lacks it.
What is the confused deputy problem in MCP?
It is an attack on MCP servers that proxy a third-party API with one static OAuth client ID. If the third-party server remembers consent in a cookie and the MCP server lets clients register dynamically, an attacker can get an authorization code without the user approving it. The fix the MCP guidance requires is a consent screen per client in the MCP server itself.
What scopes should an MCP server ask for?
As few as possible at first. MCP's security guidance recommends a small starting set of low-risk read scopes, with more requested only when a privileged tool is first used, through a 403 insufficient_scope challenge naming the scopes needed. It lists wildcard scopes such as all or full-access as a common mistake.
What is enterprise-managed authorization in MCP?
It is an MCP authorization extension for companies that sign in to both the MCP client and the MCP servers through one identity provider. The client exchanges the user's sign-in for a grant from the identity provider and swaps that for a server token, so users don't connect each server by hand and admins control which servers can be used.