2.13.0
This guide shows you how to secure your FastMCP server with Scalekit using the Remote OAuth pattern: Scalekit handles user authentication, and your FastMCP server validates the tokens it issues.
Configuration
Prerequisites
Before you begin, you will need:- Get a Scalekit account and grab your Environment URL from Dashboard > Settings.
- Have your FastMCP serverās base URL ready (can be localhost for development, e.g.,
http://localhost:8000/)
Step 1: Configure MCP server in Scalekit environment
1
Register MCP server and set environment
In your Scalekit dashboard:
- Open the MCP Servers section, then select Create new server
- Enter server details: a name, a resource identifier, and the desired MCP client authentication settings
- Save, then copy the Resource ID (for example, res_92015146095)
.env file in your FastMCP project:.env
Step 2: Add auth to FastMCP server
Create your FastMCP server file and use the ScalekitProvider 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.
server.py
Testing
Start the MCP server
Production Configuration
For production deployments, load configuration from environment variables:server.py
Capabilities
Scalekit supports OAuth 2.1 with Dynamic Client Registration for MCP clients and enterprise SSO, and provides builtāin JWT validation and security controls. OAuth 2.1/DCR: clients selfāregister, use PKCE, and work with the Remote OAuth pattern without preāprovisioned credentials. Validation and SSO: tokens are verified (keys, RS256, issuer, audience, expiry), and SAML, OIDC, OAuth 2.0, ADFS, Azure AD, and Google Workspace are supported; use HTTPS in production and review auth logs as needed.Debugging
FastMCPās loggers do not propagate to the root logger, sologging.basicConfig will not surface them. Set FASTMCP_LOG_LEVEL to see token validation and metadata forwarding details: