Est.
MCP GatewayLong read

MCP Server Authentication and Authorization Patterns

OAuth 2.1 and resource-bound tokens replaced MCP's trust-by-proximity model in just twenty months.

Contributing Editor · · 9 min read
Cover illustration for “MCP Server Authentication and Authorization Patterns”
MCP Gateway · September 26, 2026 · 9 min read · 1,990 words

MCP authentication went from nonexistent to genuinely sophisticated in about twenty months, which in protocol years is roughly the equivalent of a toddler picking up a second language. The Model Context Protocol now leans on OAuth 2.1, resource-bound tokens, and workload identity to decide who gets to talk to what. Understanding how each layer arrived, and why, is the actual groundwork for running an MCP deployment that won't embarrass anyone in an incident report.

How MCP authentication requirements evolved

Diagram: MCP Authentication: Twenty Months of Evolution. Visualizes: Show a timeline of four MCP specification milestones and what each one introduced.

MCP shipped on November 5, 2024 with no mandatory authentication for remote servers. The model was local tool, local trust: if the thing was running on a machine, the machine's owner was assumed to be the only one talking to it. Fine for a demo. Less fine the moment anyone put an MCP server on a network.

The March 26, 2025 revision fixed that gap by requiring OAuth 2.1 as the framework for HTTP-based auth, whenever a server bothered to support authorization at all (authorization itself stayed optional, if strongly recommended). RFC 7636 made Authorization Code grant with PKCE mandatory. That's the standard OAuth pattern most developers already know from logging into apps with a major identity provider.

Then came June 18, 2025, and the spec grew up considerably. Protected Resource Metadata (RFC 9728) arrived so clients could discover which authorization server actually issues tokens for a given resource. OAuth 2.0 Resource Indicators (RFC 8707) became required: every token gets bound to exactly one resource server, no exceptions. Audience validation became mandatory alongside it. Most importantly, the spec split roles that had been blurred together: the MCP server stopped being both gatekeeper and resource, and became a pure resource server that checks tokens issued by somebody else's identity provider. Separation of concerns, finally applied to a protocol that badly needed it.

July 28, 2026 brought the biggest overhaul yet. The protocol core went stateless, dropping the Mcp-Session-Id header and the initialize handshake. Dynamic Client Registration got formally deprecated in favor of Client ID Metadata Documents, with a twelve-month window so nobody's integration breaks overnight. Authorization responses now carry a validated issuer claim under RFC 9207, and clients have to compare that claim against the issuer they recorded earlier in the flow, refusing outright on any mismatch. That single check closes off mix-up attacks, where a malicious authorization server tries to pass off a token as though it came from somewhere legitimate. Six more requirements got layered on top, mostly just formalizing behavior that competent authorization servers were already doing anyway.

Why stateless protocol architecture changes the enforcement model

Before July 2026, MCP sessions carried state across requests. Request number six could quietly inherit context established back in request two, on the assumption both were hitting the same server instance. Convenient, until it isn't.

After July 2026, every request has to describe itself completely: protocol version, client identity, and capabilities travel with each request, and the authorization token rides along rather than getting set once at the start and reused like a hall pass. Nothing carries over by assumption anymore.

The operational upside shows up as a straightforward scaling win. MCP servers can now sit behind a plain round-robin load balancer, no sticky sessions, no shared session store keeping every node in sync. That's a straightforward scaling win. The security consequence is just as direct: authorization has to bind to the audience-scoped token attached to the request in front of you, full stop. Nothing can be inferred from what happened three requests ago in the same conversation, because as far as the server's concerned, there is no "same conversation" anymore. Every request stands alone, like a stranger walking into a bar with no tab and no history.

Pattern one: user-delegated access with Authorization Code and PKCE

This is the pattern for an AI assistant acting on behalf of one specific person, where access needs to stop exactly where that person's access stops. No more, no less.

The mechanics run like this. A client shows up at an MCP server with no token and gets a 401 back, along with a WWW-Authenticate header pointing to a resource_metadata URL. The client fetches that Protected Resource Metadata document, which names the resource and lists which authorization servers are allowed to issue tokens for it. From there the client pulls the authorization server's own metadata, including issuer, endpoints, and PKCE support, and records that issuer value for later comparison.

PKCE earns its keep here. The client generates a code_verifier, a random secret, and sends only a hashed version (the code_challenge) in the authorization request. The verifier itself never touches the browser redirect. MCP requires the S256 hashing method specifically, and clients need to check code_challenge_methods_supported in the server metadata before proceeding, halting if it's missing rather than downgrading quietly. At token redemption, the client presents the real verifier, and the authorization server only issues a token if that verifier hashes to match the original challenge. RFC 8707 binds every token to a specific resource server, and the MCP server rejects any token with the wrong audience even if the signature checks out and the token hasn't expired. The July 2026 revision also introduced issuer validation on authorization responses, with clients required to refuse on any mismatch, closing off mix-up attacks.

PKCE stops an intercepted authorization code from being redeemed by a different client than the one it was issued to. What it does not do is verify which piece of software is actually holding the verifier in the first place, and that gap is what workload identity exists to close later on.

As for credential choice: short-lived OAuth 2.1 access tokens are the recommended default for production. API keys don't expire on their own and offer no fine-grained control, which makes them a liability once there are many users spread across external systems. JWTs carry identity claims baked in, but someone still has to write the authorization logic that decides what those claims are allowed to do.

Pattern two: machine-to-machine access for unattended agents

Scheduled jobs don't wait for a human to log in first. Neither does a background service running at 3 a.m., or an autonomous workflow with nobody sitting behind it to click "approve."

