Skip to main content

MCP authorization: what an API gateway must enforce in 2026

MCP spec 2026-07-28 drops Dynamic Client Registration for Client ID Metadata Documents and adds RFC 9207 checks. Who implements what, and what Zerq enforces.

  • mcp
  • ai-agents
  • security
  • access-control
  • compliance
Zerq team

Updated November 2026: rewritten for the 2026-07-28 revision of the Model Context Protocol specification, which deprecates Dynamic Client Registration in favor of Client ID Metadata Documents, adds RFC 9207 issuer checks and removes protocol-level sessions.

MCP authorization is OAuth 2.1 with the MCP server as the protected resource. The server publishes RFC 9728 metadata, your identity provider issues the tokens, and the gateway rejects anything whose issuer or audience is wrong. The 2026-07-28 revision changes how clients register and adds issuer checks, and both of those land on the client and the identity provider. What the gateway must still get right is discovery metadata, token validation, scope enforcement and a record of every tool call that reaches an API or changes configuration.

That split matters because gateway teams get asked to "implement the MCP auth spec" as if it were one thing. It is three things owned by three parties, and most of the new text in the current revision is addressed to MCP clients such as Claude, Cursor and ChatGPT, and to authorization servers such as Keycloak, Entra ID and Okta. The resource-server half, which is where Zerq's MCP surfaces sit, has been stable since the spec first adopted OAuth 2.1. The spec calls authorization optional and says HTTP transports should conform; in a bank or a hospital, "optional" is not how your auditors will read it. This post lists what changed, who implements each requirement, what Zerq enforces on its two MCP surfaces, and where the gaps are.

What changed in the 2026-07-28 MCP authorization specification?

The changelog lists four authorization items since the 2025-11-25 revision, plus transport changes that affect anyone operating an MCP server behind a gateway.

  1. Dynamic Client Registration is deprecated. RFC 7591 registration "remains available for backwards compatibility with authorization servers that do not support Client ID Metadata Documents," but new implementations should not adopt it. The replacement is a Client ID Metadata Document (CIMD): the client_id is an HTTPS URL that serves a JSON document with the client's client_name and redirect_uris, so the authorization server fetches the client's metadata instead of registering it. Clients and authorization servers SHOULD support it, and authorization servers advertise it with client_id_metadata_document_supported. The IETF draft behind it, draft-ietf-oauth-client-id-metadata-document-02 of 6 July 2026, is a working-group document, not yet an RFC.
  2. Issuer identification. Authorization servers SHOULD include the iss parameter in authorization responses per RFC 9207, and clients MUST validate a present iss against the issuer they recorded before redeeming the authorization code. The spec says it expects to raise the server side from SHOULD to MUST in a later revision.
  3. Credentials are bound to the issuer. Clients MUST key persisted client credentials by the authorization server's issuer, MUST NOT reuse them with a different authorization server, and MUST re-register when the server changes.
  4. application_type during registration. Where DCR is still used, clients MUST send application_type (native or web) to avoid OpenID Connect redirect URI conflicts.

The requirements that did not change are the ones the gateway is measured against. MCP servers MUST implement RFC 9728 Protected Resource Metadata and MUST publish at least one authorization_servers entry. Clients MUST send the RFC 8707 resource parameter, and servers MUST validate that a token was issued for them as the audience. Servers MUST NOT pass a client's token through to upstream APIs. Invalid or expired tokens get 401, insufficient scope gets 403, and the server SHOULD include a scope attribute in the WWW-Authenticate challenge.

The transport changed more than the authorization text did. The current revision removes protocol-level sessions and the Mcp-Session-Id header, replaces the initialize handshake with a protocol version carried in every request's _meta, requires MCP-Protocol-Version, Mcp-Method and Mcp-Name headers on every POST, requires servers to implement server/discover, and replaces the GET stream with subscriptions/listen. Revisions 2025-11-25 and earlier are now "legacy," and a server MAY serve both eras on one endpoint. Zerq's MCP servers are legacy-era servers today; the limitations section spells out what that means.

