Skip to content

MCP Server Authorization

This guide sets up AuthAction as the authorization server for your MCP server. Once it is done, a user can add your MCP server to Claude, ChatGPT, VS Code, Cursor or any other MCP client, sign in with AuthAction, and the client receives an access token for your server.

Example Repository: For a working code example, see the mcp-server-auth-example repository.

An MCP server is its own resource in AuthAction, separate from your API servers. It has its own audience, so a token issued to an MCP client never works against your APIs, and a token for your APIs never works against your MCP server.

You do not create an application for each MCP client. MCP clients identify themselves with a Client ID Metadata Document: their client_id is an HTTPS URL that publishes their name and redirect URIs. AuthAction fetches that document when the client first connects.

You control three things on an MCP server:

  • Allowed MCP Clients: any client, or only the ones you choose.
  • Connections: which sign-in methods users see when they connect through an MCP client.
  • Applications: your own registered apps that may also call it, such as an in-app assistant.

An API server never accepts MCP clients. There is no switch to turn MCP client access on or off: an MCP server always accepts them, limited by the allowlist.

  1. In the AuthAction dashboard, go to Applications > MCP servers.
  2. Select Create MCP server, and enter a name and your MCP server’s URL, for example https://mcp.example.com or https://www.example.com/mcp.

MCP clients send this URL as the resource parameter, and it becomes the aud of the access token. It must be an https URL, and it cannot be changed later.

You can also create one with the Management API: POST /api/v1/mcp-servers with name and identifier.

On the MCP server’s Settings tab, under Allowed MCP Clients:

  1. Choose Only the clients I allow, or Any MCP client.
  2. Under Common clients, select Allow next to the clients you support:
    • Claude: https://claude.ai/oauth/mcp-oauth-client-metadata. Every Claude account uses this one client_id.
    • ChatGPT: https://chatgpt.com/oauth/*/client.json. ChatGPT gives each connector its own client_id, such as https://chatgpt.com/oauth/aCMAjcRC1l0R/client.json. The * stands for that id, so this one entry allows every ChatGPT connector.
  3. To allow another client before it has connected, enter its client_id URL and select Allow.

In an entry, * stands for exactly one path segment. It never matches across a /, in the host, or past the end of the path, so https://chatgpt.com/oauth/*/client.json allows only documents that ChatGPT publishes.

A client that is not allowed is refused before AuthAction contacts its metadata URL. Blocking a client that is already signed in stops it from refreshing its token, so it loses access when its current access token expires.

AuthAction tells clients apart only by client_id. If two apps publish the same metadata URL, for example a web and a desktop version of the same product, they count as one client and are allowed or blocked together.

On the Connections tab, turn on the connections users may sign in with, for example Email Password, Google or GitHub.

At least one connection must be enabled, otherwise sign-in fails with a “no connection” error.

MCP clients do not need this. Use the Applications tab for apps you register yourself that call the MCP server, for example:

  • an assistant inside your own web app, signing users in with authorization code and PKCE;
  • a background job or workflow, with client credentials;
  • an MCP gateway in front of several MCP servers.

The MCP server’s Quick start tab shows these with your own values filled in.

Your MCP server publishes Protected Resource Metadata that names your AuthAction tenant as its authorization server. Serve it at /.well-known/oauth-protected-resource followed by your MCP server’s path, for example https://www.example.com/.well-known/oauth-protected-resource/mcp for https://www.example.com/mcp:

{
"resource": "https://www.example.com/mcp",
"authorization_servers": ["https://<tenant>.<region>.authaction.com/"]
}

If users sign in on a custom domain, name that domain in authorization_servers instead.

Answer a request without a valid token with 401 and a WWW-Authenticate: Bearer resource_metadata="<that URL>" header. Verify each request’s bearer token against your tenant’s JWKS, checking iss, exp, and that aud is your MCP server’s URL. Refuse any other audience.

  1. The MCP client calls your server, receives 401, and reads your Protected Resource Metadata.
  2. It reads AuthAction’s discovery document and sees client_id_metadata_document_supported: true.
  3. It sends the user to /oauth2/authorize with its metadata URL as client_id and your server as resource.
  4. AuthAction checks that the resource is an MCP server and that the client is allowed, fetches and validates the client’s document, and shows the sign-in page with your chosen connections.
  5. The client exchanges the code for an access token using PKCE, and calls your server with it. A client whose document declares private_key_jwt, as ChatGPT’s does, also signs each token request with a key it publishes.
  • Separate audiences: MCP clients can only get tokens for MCP servers, never for an API server or the Management API.
  • Only chosen clients: Restrict an MCP server to the MCP clients you allow. Blocking a client also stops its refresh tokens from working.
  • Connection control: Limit the connections offered to MCP clients to the ones you want them to use.
  • Proof of identity: MCP clients have no client secret. PKCE is required, redirect URIs must exactly match the client’s published document, and clients that publish keys must sign their token requests.
  • Visibility: Every MCP client that has connected appears under Applications with an MCP badge. Delete one to clear its stored metadata.

For implementation details and code, see the mcp-server-auth-example repository.