For that case, For unattended scenarios, MCP supports machine-to-machine OAuth flows, letting an unattended client authenticate directly with the authorization server, no browser, no user approval step. Under this approach, short-lived, tightly scoped credentials are strongly preferred over long-lived shared secrets, mostly because a shared secret sitting in a config file is one leaked repo away from becoming everyone's problem.

The identity principle that actually matters here is least privilege. An agent should operate only within the bounds its delegating context permits, not expand them. If the agent is given a longer leash than the situation warrants, it eventually wanders somewhere it shouldn't.

Pattern three: enterprise-managed authorization through an identity provider

Thousands of employees, one company, and access policy that needs to live in the identity provider's admin console rather than getting reconstructed after the fact from a pile of individual OAuth consent clicks. That's the problem Enterprise-Managed Authorization solves.

The June 2026 EMA extension makes the enterprise IdP the authoritative provisioner for MCP server access. Users authenticate once through whatever identity system the company already runs, and the IdP automatically provisions the MCP servers that user is cleared to use. No per-server consent screens stacking up, no mixing personal and work accounts, no manual setup per tool. Everything lands in one auditable trail inside the admin console, which is the part security teams actually care about at audit time.

Okta's implementation runs through Agent SSO, which reached general availability on August 24, 2026. Okta built XAA as its OAuth extension for agentic identity federation across MCP workflows. Agent SSO registers an AI agent as a first-class identity inside Okta's Universal Directory, issuing short-lived, governed tokens instead of static API keys that sit around indefinitely. It ships inside core Okta SSO at no added cost, so the deployment decision comes down to rollout planning rather than a pricing conversation. XAA preserves verified user identity through asynchronous, chained workflows, keeping agent access tied to the delegating user's identity. As of 2026, XAA has native integrations across more than 25 major cloud, developer, and enterprise SaaS platforms. There's also prompt-level tool scoping: Okta filters out unauthorized MCP tools before the model ever executes anything, based on the delegating user's identity, which cuts schema token costs by more than 90% while shrinking the attack surface at the same time. Two birds, one filter.

Microsoft's answer is Entra Agent ID, general availability May 2026. It extends Conditional Access, lifecycle management, and access governance, tools built for human accounts, to non-human ones. An agent identity here is a specialized service principal that obtains short-lived tokens after a user or tenant admin consents. It speaks OAuth 2.0, MCP, and A2A natively, and can onboard third-party agents built on AWS Bedrock or n8n through a sidecar SDK or workload identity federation. The licensing, though, is where things get complicated: full agent security coverage needs Microsoft 365 E7, or E5 (or the E5/A5/Business Premium equivalents) paired with a standalone Microsoft Agent 365 license. Full agent security coverage needs Microsoft 365 E7, or E5 (or the E5/A5/Business Premium equivalents) paired with a standalone Microsoft Agent 365 license.

Workload identity and mTLS for cryptographic agent assurance

A gap survives all of the above. PKCE and Client Credentials both prove a token was issued the right way, through the right handshake, by the right authorization server. Neither one proves which piece of software is holding that token when it shows up at your door. A stolen but valid token still looks exactly like a legitimate one to a server that only checks signatures and expiry.

Mutual TLS closes that gap by binding identity to cryptographic keys rather than a bearer string anyone can copy and replay. Replay attacks get considerably harder under mTLS than under a plain bearer token scheme, and mTLS functions as an enterprise-grade complement that sits alongside OAuth rather than replacing it.

The operational catch with mTLS has always been certificate management. That matters specifically for agentic systems, because agents in production don't behave like long-lived services. They spin up, do a task, and disappear, sometimes within minutes. Manually managing certificates for infrastructure that ephemeral would be a full-time job for someone, which is exactly why automated certificate issuance and rotation tooling becomes essential at scale.

The MCP gateway as the practical enforcement layer

A gateway is the control plane that authenticates, authorizes, filters, and logs every request passing between an agent and whatever MCP servers it's allowed to reach. Point agents at the gateway, manage tool access centrally, and stop handing out direct credentials to every server one at a time. That's the pitch, and it holds up.

The category exists because the gaps are real and openly acknowledged: the official 2026 MCP roadmap flags missing pieces around audit trails, SSO-integrated auth, gateway behavior, and configuration portability. The gateway is where production teams fill those gaps today, ahead of whatever the spec eventually standardizes.

On enforcement specifically, the gateway absorbs the OAuth 2.1 flows, the token validation, and the identity provider integration, so individual MCP servers can stay focused on doing their actual job: serving resources. A dedicated authentication service inside the gateway translates enterprise identity tokens into MCP-specific credentials, one conversion point instead of dozens scattered across every server.

Then there's shadow IT, which is really just an old problem wearing a new hat. Without a centralized, IT-curated registry of approved MCP servers, individual developers spin up their own on their own machines, unmonitored, unreviewed, invisible to anyone doing security posture reviews. A gateway paired with a server registry functions as an internal app store: approved tools in one place, discoverable, governed, logged. It kills shadow MCP instances the same way API gateways killed shadow API consumption a decade earlier. Different protocol, same fix.

Sources

  1. MCP Authorization: OAuth 2.1, PKCE, and Agent Identity | Aembit
  2. Core Differences Between MCP Authentication and Authorization
  3. Is that allowed? Authentication and authorization in Model Context Protocol - Stack Overflow
  4. Diving Into the MCP Authorization Specification
  5. aembit.io
  6. The Evolution of MCP Auth: Every Spec, Every Lesson (2024–11–05 → 2026–07–28 draft) | by Ayesha Dissanayaka | Medium
  7. The New MCP Authorization Specification
  8. workos.com
Filed underMCP Gateway

More in MCP Gateway