Who implements each requirement: client, identity provider or gateway?

RequirementLevelLands onWhat a gateway operator verifies
RFC 9728 metadata, and a 401 that points to itMUSTMCP serverThe metadata URL answers, and its resource value equals the URL clients call
Audience validation (RFC 8707 section 2)MUSTMCP serverTokens for another audience are refused with 401
resource parameter in authorization and token requestsMUSTMCP clientThe identity provider accepts the parameter or maps the MCP URL to an audience
RFC 8414 or OpenID Connect DiscoveryMUST (one of)Identity providerIssuer metadata is reachable from where the MCP client runs
Client ID Metadata DocumentsSHOULDClient and identity providerclient_id_metadata_document_supported is true, or clients are pre-registered
Dynamic Client RegistrationMAY, deprecatedClient and identity providerNothing new is built on it; existing registrations have a migration date
iss in authorization responsesSHOULD (server), MUST validate (client)Identity provider and clientauthorization_response_iss_parameter_supported is true
PKCE with S256MUSTClient and identity providercode_challenge_methods_supported is present in issuer metadata
scope in the challenge, step-up on insufficient_scopeSHOULDMCP server and clientKnown gap if the server returns a plain 403
No token passthrough to upstream APIsMUSTMCP serverUpstream calls use the server's own credentials

Client registration is entirely outside the gateway: Zerq is the resource server, not the authorization server, so CIMD support is your identity provider's feature. The audience row is where most deployments fail: an identity provider that ignores resource issues a token with a generic audience, and a resource server that skips the aud check accepts it.

How Zerq's Management MCP implements the resource-server half

Management MCP is the surface operators and automation agents use to change the platform: collections, proxies, workflows, policies, clients, profiles, credentials and the AI Gateway catalog. It is an OIDC-protected resource with no client or profile headers, and it implements the discovery half of the MCP authorization spec.

Step 1: name the resource and the issuer

The server is mounted at /api/v1 plus MCP_MANAGEMENT_PATH and stays off until that variable is set. The metadata document is built from environment variables, so the public URL has to be exact.

# Management-plane OIDC trust (the same values protect the console and the Management API)
OIDC_ENABLED=true
OIDC_ISSUER_URL=https://auth.example.com/realms/api-platform   # must equal the token's iss, byte for byte
OIDC_AUDIENCE=zerq-management                                   # must appear in the token's aud
OIDC_ROLE_CLAIM_PATH=roles                                      # dot path to the roles claim; default "roles"
OIDC_VIEWER_ROLES=viewer                                        # role lists are separate tiers, not a hierarchy
OIDC_MODIFIER_ROLES=modifier
OIDC_AUDITOR_ROLES=auditor
OIDC_ADMIN_ROLES=admin

# Management MCP and its RFC 9728 metadata
MCP_MANAGEMENT_PATH=/mcp                                        # served at /api/v1/mcp; unset = Management MCP disabled
BACKEND_PUBLIC_URL=https://gateway.example.com                  # used for the WWW-Authenticate resource_metadata URL
MCP_MANAGEMENT_PUBLIC_URL=https://gateway.example.com/api/v1/mcp  # the "resource" value; defaults to BACKEND_PUBLIC_URL + /api/v1 + path
OIDC_ISSUER_PUBLIC_URL=https://auth.example.com/realms/api-platform  # "authorization_servers" entry; falls back to OIDC_ISSUER_URL

RFC 9728 section 3.3 says the resource value "MUST be identical to the URL that the client used to make the request to the resource server," and a compliant client MUST NOT use the metadata otherwise. So if agents reach the gateway through https://api.bank.example/api/v1/mcp, that string, not an internal hostname, belongs in MCP_MANAGEMENT_PUBLIC_URL.

