Skip to content

MCP authorization spec support

The MCP authorization specification builds on OAuth 2.1: protected-resource metadata (RFC 9728), authorization-server metadata (RFC 8414 / OpenID Connect discovery), PKCE, and either dynamic client registration (RFC 7591) or Client ID Metadata Documents. The Brutor facade at /v1/proxy/oauth/{mcp_server_id}/{idp_server_id} implements these as follows.

Spec element Brutor endpoint Status
Protected-resource metadata (RFC 9728) GET .../.well-known/oauth-protected-resource Served; authorization_servers is the facade
Authorization-server discovery GET .../.well-known/openid-configuration Served, endpoints rewritten to the facade. There is no oauth-authorization-server document at the facade
Authorization endpoint GET .../authorize 307 to the IdP for registered clients; bridged for CIMD clients
PKCE S256 Advertised in code_challenge_methods_supported Verified by the IdP; by the gateway for CIMD clients
Dynamic client registration (RFC 7591) POST .../register Forwarded to the IdP’s registration_endpoint; advertised only when the IdP has one
Client ID Metadata Documents GET .../authorize with an https client_id Bridged; advertised as client_id_metadata_document_supported: true only when the IdP supports DCR
Authorization response iss (RFC 9207) — Not supported; advertised as authorization_response_iss_parameter_supported: false

For IdPs that support RFC 7591, a client can register itself through the facade instead of an operator creating an OAuth app by hand. X-Tenant-ID is required on this endpoint.

Terminal window
curl -s -X POST "http://localhost:8100/v1/proxy/oauth/mcp-01M62B4R7D3H8KQ2W5Y9T1N6PV/idp-01M62C1A5S9K3E7W2Q8Z4R6TYB/register" \
-H "X-Tenant-ID: default" \
-H "Content-Type: application/json" \
-d '{
"client_name": "My MCP Client",
"redirect_uris": ["http://localhost:8085/callback"],
"grant_types": ["authorization_code", "refresh_token"],
"token_endpoint_auth_method": "none"
}'

The gateway forwards the JSON body to the IdP’s registration_endpoint and relays the IdP’s status code and body unchanged, for example:

{
"client_id": "d7c1f5a2-8e44-4b0a-9c3e-61f2a8b7e905",
"client_name": "My MCP Client",
"redirect_uris": ["http://localhost:8085/callback"],
"grant_types": ["authorization_code", "refresh_token"],
"token_endpoint_auth_method": "none",
"application_type": "native"
}

When the request has no application_type, the gateway infers one before forwarding: native if any redirect URI is http://localhost…, http://127.0.0.1… or a custom scheme, otherwise web. An explicit value is never changed.

Response Cause
400 {"error": "Missing tenant context"} No X-Tenant-ID header
404 {"error": "Identity provider not found"} IdP missing or disabled in that tenant
400 {"error": "IdP does not support dynamic client registration"} The IdP has no registration_endpoint
403 {"error": "Identity provider endpoint is refused by the outbound policy"} The IdP’s endpoints resolve to a refused destination
502 {"error": "Failed to reach IdP registration endpoint: ..."} The IdP could not be reached

A CIMD client does not register. Its client_id is an https URL pointing at a JSON document it hosts:

{
"client_id": "https://agent.example.com/oauth/client.json",
"client_name": "Example Agent",
"redirect_uris": ["http://127.0.0.1:33418/callback"],
"token_endpoint_auth_method": "none"
}

Your IdP does not need to understand URL client IDs: the gateway terminates the CIMD side and speaks ordinary OAuth upstream with a client of its own.

  1. Authorize. The client calls GET .../authorize with response_type=code, its URL client_id, a redirect_uri, state, and code_challenge with code_challenge_method=S256. The gateway fetches the document and checks that its client_id equals the URL, that it lists redirect_uris including the requested one, and that token_endpoint_auth_method, if present, is none.

  2. Gateway client. On first use per (tenant, IdP, document URL) the gateway registers a client of its own at the IdP by DCR (named Brutor CIMD bridge — <client_name>, with the gateway’s /callback as its redirect URI and client_secret_post) and stores it, secret encrypted. Later authorizations reuse it.

  3. Upstream leg. The gateway redirects the user to the IdP with its own client ID, redirect URI, state and PKCE pair. scope, resource, audience, prompt and login_hint are passed through.

  4. Callback. The IdP redirects to GET .../callback. The gateway swaps the IdP’s code for a single-use gateway code (prefix gwc_) and redirects the user to the client’s redirect_uri with that code and the client’s original state. An IdP error is passed to the client as error, error_description and state.

  5. Token. The client posts the gwc_ code with its URL client_id and code_verifier to POST .../token. The gateway checks the client ID and the client’s PKCE, then exchanges the stored IdP code with its own client, stores the tokens and returns an MCP JWT exactly as for any other client.

Limit Value
Document URL https:// only; no redirects followed
Document fetch 10 s timeout, 64 KiB maximum, JSON
Refused document hosts Addresses that resolve to loopback, private (RFC 1918, IPv6 unique-local), link-local including 169.254.169.254, CGNAT 100.64.0.0/10, multicast, broadcast, unspecified or documentation ranges. DNS is resolved once and the connection pinned to the vetted address
Authorize → callback window 600 s
Callback → token window 120 s, single use
Backing store Redis. Without it, CIMD requests return 503 CIMD bridging requires Redis

Registered (non-URL) client IDs are unaffected by any of this: they pass straight through /authorize to the IdP.

Error (400 unless noted) Cause
response_type must be 'code' Wrong or missing response_type
CIMD clients must use PKCE (code_challenge missing) No code_challenge
code_challenge_method must be S256 plain or missing method
redirect_uri is required / redirect_uri is not listed in the CIMD document Redirect URI missing or not in the document
CIMD document client_id '…' does not match its URL '…' Document’s own client_id differs from its URL
CIMD clients are public clients; token_endpoint_auth_method '…' is not supported Document declares a confidential auth method
CIMD host resolves to a blocked address (…) — refusing to fetch SSRF guard
502 IdP does not support dynamic client registration — CIMD bridging unavailable IdP has no registration endpoint
Unknown or expired authorization request Callback after the 600 s window, or replayed
Unknown, expired, or already-used authorization code Token request after 120 s, or code reused
client_id does not match the authorization request / PKCE verification failed Token request from a different client or wrong verifier