Skip to main content
This guide shows you how to secure your FastMCP server using Descope, a complete authentication and user management solution. This integration uses the Remote OAuth pattern, where Descope handles user login and your FastMCP server validates the tokens.

Configuration

Prerequisites

Before you begin, you will need:
  1. To sign up for a Free Forever Descope account
  2. Your FastMCP server’s URL (can be localhost for development, e.g., http://localhost:8000)

Step 1: Configure Descope

1

Configure a Descope application

You can use either a resource-specific Descope MCP Server or a project-level inbound app.To create an MCP Server, go to the MCP Servers page of the Descope Console, create a server, and enable Dynamic Client Registration (DCR).
DCR is required for FastMCP clients to automatically register with your authentication server.
2

Copy the Well-Known URL

DescopeProvider accepts both resource-specific MCP Server URLs:
and project-level inbound app URLs:

Step 2: Environment Setup

Create a .env file with your Descope configuration:

Step 3: FastMCP Configuration

Create your FastMCP server file and use the DescopeProvider to handle all the OAuth integration automatically. Nothing reads .env automatically, so load it explicitly with python-dotenv (pip install python-dotenv) before constructing the provider — otherwise the values you just wrote stay invisible to os.environ.
server.py

Scope discovery and validation

When both scopes_supported and required_scopes are omitted, DescopeProvider discovers scopes_supported lazily from the OpenID configuration and advertises them to MCP clients. Provider construction remains network-free, and a transient discovery failure is retried on a later metadata request. Set both options when clients should request a broader set of scopes than the server requires on every token:
scopes_supported controls what the protected resource metadata advertises. required_scopes controls what the JWT verifier requires during token validation. When only required_scopes is set, those scopes are also advertised to clients.

Testing

To test your server, you can use the fastmcp CLI to run it locally. Assuming you’ve saved the above code to server.py (after replacing the environment variables with your actual values!), you can run the following command:
Now, you can use a FastMCP client to test that you can reach your server after authenticating:

Production Configuration

For production deployments, load configuration from environment variables:
server.py