Skip to content

MCP servers

Protect an MCP server so MCP clients such as Claude Code find your realm, sign the person in and call your tools with a token issued for your server alone.

In the Model Context Protocol authorization model, your MCP server is an OAuth resource server and Authio is its authorization server. The server never signs anyone in: an MCP client — Claude Code, an IDE, the MCP Inspector — discovers Authio from the server, signs the person in through the hosted login and calls your tools with an access token whose audience is your server.

Two packages implement the server’s half: @hyper.authio/mcp 0.8.0 for Node.js, on top of the official MCP SDK and the Authio Node.js SDK 0.13, and Authio.Mcp.AspNetCore 0.8.0 for ASP.NET Core, on top of the official C# MCP SDK and Authio.AspNetCore 0.12. Both verify tokens, publish the metadata MCP clients look for, answer with the challenges that start the OAuth flow and authorize each tool.

Configure them the way the server is registered

The packages assume nothing the console configures: each setting is an option, and an option left out is off — no scope required, no introspection, nothing decrypted. Name the scopes the server insists on and the introspection mode you want, as the examples below do. Only what the MCP specification requires stays fixed; see What the MCP specification fixes.

Looking for Authio’s own MCP server?

This page protects your MCP server, whose tools your users call. To connect Claude, VS Code or Cursor to your Authio account and read or administer it through an agent, use the Authio MCP server instead: nothing to build or register.

How an MCP client finds Authio

  1. The client calls the server without a token. The server answers 401 with a WWW-Authenticate: Bearer header whose resource_metadata points at its protected resource metadata.
  2. The client reads that document (RFC 9728), served under /.well-known/oauth-protected-resource followed by the endpoint’s path. It names the realm as the authorization server.
  3. It reads the realm’s authorization server metadata (RFC 8414) at the path-inserted address MCP clients try first, https://authio.api.hyperio.tech/.well-known/oauth-authorization-server/realms/acme; the realm’s OpenID Connect discovery address answers too.
  4. It identifies itself with a client ID you registered for it, or with the URL of its own Client ID Metadata Document if the realm accepts those. A realm can also turn on dynamic client registration, off by default, for MCP clients that can do neither.
  5. It runs the authorization code flow with PKCE and resource=https://mcp.example.com/mcp (RFC 8707). The access token carries that identifier as aud, so it is useless on any other server.
  6. Your server checks the signature against the realm’s keys, the issuer, the audience, the expiry and the scopes it requires. With introspection set to activeCheck, it also asks Authio whether the token is still active — at most once every 30 seconds per token.
GET /.well-known/oauth-protected-resource/mcpJSON
{
  "resource": "https://mcp.example.com/mcp",
  "authorization_servers": ["https://authio.api.hyperio.tech/realms/acme"],
  "bearer_methods_supported": ["header"],
  "scopes_supported": ["mcp:tools"],
  "resource_name": "Acme tools"
}

scopes_supported lists the required scopes and any others you advertise, and is left out when there are none.

Set up the realm

Resource servers and tokens issued for them need the MCP integration in your account’s plan, and connected accounts need their own feature. See Plans and billing.
  1. Register the server as a resource server

    In Resource servers, set the Identifier to the public URL of the MCP endpoint, such as https://mcp.example.com/mcp, and add a scope such as mcp:tools. The identifier becomes every token’s aud and cannot change later; it is stored with the scheme and host lower-cased and without a default port or trailing slash.

  2. Create the server’s own client

    In Clients, create a confidential client for the server and choose it as the resource server’s Introspection client. Its ID, its Token endpoint auth method and its secret (or, for private_key_jwt, its private key) go in the server’s configuration. Give it the token exchange grant if tools will use connected accounts. A server that validates locally and exchanges nothing does not need it.

  3. Let MCP clients in

    Register a client for each MCP client you use and add it under Allowed clients, turn on Accept CIMD clients so MCP clients that publish a metadata document can ask for tokens, or — for MCP clients that can do neither — turn on dynamic client registration in the realm and Accept dynamically registered clients here. All three are described below.

Pre-registered clients

  • A public client with the authorization_code grant, PKCE required and S256 allowed.
  • The redirect URI of each MCP client: Claude Code uses http://localhost:<callback-port>/callback, the MCP Inspector http://localhost:6274/oauth/callback. Turn on Loopback on any port for native clients that pick their port.
  • Require OpenID Connect off, because MCP clients usually ask only for your scope — or have them ask for openid too.
  • The client listed under Allowed clients on the resource server; otherwise the authorize request fails with invalid_target.

