Skip to content
Back to Authdog Blog

Getting started with MCP Auth

A step-by-step guide to OAuth 2.1 authorization for MCP clients connecting to your resource servers using Authdog's MCP Auth platform.

Authdog Team

8 min read
Centered Authdog and MCP marks with an OAuth flow arrow on a grainy indigo wash

MCP (Model Context Protocol) servers let AI assistants call tools on your infrastructure. MCP Auth layers OAuth 2.1 authorization in front of those calls so that only authenticated, consented users and verified agents can invoke your tools. This tutorial walks through creating an MCP project, enabling MCP Auth in the Authdog console, registering clients, defining scopes, connecting a resource server, and testing the flow in the Playground.

What is MCP Auth?

MCP Auth is an OAuth 2.1 authorization server profile designed specifically for MCP clients. When an AI assistant or agent wants to call a tool on your MCP server, it first authenticates with Authdog, obtains an access token scoped to your resource, and presents that token on each tool call. Your MCP server validates the token against Authdog's JWKS and enforces the scopes and policies you configured.

The key concepts:

  • Resource server: Your MCP server that exposes tools.
  • Authorization server: Authdog's OIDC issuer for your environment.
  • MCP client: The AI assistant, agent, or desktop app calling tools.
  • Protected resource metadata (RFC 9728): A JSON document at /.well-known/oauth-protected-resource telling clients where to get tokens.

Prerequisites

Before you start, you need:

  1. An Authdog account with a tenant.
  2. An MCP server you want to protect (or use Authdog's built-in MCP for testing).
  3. Basic familiarity with OAuth 2.1 and JWT access tokens.

Step 1: Create an MCP project

Open the Authdog console and navigate to Projects. If you don't have any projects yet, you'll see the empty state with a Create a new Project button.

Projects empty state

Click New Project and select MCP server as the application type. This registers a Model Context Protocol server for AI agents with secure, authenticated tool and resource access.

Create application dialog with MCP type selected

The Add new MCP server wizard opens. Fill in the basic details:

MCP server form - empty

  • Display Name: A meaningful name to identify your MCP server (e.g., "Blog Demo MCP")
  • Identifier: A URI identifier for the server (e.g., mcp://blog-demo-mcp). This field is unique and not editable after creation.
  • Description: What this MCP server provides

MCP server form - filled

Click Next to proceed to the Scopes step. You can configure scopes and access control after the server is created.

MCP server step 2 - Scopes

Click Register Server to complete the creation. You'll see the button spinner while the server is being registered.

Registering server

Once created, your MCP project appears in the Projects list with its type, description, environments count, and last updated date.

Projects list with MCP project

Step 2: Navigate to MCP Auth

Select your MCP project and choose an environment (e.g., "prod"). In the sidebar under Platform, click MCP Auth. The MCP Auth module has six tabs:

  • Playground — test authenticated tool calls
  • Settings — enable MCP Auth and configure resource defaults
  • Scopes — define OAuth scopes for consent
  • Connect — get issuer URLs and integration snippets
  • Policies — AuthZEN policy templates
  • Gateway — hosted gateway configuration

Step 3: Enable MCP Auth

Select the Settings tab. By default, MCP Auth is disabled.

MCP Auth Settings - default state

Enable the Enable MCP Auth toggle. This activates the authorization server profile for this environment.

Configure the default resource

When MCP clients omit the RFC 8707 resource parameter (some desktop AI clients still do), Authdog can substitute a default. Enter your MCP server's public URL in the Default resource (HTTPS) field:

https://mcp.example.com

This URL becomes the aud (audience) claim in access tokens, which your resource server validates.

MCP Auth Settings - enabled with default resource

Additional settings

  • Strict resource mode: Reject requests that omit the resource parameter when no default is configured
  • Dynamic client registration (preview): Let MCP clients register themselves via RFC 7591
  • Client ID metadata (CIMD) (preview): Accept software statements from HTTPS metadata URLs

Click Save changes. You'll see a confirmation toast.

MCP Auth Settings - saved

Step 4: Define OAuth scopes

Switch to the Scopes tab. Here you define the scopes that appear on consent screens and control what access tokens grant.

MCP Auth Scopes tab

A typical setup has two scopes:

Scope Description Grantable Roles Admin Consent
mcp:invoke Call MCP tools on this resource Member, Admin No
mcp:admin Privileged MCP tools (administrative actions) Admin Yes

The Grantable roles field controls which user roles can consent to the scope. When Require administrator consent is checked, only Admins can approve, and the grantable roles are automatically set to Admin only.

Click Add scope to add more scopes, then Save scopes to persist changes.

Step 5: Connect your MCP server

The Connect tab provides the integration values your MCP server needs.

MCP Auth Connect tab

OIDC endpoints

Copy these URLs for your MCP server configuration:

  • Issuer: https://identity.authdog.com/oidc/<environment-id>
  • JWKS URI: {issuer}/.well-known/jwks.json
  • Authorization endpoint: {issuer}/authorize
  • Token endpoint: {issuer}/token

Environment variables

The Connect tab provides a suggested environment variable block for your resource server:

# Resource server (@authdog/mcp-sdk — monorepo packages/mcp-sdk)
AUTHDOG_OIDC_ISSUER=https://identity.authdog.com/oidc/<environment-id>
MCP_PROTECTED_RESOURCE=https://your-mcp-host.example/mcp
MCP_REQUIRED_SCOPES=mcp:invoke
MCP_JWT_ONLY=true

Protected resource metadata

Create a /.well-known/oauth-protected-resource endpoint on your MCP server that returns the JSON shown in the Connect tab:

{
  "resource": "https://your-mcp-host.example/mcp",
  "authorization_servers": [
    "https://identity.authdog.com/oidc/<environment-id>"
  ],
  "scopes_supported": [
    "mcp:invoke"
  ],
  "bearer_methods_supported": [
    "header"
  ]
}

MCP clients fetch this document to discover where to authenticate before calling your tools.

Set MCP_JWT_ONLY=true to validate tokens as JWTs against Authdog's JWKS. This is the recommended approach for tokens minted to desktop MCP clients.

Step 6: Configure policies (optional)

The Policies tab provides AuthZEN policy templates for per-tool authorization.

MCP Auth Policies tab

OAuth scopes control what users can consent to. AuthZEN policies control individual tools after authentication. Even with mcp:invoke, a specific tool can be denied based on policy.

Agent tool call template

For agent identities using @authdog/mcp-sdk:

{
  "subject": { "type": "agent", "id": "client:your-agent-id" },
  "action": { "name": "tools/call" },
  "resource": { "type": "mcp_tool", "id": "your-server/read_file" },
  "context": { "arguments_digest": "sha256:..." }
}

Human user tool execute template

For ABAC/FGA environments with human callers:

{
  "subject": { "type": "user", "id": "[email protected]" },
  "action": { "name": "execute" },
  "resource": { "type": "mcp_tool", "id": "admin_echo" }
}

If your environment uses the ABAC permission model, click Apply ABAC starter policy to seed a baseline Rego module.

Step 7: Set up the gateway (optional)

The Gateway tab configures hosted MCP gateway routing if you want Authdog to proxy requests to your MCP origin.

MCP Auth Gateway tab

  1. Enable Gateway registration
  2. Enter your MCP origin URL (the internal upstream endpoint)
  3. Choose a Gateway hostname label

Your public MCP URL becomes https://<label>.mcp.authdog.com/mcp.

This is optional — most deployments point clients directly at the MCP server origin.

Step 8: Test in the Playground

The Playground tab lets you test the entire OAuth flow without leaving the console.

MCP Auth Playground

Note: The Playground UI is being redesigned. Screenshots may look different once the redesign lands.

Connect with SSO

Click Connect with SSO to initiate the OAuth flow. A popup opens to Authdog's hosted authentication where you sign in and consent to the requested scopes. On success, the Playground receives an access token.

The IDENTITY section shows your identity alignment:

  • Aligned — your console identity matches the token's sub and externalId
  • Cross-env — the token was minted in a different OIDC environment
  • Mismatch — the identities don't match; reconnect with SSO

Import tools

Click Import tools under TOOL ACCESS to fetch the MCP server's tool catalog. The Playground lists available tools with their descriptions.

Advanced options

Expand Endpoint & Bearer to view or manually configure the MCP endpoint URL and bearer token.

Connecting a real MCP client

Once your MCP server is configured and tested, connect a real MCP client like Cursor or Claude Desktop.

Cursor configuration

Add to your Cursor MCP configuration:

{
  "mcpServers": {
    "your-server": {
      "url": "https://your-mcp-host.example/mcp",
      "auth": {
        "type": "oauth",
        "clientId": "your-client-id",
        "scopes": ["mcp:invoke"]
      }
    }
  }
}

Claude Desktop configuration

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "your-server": {
      "command": "npx",
      "args": ["-y", "@your-org/mcp-client"],
      "env": {
        "MCP_SERVER_URL": "https://your-mcp-host.example/mcp",
        "MCP_AUTH_TYPE": "oauth",
        "MCP_CLIENT_ID": "your-client-id"
      }
    }
  }
}