Step 2: the challenge and the metadata document

A request without a token gets the challenge the spec asks for. The realm is there because some clients will not treat the response as a Bearer challenge without one.

POST /api/v1/mcp HTTP/1.1
Host: gateway.example.com
Content-Type: application/json

HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer realm="Zerq Management MCP", resource_metadata="https://gateway.example.com/api/v1/.well-known/oauth-protected-resource"
Content-Type: application/json

{"error":"Missing Authorization header"}

The client follows resource_metadata. The same document is also served at the host root, /.well-known/oauth-protected-resource, for clients that construct the well-known URL themselves.

{
  "resource": "https://gateway.example.com/api/v1/mcp",
  "authorization_servers": ["https://auth.example.com/realms/api-platform"],
  "scopes_supported": ["openid", "email", "profile", "roles", "audience"],
  "bearer_methods_supported": ["header"],
  "resource_name": "Zerq Management MCP"
}

From here the client reads the issuer's discovery document, registers or presents its client ID, runs the authorization code flow with PKCE and the resource parameter, and comes back with a Bearer token. Zerq takes no part in that leg. The challenge carries no scope attribute, so a spec-following client falls back to scopes_supported, which is why that list holds the OpenID scopes a Keycloak or Entra realm needs rather than MCP-specific scopes.

Step 3: what the token has to contain

Every request to Management MCP is validated the same way as a request to the Management API:

  1. The JWT must be RSA-signed with a kid that resolves in the issuer's JWKS; other algorithms are rejected.
  2. iss must equal OIDC_ISSUER_URL exactly. There is no normalization of trailing slashes or case.
  3. aud must be the configured OIDC_AUDIENCE, either as a string or as one entry in an array.
  4. exp must be in the future.
  5. The roles found at OIDC_ROLE_CLAIM_PATH must intersect the role list for the route. The MCP endpoint itself requires a viewer role; each tool then forwards the same Bearer token to the Management API route it calls, so a viewer can run list_clients but gets 403 from create_client, and list_audit_logs needs an auditor role.

Failures in steps 1 to 4 return 401 with the WWW-Authenticate challenge above. A role failure returns 403 with {"error":"Insufficient permissions"} and no insufficient_scope challenge, which is one of the gaps listed below.

The audience check is the one to get right with your identity provider. Zerq compares aud to a configured string, not to the MCP URL, so a token requested with resource=https://gateway.example.com/api/v1/mcp must come back carrying zerq-management (or whatever you chose). A token minted for the management console passes the same check, because the console, the Management API and Management MCP are one resource server with one RBAC model; see Management MCP for the role tiers.

Step 4: the session and the tool call

Zerq's servers still speak the handshake-based protocol. The first message is initialize; the response carries an Mcp-Session-Id header that every later request must echo, or the server answers 400 Mcp-Session-Id required after initialize.

# 1. initialize (the response header Mcp-Session-Id is required on every later call)
curl -i https://gateway.example.com/api/v1/mcp \
  -H "Authorization: Bearer $OIDC_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize",
       "params":{"protocolVersion":"2025-11-25","capabilities":{},
                 "clientInfo":{"name":"ops-agent","version":"1.0"}}}'
# -> {"jsonrpc":"2.0","id":1,"result":{"protocolVersion":"2024-11-05", ...}}

# 2. tools/list returns 90 tools: 57 platform tools plus 33 ai_* tools for the AI Gateway
curl -s https://gateway.example.com/api/v1/mcp \
  -H "Authorization: Bearer $OIDC_ACCESS_TOKEN" \
  -H "Mcp-Session-Id: $SESSION_ID" -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/list"}'

# 3. a mutation: the tool forwards this same Bearer token to PUT /api/v1/clients/:id
curl -s https://gateway.example.com/api/v1/mcp \
  -H "Authorization: Bearer $OIDC_ACCESS_TOKEN" \
  -H "Mcp-Session-Id: $SESSION_ID" -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":3,"method":"tools/call",
       "params":{"name":"update_client","arguments":{"id":"6650f1c2a9b3e4d5f6a7b8c9","active":false}}}'