Then give Claude Code the client ID and the callback port you registered:

TerminalBash
claude mcp add --transport http --client-id acme-claude-code --callback-port 8765 acme-tools https://mcp.example.com/mcp

Client ID Metadata Documents

A Client ID Metadata Document (CIMD) lets an MCP client identify itself with an https URL that serves a JSON description of it — its name and redirect URIs — instead of a client ID you created. The URL is the identity: a document that names a different client_id is refused.

  • Turn it on per realm: in the realm’s MCP clients (CIMD) settings, switch on Accept clients by metadata document (CIMD). It is off by default.
  • Optionally limit Allowed hosts. Empty accepts any public https host; *.example.com covers the subdomains of example.com but not example.com itself.
  • Turn on Accept CIMD clients on each resource server those clients may reach.
  • The client is registered on first use, is always public, always shows the consent screen and stays in sync with its document. Turning the setting off, or removing its host, shuts it out on the next request.
  • The realm’s discovery document advertises client_id_metadata_document_supported: true while the setting is on.

Dynamic client registration

Dynamic client registration (RFC 7591) lets an MCP client create its own client by posting its metadata to the realm’s registration endpoint, POST https://authio.api.hyperio.tech/realms/acme/protocol/openid-connect/register. It is off by default and turned on per realm.

Prefer CIMD or a pre-registered client

The MCP specification of 2025-06-18 said authorization servers SHOULD support dynamic registration; the 2025-11-25 revision downgrades it to MAY and recommends Client ID Metadata Documents. Turn it on only for MCP clients that can neither be given a client ID nor publish a metadata document — older versions of the MCP Inspector, some IDE plugins — and keep the access on InitialAccessToken rather than Open.
  • Turn it on per realm: on the realm’s page, in the Access section, switch on Dynamic client registration (DCR). Through the Admin API, it is the dynamicClientRegistration object of PUT /api/v1/admin/realms/{realm}: admin.realm.update in @hyper.authio/admin, and on .NET an HttpClient with the account credential, as Routes without a method in .NET shows.
  • While it is off — or the realm does not exist or is inactive — the endpoint answers 404 and the realm’s metadata (/.well-known/oauth-authorization-server/realms/acme and the OpenID configuration) carries no registration_endpoint. While it is on, registration_endpoint is published.
  • Turn on Accept dynamically registered clients (allowDynamicallyRegisteredClients) on each resource server those clients may reach, as Accept CIMD clients does for CIMD. Without it, a token request with resource= fails with invalid_target.
SettingAPI memberDefaultMeaning
EnabledenabledfalseOpens the endpoint and publishes registration_endpoint.
AccessaccessInitialAccessTokenInitialAccessToken requires a credential of the account that owns the realm on every registration; Open lets anyone register.
Allowed scopesallowedScopesopenid profile email offline_accessA request that names no scope gets all of them; a scope outside the list is refused.
Allowed grant typesallowedGrantTypesauthorization_code refresh_tokenMay also allow client_credentials and device_code. A request that names none gets authorization_code.
Allowed auth methodsallowedAuthMethodsnoneMay also allow client_secret_basic and client_secret_post. A request that omits it gets client_secret_basic if allowed, otherwise the first allowed method.
Redirect hostsredirectHostsEmpty: any https host*.example.com covers the subdomains of example.com but not example.com itself.
Allow loopback redirectsallowLoopbackRedirectstruehttp or https on 127.0.0.1, [::1] or localhost, on any port.

With InitialAccessToken, the request carries Authorization: Bearer with an API key or personal access token of the account that owns the realm, holding realm:write — the permission the Admin API needs to create clients. A credential restricted to another realm or to a single client does not work. The body takes the RFC 7591 members redirect_uris, token_endpoint_auth_method, grant_types, response_types, client_name, client_uri, scope and contacts; any other member is ignored.

TerminalBash
curl -X POST https://authio.api.hyperio.tech/realms/acme/protocol/openid-connect/register \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer pat_...' \
  -d '{"client_name":"My MCP client","redirect_uris":["http://127.0.0.1:33418/callback"],"grant_types":["authorization_code","refresh_token"],"response_types":["code"],"token_endpoint_auth_method":"none","scope":"openid offline_access"}'

