New in version:Β 2.13.0
This guide shows you how to secure your FastMCP server using OCI IAM OAuth. Since OCI IAM doesnβt support Dynamic Client Registration, this integration uses the OIDC Proxy pattern to bridge OCIβs traditional OAuth with MCPβs authentication requirements.
Configuration
Prerequisites
- An OCI cloud Account with access to create an Integrated Application in an Identity Domain.
- Your FastMCP serverβs URL (For dev environments, it is http://localhost:8000. For PROD environments, it could be https://mcp.${DOMAIN}.com)
Step 1: Make sure client access is enabled for JWKβs URL
1
Navigate to OCI IAM Domain Settings
Login to OCI console (https://cloud.oracle.com for OCI commercial cloud).
From βIdentity & Securityβ menu, open Domains page.
On the Domains list page, select the domain that you are using for MCP Authentication.
Open Settings tab.
Click on βEdit Domain Settingsβ button.

2
Update Domain Setting
Enable βConfigure client accessβ checkbox as shown in the screenshot.

Step 2: Create OAuth client for MCP server authentication
Follow the Steps as mentioned below to create an OAuth client.1
Navigate to OCI IAM Integrated Applications
Login to OCI console (https://cloud.oracle.com for OCI commercial cloud).
From βIdentity & Securityβ menu, open Domains page.
On the Domains list page, select the domain in which you want to create MCP server OAuth client. If you need help finding the list page for the domain, see Listing Identity Domains..
On the details page, select Integrated applications. A list of applications in the domain is displayed.
2
Add an Integrated Application
Select Add application.
In the Add application window, select Confidential Application.
Select Launch workflow.
In the Add application details page, Enter name and description as shown below.

3
Update OAuth Configuration for an Integrated Application
Once the Integrated Application is created, Click on βOAuth configurationβ tab.
Click on βEdit OAuth configurationβ button.
Configure the application as OAuth client by selecting βConfigure this application as a client nowβ radio button.
Select βAuthorization codeβ grant type. If you are planning to use the same OAuth client application for token exchange, select βClient credentialsβ grant type as well. In the sample, we will use the same client.
For Authorization grant type, select redirect URL. In most cases, this will be the MCP server URL followed by β/oauth/callbackβ.

4
Activate the Integrated Application
Click on βSubmitβ button to update OAuth configuration for the client application.
Note: You donβt need to do any special configuration to support PKCE for the OAuth client.
Make sure to Activate the client application.
Note down client ID and client secret for the application. Update .env file and replace FASTMCP_SERVER_AUTH_OCI_CLIENT_ID and FASTMCP_SERVER_AUTH_OCI_CLIENT_SECRET values.
FASTMCP_SERVER_AUTH_OCI_IAM_GUID in the env file is the Identity domain URL that you chose for the MCP server.
Step 3: Token Exchange Setup (Only if MCP server needs to talk to OCI Control Plane)
Token exchange helps you exchange a logged-in userβs OCI IAM token for an OCI control plane session token, also known as UPST (User Principal Session Token). To learn more about token exchange, refer to my Workload Identity Federation Blog For token exchange, we need to configure Identity propagation trust. The blog above discusses setting up the trust using REST APIs. However, you can also use OCI CLI. Before using the CLI command below, ensure that you have created a token exchange OAuth client. In most cases, you can use the same OAuth client that you created above. You will use the client ID of the token exchange OAuth client in the CLI command below and replace it with . You will also need to update the client secret for the token exchange OAuth client in the .env file. It is the FASTMCP_SERVER_AUTH_OCI_CLIENT_SECRET parameter. Update FASTMCP_SERVER_AUTH_OCI_IAM_GUID and FASTMCP_SERVER_AUTH_OCI_CLIENT_ID as well for the token exchange OAuth client in the .env file.Running MCP server
Once the setup is complete, to run the MCP server, run the below command.client.py
- Your browser will open to OCI IAMβs login page
- Sign in with your OCI account and grant the requested consent
- After authorization, youβll be redirected back to the redirect path
- The client receives the token and can make authenticated requests
Production Configuration
New in version:Β 2.13.0
For production deployments with persistent token management across server restarts, configure jwt_signing_key, and client_storage:
server.py
Parameters (
jwt_signing_key and client_storage) work together to ensure tokens and client registrations survive server restarts. Wrap your storage in FernetEncryptionWrapper to encrypt sensitive OAuth tokens at Rest - without it, tokens are stored in plaintext. Store secrets in environment variables and use a persistent storage backend like Redis for distributed deployments.For complete details on these parameters, see the OAuth Proxy documentation.The client caches tokens locally, so you wonβt need to re-authenticate for subsequent runs unless the token expires or you explicitly clear the cache.
Environment Variables
For production deployments, use environment variables instead of hardcoding credentials.Provider Selection
Setting this environment variable allows the OCI provider to be used automatically without explicitly instantiating it in code.Set to
fastmcp.server.auth.providers.oci.OCIProvider to use OCI IAM authentication.OCI-Specific Configuration
These environment variables provide default values for the OCI IAM provider, whether itβs instantiated manually or configured viaFASTMCP_SERVER_AUTH.
Your OCI Application Configuration URL (e.g.,
idcs-asdascxasd11......identity.oraclecloud.com)Your OCI Application Configuration URL (e.g.,
https://{FASTMCP_SERVER_AUTH_OCI_IAM_GUID}.identity.oraclecloud.com/.well-known/openid-configuration)Your OCI Application Client ID (e.g.,
tv2ObNgaZAWWhhycr7Bz1LU2mxlnsmsB)Your OCI Application Client Secret (e.g.,
idcsssvPYqbjemq...)Public URL where OAuth endpoints will be accessible (includes any mount path)
Redirect path configured in your OCI IAM Integrated Application
.env file:
server.py