Whatever protocolVersion the client asks for, the server answers 2024-11-05, and the client decides whether it can work with that. The server does not read the MCP-Protocol-Version header.

How Gateway MCP authenticates agents, and where it diverges from the spec

Gateway MCP, at MCP_PATH (default /mcp), is the surface agents use to discover and call published APIs. It does not use OAuth discovery: its 401 is a JSON error without a WWW-Authenticate challenge, and identity comes from the client and profile model REST callers use, X-Client-ID, X-Profile-ID and a credential matching the profile's auth type.

The auth types are token (a Zerq-issued bearer token, revealed only through an audited, modifier-only action), jwt (an HMAC token signed with JWT_SECRET whose client_id and profile_id claims must match the headers), oidc (a token from your identity provider), mtls (checked at your TLS terminator) and none. For oidc, Zerq validates the signature against the JWKS of GATEWAY_OIDC_ISSUER_URL, requires iss to equal it and aud to contain GATEWAY_OIDC_AUDIENCE, and checks exp. If the token carries client_id or profile_id claims they must match the headers; if it carries neither, any valid token for that audience satisfies any oidc profile. To bind a token to one agent, have the provider emit those two claims, or set requireCertificateBoundToken so the token's cnf.x5t#S256 must match the client certificate per RFC 8705, as the FAPI 2.0 post shows.

Three enforcement details catch teams out:

  • Every MCP message is an HTTP POST to /mcp, and the profile's allowed-methods check runs on that transport request before initialize is parsed. A profile created without methods defaults to GET only, so an MCP agent's profile must list POST; the read-only boundary then comes from collection assignment and each endpoint's own methods, as the read-only agent guide explains.
  • Discovery is scoped by data, not by filtering. list_collections, list_endpoints and endpoint_details iterate only the client's assigned, active collections and their published endpoints; anything else does not exist as far as the tools are concerned.
  • execute_endpoint takes method, path and optional body, headers and query, then loops back over HTTP to the gateway with X-Client-ID, X-Profile-ID, the forwarded Authorization header and X-Gateway-Source: mcp. The gateway applies its full set of controls: a bad credential is 401, a call from outside the IP allowlist 403, a method the profile does not allow 405, a path outside the assigned collections 404, and a rate limit or quota refusal 429, before the proxy or workflow runs. The tool result wraps the gateway's status_code, body and headers; any status of 400 or above comes back as isError: true with the cause Gateway returned 405 (or whichever status), while the MCP response itself stays HTTP 200.
{
  "jsonrpc": "2.0",
  "id": 4,
  "result": {
    "content": [{ "type": "text",
      "text": "{\"status_code\":405,\"body\":\"{\\\"error\\\":\\\"HTTP method not allowed\\\"}\",\"headers\":{...}}" }],
    "isError": true,
    "cause": { "message": "Gateway returned 405" }
  }
}

Your agent framework has to handle that shape: a refused call is a successful JSON-RPC exchange with an error result inside.

What the audit trail records for an MCP tool call

Two records matter, in two collections of your own MongoDB. Every execute_endpoint call produces a gateway request log entry, because the loopback request passes through the normal gateway route. Discovery tools and the MCP transport request itself do not write request log entries; they are counted in the zerq_mcp_tool_calls_total metric (labels server, tool, result) when the Prometheus listener is on.