A confidential client also gets client_secret and client_secret_expires_at: 0. There is no registration_access_token or registration_client_uri: client management (RFC 7592) is not supported, and the client is managed in the console like any other.

ErrorStatusWhen
invalid_client_metadata400A scope, grant type or auth method the policy does not allow, or metadata that does not hold together.
invalid_redirect_uri400http on a host other than loopback, a host not listed, a loopback address while loopback is off, a fragment or user info.
invalid_token401The initial access token is missing or lacks realm:write on the realm.
None404Registration is off, or the realm does not exist or is inactive.

The registered client is created like any other: it counts toward the plan’s client quota, is recorded in the audit trail and fires the admin_resource_created webhook. The console marks it Dynamically registered. A public one always requires PKCE with S256, the consent screen is always shown and Require OpenID Connect is off.

Pre-registered vs CIMD vs DCR

Pre-registeredCIMDDCR
Who creates the clientYou, in the consoleAuthio, from the client’s document on first useThe MCP client, by calling the registration endpoint
Client IDChosen when you create itThe document’s https URLIssued by Authio
In the realmNothing to turn onAccept clients by metadata document (CIMD)Dynamic client registration (DCR)
On the resource serverAllowed clientsAccept CIMD clientsAccept dynamically registered clients
When to use itMCP clients you know and configure, such as Claude CodeMCP clients that publish a metadata document — the recommended defaultOnly MCP clients that can do neither

Node.js: @hyper.authio/mcp

@hyper.authio/mcp needs Node.js 20.19 or later and is ESM only. express is needed only for the @hyper.authio/mcp/express helpers.

TerminalBash
npm install @hyper.authio/mcp @modelcontextprotocol/sdk express

createAuthio reads the realm’s discovery document at start-up, so a wrong authority, realm or issuer stops the server with a sentence instead of every token being refused later. authioMetadataRouter publishes the protected resource metadata and answers CORS for browser clients such as the MCP Inspector; mount it at the root. authio.protect(server).registerTool takes what McpServer.registerTool takes plus requires — requireScope, requireRole, requirePermission, requireCallerKind, requireOrganization, requireAuthenticationLevel, allOf, anyOf — and hands each tool the caller as extra.user: its kind, subject, client, scopes, roles, permissions, organization, acr/amr and delegation.

Not on Express? authio.authenticate(authorizationHeader) answers the caller or the refusal to send, authio.authorizeRequest(user, body) checks a tools/call, authio.metadata is the protected resource metadata, and authio.tokenVerifier is an OAuthTokenVerifier for the MCP SDK’s own requireBearerAuth.

ASP.NET Core: Authio.Mcp.AspNetCore

The package targets .NET 8 and .NET 10 and brings Authio.AspNetCore, Authio.Client and the official C# MCP SDK (ModelContextProtocol.AspNetCore) with it. It reads every setting from the Authio:Mcp section.

TerminalBash
dotnet add package Authio.Mcp.AspNetCore

Keep the secret in user-secrets or the Authio__Mcp__ClientSecret environment variable. AddAuthioMcp(options => options.RequiredScopes = ["mcp:tools"]) sets the scopes in code. RequireAuthioMcp() requires the AuthioMcpDefaults.Policy policy on the endpoint and authorizes each tools/call against the tool’s [AuthioScope], [AuthioRole], [AuthioPermission], [AuthioCallerKind], [AuthioOrganization] or step-up attributes before it runs; AddAuthorizationFilters() hides from tools/list what the caller may not call. ClientId is optional when the server neither introspects nor exchanges tokens.

Options