The client discovers the authorization server from your protected resource metadata, opens a browser for authentication, and stores the token for subsequent tool calls.

Troubleshooting

invalid_client error

The OAuth client ID is not registered or has incorrect settings. Check:

  • The client exists in your environment's OIDC clients
  • Redirect URIs include the callback URL the client uses
  • If using DCR, ensure Dynamic Client Registration is enabled

externalId mismatch

The token was minted for a different identity than your console session. This happens when:

  • You signed into the MCP OAuth popup with a different account
  • A legacy UUID-based account exists alongside a provider-linked identity

Fix: Clear the connection and reconnect with SSO using the same identity provider as your console session.

Settings not saving

The save mutation may fail silently. Check:

  • You have permission to modify environment settings
  • The environment exists and is not archived
  • No validation errors (empty required fields, invalid URLs)

Inspect the browser's Network tab for GraphQL errors.

Token audience mismatch (401 on tool call)

The access token's aud claim doesn't match your MCP server's expected audience. Ensure:

  • MCP_PROTECTED_RESOURCE on your server matches the Default resource in MCP Auth Settings
  • Your protected resource metadata returns the same resource URL
  • Tokens are requested with the correct resource parameter (or the default applies)

Missing scopes (403 on tool call)

The token is valid but lacks required scopes. Check:

  • Scopes are defined in the Scopes tab
  • The OAuth client is allowed to request those scopes
  • The user consented to the scopes during authentication

Next steps

MCP Auth bridges the gap between AI assistants and your protected resources. With OAuth 2.1 flows, fine-grained scopes, and policy-based authorization, you control exactly which tools each identity can invoke.