New in version 2.13.0Install auth stack to your FastMCP server with Scalekit using the Remote OAuth pattern: Scalekit handles user authentication, and the MCP server validates issued tokens.
Create your FastMCP server file and use the ScalekitProvider to handle all the OAuth integration automatically:
Warning: The legacy mcp_url and client_id parameters are deprecated and will be removed in a future release. Use base_url instead of mcp_url and remove client_id from your configuration.
server.py
Copy
from fastmcp import FastMCPfrom fastmcp.server.auth.providers.scalekit import ScalekitProvider# Discovers Scalekit endpoints and set up JWT token validationauth_provider = ScalekitProvider( environment_url=SCALEKIT_ENVIRONMENT_URL, # Scalekit environment URL resource_id=SCALEKIT_RESOURCE_ID, # Resource server ID base_url=SERVER_URL, # Public MCP endpoint required_scopes=["read"], # Optional scope enforcement)# Create FastMCP server with authmcp = FastMCP(name="My Scalekit Protected Server", auth=auth_provider)@mcp.tooldef auth_status() -> dict: """Show Scalekit authentication status.""" # Extract user claims from the JWT return { "message": "This tool requires authentication via Scalekit", "authenticated": True, "provider": "Scalekit" }
Set required_scopes when you need tokens to carry specific permissions. Leave it unset to allow any token issued for the resource.
Use any MCP client (for example, mcp-inspector, Claude, VS Code, or Windsurf) to connect to the running serve. Verify that authentication succeeds and requests are authorized as expected.
These environment variables provide default values for the Scalekit provider, whether it’s instantiated manually or configured via FASTMCP_SERVER_AUTH.
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.