A customer-facing MCP agent is only useful if it can act on each customer’s behalf without crossing account boundaries. OAuth gets you part of the way there, but a working login is not a complete authorization design.
Your practical goal is simpler: issue the right token to the right customer, let it live only as long as necessary, refresh it without interrupting work, revoke it promptly, and enforce scopes again when every tool runs.
For a small team, this does not require an enterprise identity platform. It does require clear ownership of the token lifecycle and a server-side authorization check on every protected action.
Separate the four jobs before choosing infrastructure
MCP authorization works best when you keep these responsibilities distinct:
- The MCP client requests access and stores credentials.
- The authorization server authenticates the user, obtains consent, and issues tokens.
- The MCP server validates tokens and authorizes tool calls.
- Your application database records tenant ownership, grants, sessions, and revocation state.
The authorization server may live in the same codebase as your MCP server, but combining deployment does not mean combining responsibilities. The MCP server should consume and validate tokens; it should not become an accidental token factory for unrelated services.
This separation gives you a useful fallback. If your hosted identity provider becomes inconvenient, your authorization server can change without rewriting every tool handler. If a tool starts misbehaving, you can tighten server-side checks without rotating every customer’s account.
For the broader trade-offs between static tokens, delegated OAuth access, and per-user authorization, see How to Choose an MCP Server Authorization Model Without Handing Agents Too Much Access.
Start with the delegation, not the token format
Before writing token code, define what the agent is allowed to do for one customer. This sounds obvious, but it prevents the most common implementation mistake: creating one broad scope such as mcp:write because individual tools did not seem important enough to separate.
A useful scope model is organized around customer-visible capabilities:
mcp:tools:read
mcp:tools:create
mcp:tools:update
mcp:tools:delete
mcp:admin
The exact names are yours to choose. The important properties are:
- Each scope has a clear purpose.
- Privileged operations are not bundled with ordinary reads.
- A client can receive only the scopes its workflow needs.
- The server rejects tools that fall outside the granted scopes.
Do not use scope names as your only defense. Scopes answer, “What was this client delegated?” Resource checks answer, “Can this customer manipulate this specific record?” You need both.
Consider a customer record:
Customer A
├─ invoices:read
├─ invoices:write
└─ subscriptions:read
Customer B
└─ invoices:read
A token for Customer A may have invoices:write, but it must not update Customer B’s invoice. When a tool receives an invoice identifier, verify that the invoice belongs to the tenant represented by the token. Do this in the data-access layer or tool implementation, not only in the request handler.
Choose access-token lifetimes by damage and recovery time
Short-lived access tokens are the default because they reduce the useful lifetime of a leaked bearer token. But “short-lived” without a recovery plan can create a different problem: your agent stops working in the middle of a customer task.
Use separate lifecycles:
| Credential | Practical role | Expiration and handling |
|---|---|---|
| Access token | Authorizes MCP requests | Short lifetime; reject after expiration |
| Refresh token | Obtains new access tokens | Longer lifetime, bound to the client and authorization grant |
| Authorization grant | Records user consent | Revocable independently of any one token |
| Session or connection state | Supports recovery and diagnostics | Revoke when the grant is revoked |
A sensible starting policy is an access token measured in minutes rather than days, with refresh tokens handled as sensitive credentials. The exact duration depends on how quickly you can revoke, how often agents operate, and how disruptive a forced reauthorization would be. If an agent performs a long-running task, do not solve that by making access tokens unnecessarily long-lived. Use the existing refresh mechanism before expiry.
The important design choice is that an access token should never become the only durable record of a customer’s authorization. If your server can only decide whether a request is allowed by looking at an unexpired bearer token, revocation becomes difficult and audit history becomes weak.
Implement refresh as a controlled rotation
Refresh is not “send the same credential again.” It is a new grant to continue access under an existing authorization decision.
A refresh path should:
- Validate the refresh credential.
- Confirm that its client and authorization grant are still active.
- Confirm that the customer or tenant has not been suspended or removed.
- Issue a new access token with the current scopes.
- Rotate the refresh token when required by your security policy.
- Record the event without storing the raw credential.
Treat an invalid refresh token as a signal to reauthorize, not as a reason to repeatedly retry. Repeated failures can create noisy logs and invite denial-of-service pressure against the token endpoint.
For public clients, refresh-token rotation is especially important because the client cannot keep a secret confidential. Rotate refresh tokens, detect reuse of an already-rotated token, and revoke the affected authorization family when reuse is confirmed.
If the client and server are part of your own product, you may control both sides. Keep the refresh-token store separate from conversation logs, analytics events, and exception payloads. A token that appears in a crash report is still a live credential.
Make revocation a first-class product operation
Token revocation matters when a customer:
- Disconnects your agent.
- Revokes the customer’s grant in your product.
- Changes the permissions associated with the integration.
- Reports suspicious activity.
- Leaves a team or workspace that owned the connection.
A useful design separates grant revocation from token invalidation. Revoking the grant ends future refreshes. Invalidating outstanding access tokens ends current use. In a small implementation, your authorization server can check grant status on each request, but as volume grows you may move that check into a cache or policy service.
Do not rely on deleting a row from your database without deciding what else must happen. A revocation event may also need to:
- Stop refresh-token use.
- Invalidate cached access tokens.
- Disconnect active agent sessions.
- Prevent queued jobs from running later with the old credential.
- Record who requested revocation and when.
For customer-facing software, support should be able to answer: “When was this connection disabled, and which requests stopped?” Store a status such as active, revoked, or expired, along with timestamps. If your product promises immediate shutdown, verify that every request path honors the revoked state.
You do not need a global event bus on day one. A transactional state update plus a reliable status check may be enough. Add a background cleanup or cache invalidation process only when the number of tokens makes synchronous checks too expensive.
Enforce authorization at tool-call time
Authentication and OAuth validation are not the same as tool authorization. A valid token can carry a legitimate scope and still contain an identifier that points to another customer’s data.
Use this sequence for every protected tool:
1. Validate token signature, expiry, issuer, and audience.
2. Load the active authorization grant.
3. Confirm the required scope is granted.
4. Resolve the customer or tenant from trusted token context.
5. Check that the requested resource belongs to that tenant.
6. Apply any step-up or approval policy for sensitive actions.
7. Execute the tool.
8. Record an audit event.
There is an important detail in step four: derive tenant context from validated token claims or a server-side grant record, not from a tenant ID supplied directly by the model or tool arguments. An agent should not be able to change the active customer simply by placing another customer ID in its arguments.
For destructive tools, consider requiring a stronger condition than ordinary scope access:
- A recent user confirmation.
- A short-lived approval grant.
- A narrower scope such as
mcp:tools:delete. - A server-side transaction limit.
- An explicit policy for high-value records.
This is especially important because an agent may produce a valid sequence of calls that no human intended. OAuth verifies delegated access; it does not evaluate whether the agent’s plan is sensible.
Prevent one customer’s context from contaminating another
Multi-tenant MCP authorization has three isolation boundaries to preserve:
Credential boundary
Each customer should receive a grant associated with that customer and the intended client. Do not issue a shared token to all customers and rely on a database lookup to guess who is calling. The token or its grant record must identify the delegation unambiguously.
Data boundary
Every read and write must include the authorized tenant in its query or policy check. Test that direct calls to internal APIs cannot bypass the MCP layer and fetch records by ID alone.
Context boundary
Customer data, tool output, and credentials must not leak between conversations or jobs. Use separate storage partitions, cache keys, and background-job contexts. Clear a customer’s agent context when a connection is revoked if the product retains session state.
A common failure is caching a tool result by tool name or request body without including the tenant. The next customer can then receive the previous customer’s result. Include tenant and authorization context in every cache key that contains customer data.
Keep credentials out of the agent’s reasoning context
Bearer tokens should travel in HTTP authorization headers, not in prompts, tool arguments, traces, or model-visible conversation history. An agent should receive a tool result, not the credential needed to obtain it.
This requires checking more than the main application:
- Exception messages
- HTTP request and response logs
- Distributed tracing attributes
- Analytics events
- Debug endpoints
- Crash reports
- Support tools
- Background job payloads
Redact authorization headers and token-like fields at the logging boundary. If a developer tool temporarily displays a credential to diagnose an issue, it should still avoid copying it into persistent notes or model context.
Use discovery and audience binding correctly
For HTTP-based MCP servers, clients generally need metadata to discover the authorization server and the protected resource. The server should expose the appropriate protected-resource metadata, including supported scopes, and the authorization server should publish its authorization-server metadata.
The flow normally looks like this:
- The client requests an MCP endpoint without valid authorization.
- The server responds with
401 Unauthorizedand aWWW-Authenticatechallenge that points to protected-resource metadata and identifies required scopes. - The client retrieves the metadata and discovers the authorization server.
- The client registers if the server supports dynamic client registration, or uses a pre-registered client.
- The client performs the authorization-code flow with PKCE for user-delegated access.
- The authorization server issues an audience-bound access token for the MCP resource.
- The client presents that token to the MCP server.
The client should include the MCP server as the requested resource so the authorization server can bind the token to the intended audience. The MCP server must validate that the token was issued for it. It must not accept a token intended for another API and must not pass an MCP token through to an upstream service.
That last rule prevents a common but dangerous shortcut. If your MCP server accepts a customer’s GitHub token directly and forwards it upstream, you have combined two authorization domains. The upstream service may understand broad user permissions that your MCP tools never intended to expose.
Test the lifecycle, not just the login
A successful login proves very little. Test the state transitions that matter after customers start using the product:
- An expired access token is rejected.
- A refresh token creates a valid new access token.
- Refresh-token reuse is detected and the grant is revoked.
- A revoked grant cannot refresh.
- A revoked grant cannot use an outstanding access token.
- A token issued for another MCP server is rejected.
- A client missing a required scope is denied.
- A token for Customer A cannot read or modify Customer B’s resource.
- A queued job cannot resume with a revoked grant.
- Logs and traces do not contain raw tokens.
- Disconnecting the integration eventually stops all relevant activity.
Include server-to-server and client-credentials cases only when they match the product. OAuth is not automatically a user-consent flow. A client-credentials grant represents an application acting as itself; it must not be used to impersonate a customer.
A lean implementation path for an indie developer
You can start with a small, controlled architecture:
- Use one dedicated authorization server or a focused identity service that supports OAuth 2.1, authorization code with PKCE, short-lived access tokens, refresh-token rotation, revocation, and resource indicators.
- Store authorization grants in your application database, including customer, client, scopes, status, creation time, expiry, and revocation time.
- Keep access tokens stateless if your identity setup supports reliable validation. Keep durable grant and revocation information in your database.
- Add a middleware layer that validates audience, issuer, signature, expiry, and required scope.
- Put tenant ownership checks inside each sensitive tool or its data-access function.
- Add an audit record for grant changes, scope changes, revocation, and sensitive tool calls.
- Test expired, refreshed, revoked, wrong-audience, wrong-tenant, and missing-scope cases before launch.
Add infrastructure only when a measured requirement appears. A separate policy service may help when authorization rules span many services. A gateway may help when several MCP servers need consistent enforcement. Neither is necessary merely to make a single-customer or small multi-tenant product look enterprise-ready.
The commercial benefit is straightforward. Narrow scopes reduce the blast radius of a flawed agent. Reliable refresh reduces interrupted customer workflows. Fast revocation makes disconnect and security support trustworthy. Tenant checks prevent one customer’s data from becoming another customer’s incident. These features protect revenue by keeping the product dependable, even when they do not appear in a sales demo.
Common mistakes to avoid
Using one shared token for the whole product. It simplifies implementation but destroys attribution, revocation, and tenant isolation.
Treating a valid token as permission for every tool. Token validation and tool authorization answer different questions.
Making long-lived access tokens compensate for missing refresh. This turns a manageable token leak into a long exposure window.
Revoking only the refresh token. An already-issued access token may continue to work unless the server checks grant state or the token is otherwise invalidated.
Letting the model choose the tenant. Tenant identity must come from trusted authorization context.
Logging whole headers for debugging. Authorization headers are credentials, not ordinary metadata.
Copying upstream tokens into MCP requests. MCP servers should use audience-bound tokens of their own and perform upstream authorization separately.
For a repeatable review of existing permission grants, use the MCP Server Permission Scope Audit Checklist for Founders before expanding what agents can access.
Frequently asked questions
Should every MCP client use OAuth?
OAuth is optional at the protocol level and is not the normal mechanism for local stdio servers, which can obtain credentials from their environment. It becomes important when a remote HTTP MCP server exposes customer data, accepts delegated actions, or needs per-user attribution and revocation.
Are short access tokens worth the extra refresh logic?
Usually, yes. The refresh path is operational work, but it contains the damage from a stolen token and gives you a clean place to rotate credentials. Build and test refresh before launch rather than treating it as a post-production optimization.
Can scopes replace per-record authorization?\n
No. Scopes describe delegated capabilities at a coarse level. Per-resource checks ensure that the authenticated customer owns or may access the specific object being read or changed. A multi-tenant product generally needs both.
Do I need a separate enterprise identity provider?
Not for the first version of a small product. You need a reliable authorization server, a durable grant store, correct validation, and solid tests. Adopt a dedicated provider when its security, compliance, or operational capabilities justify the integration cost.
What should happen immediately after a customer revokes access?
Mark the grant inactive, stop refreshes, invalidate relevant sessions or cached authorization, prevent queued work from using the old grant, and retain an auditable event. If your product promises immediate disconnect, verify those paths rather than relying on access-token expiry.
Bottom line
For a customer-facing MCP agent, OAuth is the credential exchange mechanism, not the complete security model.
Design the lifecycle around a simple chain: delegate narrowly, issue short-lived tokens, refresh through rotation, revoke the grant, and check tenant ownership on every protected tool call. That gives a small product the benefits that matter operationally—customer isolation, recoverable sessions, attributable actions, and a disconnect customers can trust—without requiring enterprise-scale infrastructure.
Sources
- https://modelcontextprotocol.io/specification/2025-03-26/basic/authorization
- https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization/security-considerations
- https://modelcontextprotocol.io/docs/2026-07-28/tutorials/security/authorization
- https://www.prefect.io/resources/mcp-oauth
- https://www.permit.io/blog/oauth-on-mcp
- https://curity.io/resources/learn/mcp-authorization-lifecycle
- https://blog.gitguardian.com/oauth-for-mcp-emerging-enterprise-patterns-for-agent-authorization







