- Public Tools - Accessible to all authenticated users without additional permissions
- Role-Based Access - Tools assigned to specific roles (
admin,content_editor) - Group Membership - Users inherit permissions through group membership (managers, marketing)
- Temporal Access - Time-limited tool access with automatic expiration
- Resource-Specific Permissions - Fine-grained control over tool features (e.g., viewing private documents)
- Authenticates users with Auth0 OAuth 2.0
- Uses Auth0 FGA to determine which tools each user can access
- Dynamically filters tool lists based on user permissions
- Supports time-limited access grants that automatically expire
- Provides different data based on user roles (public vs private documents)
Prerequisites
1. Create or log in to your Auth0 account
1. Create or log in to your Auth0 account
3. Install the Auth0 CLI
3. Install the Auth0 CLI
- Follow the Auth0 CLI installation instructions.
- Log in to your account with the Auth0 CLI:
4. Install jq
4. Install jq
- macOS
- Linux
- Windows
1. Install the FGA CLI
1. Install the FGA CLI
- Install the FGA CLI:
- macOS
- Linux
- Windows
- Verify the installation:
2. Set up Auth0 FGA or OpenFGA
2. Set up Auth0 FGA or OpenFGA
- Auth0 FGA: Fully managed service at fga.dev. Best for production use.
- OpenFGA: Self-hosted open-source option. Best for local development and testing.
fga/model.fga) and initial permission tuples (fga/tuples.yaml) that will be imported using the FGA CLI.Configure tenant settings
1. Promote the connection to a domain-level connection
1. Promote the connection to a domain-level connection
List Your Connection
Choose Your Connections
- For the username-and-password database, look for the connection with the strategy
auth0. - For the Google social connection, look for the connection with the strategy
google-oauth2.
Upgrade the Connection to Domain-Level
YOUR_CONNECTION_ID with the actual ID (e.g., con_XXXXXXXXXXXXXXXX).Create an API to represent your MCP server
An MCP server is treated just like any other API in your Auth0 tenant, which means you can use the same access control, scoping, and authorization features. The API (also known as a Resource Server) represents your protected MCP Server. Run the following command to create an API in Auth0:rfc9068_profile_authz is used as the token dialect to include the permissions claim in the access token, which can be useful for the API to check user permissions without making additional calls.
For more details on protecting APIs with Auth0, check our quickstarts.
tool:greet and tool:whoami. The get_datetime tool is public and doesn’t require scopes, while get_documents uses FGA for authorization.Set up your FGA store
- Auth0 FGA
- OpenFGA (Local)
Create an Auth0 FGA account
Create a store
Generate API credentials
- Navigate to Settings in your store.
- In the Authorized Clients section, click + Create Client.
- Give your client a name and select the following permissions:
- Read/Write model, changes, and assertions - To query authorization decisions
- Write and delete tuples - To import tuples (user permissions)
- Read and query - To import the authorization model
- Click Create.
- Save the credentials shown in the confirmation modal.
Configure environment variables
FGA_API_URL may vary based on your region (e.g., api.eu1.fga.dev for Europe).Sample app
Start by downloading or cloning the sample app for this quickstart. The sample includes a FastMCP MCP server with Auth0 OAuth and Auth0 FGA integration in JavaScript/TypeScript.- Use sample app (recommended)
- Clone GitHub repository
Install packages
Install the required dependencies:Create your environment file
From the root of your sample app directory, run the following command to create a new.env file with your Auth0 configuration:
.env file. The variables you need depend on which FGA provider you’re using:
- Auth0 FGA
- OpenFGA (Local)
.env file using the credentials from your Auth0 FGA store:YOUR_STORE_IDwith your store ID from the Auth0 FGA dashboardYOUR_CLIENT_IDwith your client IDYOUR_CLIENT_SECRETwith your client secret- Update
FGA_API_URLif your store is in a different region (e.g.,https://api.eu1.fga.devfor Europe)
.env file should look like this:
- Auth0 FGA
- OpenFGA (Local)
Understanding the authorization model
The authorization model in this sample demonstrates how Auth0 FGA provides fine-grained access control using Relationship-Based Access Control (ReBAC).Authorization Model Structure
The complete model is defined infga/model.fga:
1. Public Tools
1. Public Tools
user:* means any authenticated user can use the get_datetime tool.2. Role-Based Access
2. Role-Based Access
admin role automatically gain access to these tools.3. Group Membership
3. Group Membership
managers group, they automatically inherit all permissions of the admin role, including access to all tools.4. Temporal Access
4. Temporal Access
5. Resource-Specific Permissions
5. Resource-Specific Permissions
get_documents tool checks this permission separately to determine whether to return private documents. This allows the same tool to provide different data based on user permissions.Example:- Admin role: Sees all documents (public + private)
- Content editor role: Sees only public documents
How Authorization Works
When a user connects to the MCP server:- The server authenticates the user with Auth0 (validates JWT token)
- The server queries FGA to get all tools the user can access:
- Checks
can_userelation for each tool - Evaluates group memberships, role assignments, and temporal conditions
- Checks
- The server returns only authorized tools to the MCP client
- When the user calls a tool like
get_documents, the server checkscan_view_private_documentsto determine what data to return
Import the authorization model and tuples
The sample includes a complete authorization model and initial permission tuples that define:- Public access to
get_datetimefor all users - Role assignments (
admin,content_editor) - Group-to-role mappings (
managers→admin,marketing→content_editor) - Tool access permissions for each role
Review the authorization model
fga/model.fga. It includes types for users, groups, roles, and tools, plus a temporal access condition.The initial tuples are defined in fga/tuples.yaml and establish the baseline permissions.Import the model and tuples
- Create a new FGA store (if using OpenFGA locally)
- Upload the authorization model from
fga/model.fga - Import the initial tuples from
fga/tuples.yaml - Run tests defined in
fga/store.fga.yamlto verify the setup
.env file as FGA_STORE_ID. If using Auth0 FGA with existing store, the command will update your store with the new model and tuples.Verify the import
Run the MCP server
Start the MCP server:.env file). You should see console output indicating:
- The server has started successfully
- FGA client has been initialized
- The server is listening for connections at
http://localhost:3001/mcp
Manage user permissions
The sample application includes helper scripts in thefga/ directory to make permission management easier. These scripts use the FGA CLI to add or remove authorization tuples dynamically.
Available Scripts
Add User to Group
Add User to Group
managers- Assigned toadminrole (all tools + private documents)marketing- Assigned tocontent_editorrole (all tools, public documents only)
Remove User from Group
Remove User from Group
Grant Temporal Access
Grant Temporal Access
s for seconds, m for minutes, h for hours).Available tools: greet, whoami, get_documentsget_datetime don’t need temporal access grants since they’re already accessible to all authenticated users.Reset Tuples
Reset Tuples
fga/tuples.yaml.Usage:fga/tuples.yaml. Useful for returning to a clean state during testing.Testing Permission Changes
After running any of these scripts, you need to reload the tools:- for MCP inspector: click ‘Clear’ in the MCP inspector tools panel and then ‘List Tools’
- for other MCP clients: you might need to reconnect the MCP Client to see the updated tool list.
Testing your MCP server
Now that your MCP server is up and running, you can test it by using tools like MCP Inspector.Learn how to test your Auth0-powered MCP server
Test authorization scenarios
Now test different authorization scenarios to see how FGA controls tool access. You’ll need to use an MCP client like MCP Inspector to connect to your server.Test baseline access
get_datetimeThis demonstrates that without any role or group assignments, authenticated users only have access to public tools.Grant admin access via managers group
YOUR_EMAIL with the email address you use to authenticate.Reconnect in your MCP client and verify you now see all tools.Expected tools: get_datetime, greet, whoami, get_documentsCall the get_documents tool and verify that you see both public and private documents in the response. This demonstrates resource-specific permissions based on the admin role.Test content editor role
get_datetime, greet, whoami, get_documentsCall the get_documents tool and verify that you now see only public documents (no private documents). This demonstrates how the same tool can provide different data based on user roles.Key difference: Content editors have access to the same tools as admins but don’t have the can_view_private_documents permission.Test temporal access
greet tool.Immediately reconnect in your MCP client.Expected tools: get_datetime, greetCall the greet tool to verify it works.Wait 25 seconds and reconnect again.Expected tools: get_datetime (only)The greet tool should no longer appear. This demonstrates automatic expiration of temporal access without any cleanup required.Next steps
- Learn about the simpler scope-based approach in Authorization for Your MCP Server
- Explore Auth0 FGA documentation to learn more about designing authorization models
- Read about OpenFGA for advanced modeling patterns and best practices
- Learn how to test your MCP server with MCP Inspector