Node option.NET settingLeft outMeaning
authority + realm, or issuerAuthority + Realm, or IssuerRequiredWhere the realm is. The authority must be the base Authio publishes in its issuer, without /realms/….
resourceResourceRequiredThe public URL of the MCP endpoint: the resource identifier, every token’s aud and resource in the metadata.
clientIdClientIdNoneThe resource server’s introspection client, also used for connected-account exchanges. Required with introspection.
tokenEndpointAuthMethodTokenEndpointAuthMethodFollows the credentialsThe client’s Token endpoint auth method, which Authio matches exactly: client_secret_basic, client_secret_post, private_key_jwt or none (Basic, Post, PrivateKeyJwt, None in .NET). Left out: basic with a secret, private_key_jwt with only a private key, none with neither.
clientSecretClientSecretNoneThe client’s secret, for the basic and post methods and for HS access tokens.
requiredScopesRequiredScopesNo scope requiredScopes every token must carry, all of them. Name the ones the server insists on, such as mcp:tools; they also go into the 401 challenge and scopes_supported.
introspectionIntrospectionnone: local validation onlyactiveCheck also asks Authio about each token (cached per token), so a revoked token or an ended session is refused before it expires; introspectionOnly validates by introspection alone, for opaque (Reference) tokens or HS tokens the server cannot verify. Both need clientId.
introspectionCacheDurationIntrospectionCacheDuration30 secondsHow long an active answer is reused, never past the token’s expiry.
accessTokenSignedResponseAlgAccessTokenSignedResponseAlgRS, PS and ES only, never HSThe algorithm, or several, the client signs access tokens with. HS256, HS384 and HS512 are verified with clientSecret.
clientEncryptionKeyClientEncryptionKeyNothing decryptedThe private key Authio encrypts this server’s access tokens to; see Encrypted tokens.
scopesSupported, resourceNameResourceScopes, ResourceNameNoneThe rest of the protected resource metadata.

Left out means off

Without requiredScopes, any token issued for the server is accepted, whatever its scopes, and the 401 challenge carries no scope. Without introspection, a token is validated locally only: a revoked token or an ended session keeps working until the token expires. A server that relies on either one states it, as requiredScopes: ['mcp:tools'] and introspection: 'activeCheck' ("RequiredScopes": [ "mcp:tools" ] and "Introspection": "ActiveCheck" in .NET).

MCP clients whose access token is signed with HS

An access token signed with HS256, HS384 or HS512 has no key in the realm’s JWKS: it is keyed with the secret of the client that asked for it. Only a server configured as that client, with accessTokenSignedResponseAlg set to the HS algorithm and its clientSecret, validates it locally. An MCP server does not hold the secret of the MCP clients that call it, so for those tokens use introspection: 'introspectionOnly' ("Introspection": "IntrospectionOnly"), or sign those clients’ access tokens with RS, PS or ES. The client’s view in the console warns when its access tokens need introspection; see Token signing.

Access token formats

The format of the tokens the server receives is decided by the client the MCP clients sign in through, and introspection follows it.

FormatWhat the token carriesintrospection / Introspection
JWT (self-contained)EverythingAny; none validates it locally
LightweightOnly who called and how: sub, client_id, scope, sid, acr/amr, act and the organization. Roles, permissions, subscription, the profile, the email and a consumer’s credential_type are left to introspectionactiveCheck or introspectionOnly (ActiveCheck or IntrospectionOnly), from 0.6.0
Opaque (reference)Nothing readableintrospectionOnly (IntrospectionOnly)

From 0.6.0, with activeCheck, the caller is the token’s payload plus the claims of the introspection answer the token does not carry, so a lightweight token reaches requireRole, requirePermission, requireCallerKind, [AuthioRole] and [AuthioPermission] complete; a claim the token carries keeps its signed value. With none, a lightweight token is still valid but arrives without roles or permissions, and every tool that requires one refuses it: the packages never guess the format from the claims a token lacks. See every library in Integrate with the libraries.

What the MCP specification fixes

Three things are not options, because the MCP authorization specification requires them rather than any client or resource server setting in Authio:

FixedWhy
authorization_servers is the realm’s issuerThe metadata must name the authorization server an MCP client has to use. For an Authio-protected server that is the realm that issues its tokens; any other value would send the client to a server whose tokens are refused.
bearer_methods_supported is ["header"]MCP clients send the token in the Authorization: Bearer header and never in the query string, and the packages read only the header.
Every 401 carries resource_metadataThe server points the client at its protected resource metadata through WWW-Authenticate; that is how the client discovers Authio. The metadata is therefore always published.

What the server answers

SituationStatusWWW-Authenticate carries
No token401resource_metadata, plus scope in Node when requiredScopes names any
Invalid, expired or issued for another resource; revoked, with introspection on401error="invalid_token", a description and resource_metadata
Token without the required scopes, or without a tool’s scope403error="insufficient_scope", the scopes needed and resource_metadata
A tool that needs a stronger or more recent sign-in403 in Node, 401 in .NETerror="insufficient_user_authentication", acr_values and max_age
A tool’s role, permission, caller kind or organization rule not met403Nothing