{
  "method": "GET",
  "path": "/accounts/v1/balances",            // the gateway path the agent asked for
  "status": 200,
  "latency": 87,                              // milliseconds, whole request
  "created_at": "2026-11-02T08:14:11.304Z",
  "client_ip": "127.0.0.1",                   // the TCP peer, which is the gateway host itself for loopback calls
  "client_id": "6650f1c2a9b3e4d5f6a7b8c9",    // the authenticated client, not the raw header
  "profile_id": "6650f1d9a9b3e4d5f6a7b8d0",
  "collection": "6650ef10a9b3e4d5f6a7b8aa",   // collection ID matched for the path
  "request_id": "f0c1…",
  "trace_id": "4bf92f3577b34da6a3ce929d0e0e4736",
  "request_headers": {
    "Authorization": "[REDACTED]",            // credential headers are replaced before storage
    "X-Gateway-Source": "mcp",                // set by the MCP server on loopback calls
    "X-Client-ID": "6650f1c2a9b3e4d5f6a7b8c9",
    "X-Profile-ID": "6650f1d9a9b3e4d5f6a7b8d0"
  }
}

client_ip is the loopback peer, so attribute MCP traffic by the authenticated client_id and profile_id, which are what the gateway verified; X-Gateway-Source: mcp is a convenience label for separating tool calls in reviews.

A Management MCP mutation produces an audit entry at the Management API route the tool called. The actor is the email claim of the forwarded token, actor_type is the comma-joined list of roles on that token, and the entry is part of the tamper-evident chain: seq, prev_hash and hash (SHA-256, or HMAC-SHA256 when AUDIT_CHAIN_KEY is set), which an auditor can check with GET /api/v1/audit/verify and export with GET /api/v1/audit/export.

{
  "timestamp": "2026-11-02T08:16:40.112Z",
  "actor_id": "[email protected]",      // email claim of the OIDC token the MCP tool forwarded
  "actor_type": "modifier",                  // roles on the token, comma-joined
  "resource_type": "client",
  "action": "update",                        // from audit_rules.yaml for PUT /api/v1/clients/:id
  "ip_address": "127.0.0.1",                 // the MCP server's loopback call to the Management API
  "user_agent": "Go-http-client/1.1",
  "request_id": "9a7e…",
  "trace_id": "4bf92f3577b34da6a3ce929d0e0e4736",
  "metadata": { "url": "/api/v1/clients/6650f1c2a9b3e4d5f6a7b8c9", "request_body": "{\"active\":false}", "status_code": 200 },
  "seq": 48213, "prev_hash": "e3b0…", "hash": "9f86…"
}

The audit entry does not say "this came through MCP." The actor is the identity on the token: an agent under a service account is attributed to that account, and an operator using Cursor to themselves. To tell MCP-originated changes apart, give automation its own identity in the identity provider. Role-gated reads, retention and export are covered under security and observability.

An MCP authorization checklist for gateway operators

  1. Does GET /api/v1/.well-known/oauth-protected-resource return a resource value identical to the URL your MCP clients call?
  2. Does a tokenless POST to the MCP endpoint return 401 with a WWW-Authenticate header naming resource_metadata?
  3. Does the identity provider put the configured audience into tokens requested with resource=<your MCP URL>, and is any other audience refused?
  4. Does the issuer metadata advertise code_challenge_methods_supported with S256 and authorization_response_iss_parameter_supported: true?
  5. Does it advertise client_id_metadata_document_supported, and if not, is every MCP client pre-registered rather than dynamically registered?
  6. Are automation agents and humans separate identities, so actor_id in the audit log tells them apart?
  7. Do agent profiles on Gateway MCP list POST, with the write boundary expressed as collections and endpoint methods?
  8. Do oidc agent profiles rely on client_id and profile_id claims or on certificate binding, not on audience alone?
  9. Does your review of denied MCP calls look inside tool results for isError and the wrapped status_code?
  10. Has the audit chain been verified since the last platform change, and does retention match your record-keeping period?