Browser-based clients such as the MCP Inspector must read that header across origins. Both packages expose WWW-Authenticate through CORS — the Express router by default, ASP.NET Core with AddAuthioMcpPolicy and RequireCors.

Use the person’s connected accounts

A tool can trade the caller’s Authio token for the token of an account they connected in Authio — GitHub, Google Drive and others — without storing any third-party credential. Call authio.exchangeConnection({ subjectToken: extra.user.token, provider }) in Node, which answers a status, or IAuthioTokenClient.ExchangeForConnectionAsync(subjectToken, provider, connectionId) in .NET, with HttpContext.GetAuthioAccessToken() as the subject token. provider is the connection provider’s alias.

ResultWhat to tell the person
GrantedNothing: use the provider’s access token. Authio never hands out the provider’s refresh token.
Connection requiredThe address where they connect the account (connectUri).
Selection requiredThe accounts to choose from; call again with one connectionId.
RefusedThe reason, such as access_denied when the plan does not include connected accounts.

In Node, describeConnectionRefusal(result, 'GitHub') words any result other than granted for the person.

Upgrading from 0.3

  • clientAuthentication is now tokenEndpointAuthMethod, and ClientAuthentication is now TokenEndpointAuthMethod. The old names are not read.
  • validAlgorithms is now accessTokenSignedResponseAlg, and ValidAlgorithms is now AccessTokenSignedResponseAlg; HS is accepted when listed, verified with clientSecret.
  • requiredScopes left out requires no scope (it was mcp:tools), and introspection left out is off (it was activeCheck). A server that relied on them now states them.
  • DEFAULT_REQUIRED_SCOPE and AuthioMcpDefaults.Scope are gone. In .NET, ClientId is optional without introspection.

Try it end to end

TerminalBash
curl -i -X POST https://mcp.example.com/mcp

curl https://mcp.example.com/.well-known/oauth-protected-resource/mcp

curl https://authio.api.hyperio.tech/.well-known/oauth-authorization-server/realms/acme

The first call should answer 401 with resource_metadata, the second name your realm, the third describe it. Then connect a real client: add the server to Claude Code as shown above, or open the MCP Inspector with npx @modelcontextprotocol/inspector, point it at the endpoint and start the OAuth flow from its connection settings.

Troubleshooting

What you seeWhyWhat to do
invalid_target at the authorize requestThe MCP client may not ask for this resource.List its client under Allowed clients, turn on Accept CIMD clients for a CIMD client, or Accept dynamically registered clients for a client created by dynamic registration.
404 at /protocol/openid-connect/register, or no registration_endpoint in the metadataDynamic client registration is off in the realm.Turn on Dynamic client registration (DCR) in the Access section of the realm’s page — or give the MCP client a pre-registered client or a metadata document.
invalid_token at the registration endpointThe access is InitialAccessToken and the credential is missing or lacks realm:write on the realm.Send an API key or personal access token of the realm’s account with realm:write, not restricted to another realm or to a client.
invalid_scope — scope must include openidThe client requires OpenID Connect and the MCP client asked only for your scope.Turn Require OpenID Connect off on that client.
The hosted login refuses the redirect URIThe MCP client’s callback is not registered exactly.Register it with its port, or turn on Loopback on any port.
The server does not start: Authio names a different issuerauthority is not the base Authio publishes in its issuer.Use the issuer without /realms/acme, or pass issuer.
Every token refused: not issued for this resourceresource differs from the resource server’s identifier.Make them identical, scheme, host and path included.
Every token refused with 401 once introspection is onAuthio refused the introspection request with invalid_client.Check the client ID, its secret or key, and that tokenEndpointAuthMethod is the client’s Token endpoint auth method.
Tokens without mcp:tools get throughrequiredScopes is left out, so no scope is required.Set requiredScopes: ['mcp:tools'].
A revoked token still works until it expiresintrospection is left out, so tokens are validated locally only.Set introspection: 'activeCheck' and the introspection client.
HS-signed tokens refused with invalid_algorithmWithout accessTokenSignedResponseAlg, only RS, PS and ES are accepted.Use introspection: 'introspectionOnly', or sign the client’s access tokens with RS, PS or ES.

Next steps