Limitations and when Zerq isn't the right fit

  • Zerq's MCP servers are legacy-era servers. Both surfaces answer initialize with protocolVersion: "2024-11-05", require Mcp-Session-Id after the handshake, and do not implement server/discover, the MCP-Protocol-Version, Mcp-Method and Mcp-Name headers, or subscriptions/listen. Clients that still speak the handshake-based revisions connect; a client built only for 2026-07-28 will not.
  • Sessions live in process memory. The session store is a map inside each backend replica, with no Redis sharing and no expiry. Behind multiple replicas you need session affinity at the ingress or the second request fails with 400 Invalid or expired session; the multi-replica post covers what is and is not shared across replicas.
  • Gateway MCP has no OAuth discovery. Agents are system principals configured with headers. There is no user-delegated flow, no token exchange and no per-tool scopes; the authorization unit is the profile, with collections, methods, IP allowlists and limits. An agent acting on behalf of a named end user with that user's token is not something the gateway does today.
  • Role failures are plain 403s. No insufficient_scope challenge and no scope attribute in the 401, so the spec's step-up flow has nothing to act on. Roles are the four management tiers, not fine-grained scopes.
  • Client registration is your identity provider's feature. Zerq is never the authorization server; a gateway that registers clients, serves CIMDs or mints tokens is a different product.
  • The oidc profile type binds to a profile only if the token carries Zerq's client_id and profile_id claims or a certificate thumbprint. Audience alone identifies the resource, not the agent.

What this looks like in practice

Illustrative scenario, not a specific customer deployment.

A retail bank's platform team runs Zerq on-prem with Keycloak as the management identity provider. Before the change, two engineers had Cursor connected to Management MCP with a static header copied from a service account, and a reconciliation agent reached the accounts APIs through Gateway MCP with a token profile created through the API and left at the default GET-only methods. Its initialize calls failed with 405, so someone had "fixed" it by letting the agent call the REST endpoints directly.

The team set MCP_MANAGEMENT_PUBLIC_URL to the public MCP URL, mapped Keycloak realm roles to OIDC_VIEWER_ROLES and OIDC_MODIFIER_ROLES, gave the agent its own Keycloak client whose client scope adds the Zerq client_id and profile_id claims, and switched its profile to oidc with GET and POST allowed and one assigned collection, accounts-read. Cursor was reconfigured with only the endpoint URL; it followed the 401 challenge, logged each engineer in through Keycloak, and received tokens with aud: zerq-management. Dynamic Client Registration stayed off in the realm; the Cursor installs were pre-registered as confidential clients.

Afterward, the audit log shows the engineers' own email addresses as actor_id for changes made from Cursor, and the request log shows the agent's client_id with collection set to accounts-read. A test execute_endpoint with POST against a balances endpoint came back as isError: true with status_code: 405 from the endpoint's own method list, and a call into the payments collection came back 404, both visible in Logs. The audit chain verifies clean, and zerq_mcp_tool_calls_total{server="mcp_gateway",result="error"} sits on the dashboard the team already watched.

Closing summary

MCP authorization is OAuth 2.1 with the MCP server as the resource server, and the 2026-07-28 revision mostly changes the client and identity-provider sides: Client ID Metadata Documents replace Dynamic Client Registration, and RFC 9207 issuer checks become expected. Zerq's Management MCP publishes RFC 9728 metadata, challenges with resource_metadata, validates issuer, audience, expiry and roles, and forwards the caller's own token so RBAC and the hash-chained audit log apply unchanged. Gateway MCP uses the client and profile model instead of OAuth discovery, scopes discovery to assigned collections, and runs every execute_endpoint through the same chain as REST traffic. The gaps are listed: a legacy protocol revision, in-memory sessions, no per-tool scopes, no step-up challenge and no user-delegated agents. Check the identity provider's resource and audience handling first, because that is where most MCP authorization failures happen.

Sources


Zerq is an enterprise API gateway built for regulated industries — one platform for API management, AI agent access, compliance audit, and developer portal, running entirely in your own infrastructure. See how it works or request a demo to walk through your specific requirements.