Authorization with Auth0
Example: Auth0
This guide uses Auth0 as the Identity Provider.
Pre-requisites
Clone the repo for the example project.
shgit clone git@github.com:apollographql/apollo-mcp-server.gitInstall or update the Rover CLI. You need at least v0.35 or later.
shcurl -sSL https://rover.apollo.dev/nix/latest | sh
Step 1: Set up the Auth0 Identity Provider
Create the Auth0 API
In your dashboard, navigate to Applications -> APIs.
Click Create API.
Give it a friendly name like
MCP Auth API.For the Identifier field, Auth0 recommends using a URL. This identifier is used in the MCP server configuration later as the
audienceproperty. For this guide, usehttp://localhost:8000/mcp-example.Leave the defaults for the rest of the fields and click Create.
Navigate to your dashboard Settings.
Under General -> API Authorization Settings, set the Default Audience to the
Identifieryou chose.Navigate to the Advanced tab.
Toggle on Dynamic Client Registration (DCR) to enable dynamic client registration.
Toggle on Enable Application Connections.
Save your changes.
Create the Auth0 Connection
The Auth0 Connection is the method clients use to authenticate. This guide uses the default Username-Password-Authentication connection.
In your Auth0 dashboard, navigate to Authentication -> Database.
Create the default Username-Password-Authentication connection. Click the Try Connection button to test it and set up a username and password for later.
Back on your Auth0 dashboard, note the Connection Identifier at the top of the page. It should start with something like
con_. Copy it into a temporary location. This guide refers to it as<CONNECTION ID>.Navigate to Applications -> APIs -> Auth0 Management API.
Copy the Identifier for the Auth0 Management API to a temporary location. It should look something like
dev-123456.us.auth0.com, wheredev-123456is your Auth0 tenant ID. This guide refers to it as<AUTH0 DOMAIN>.Click the API Explorer tab. Copy the token value to a temporary location. This guide refers to it as
<MGMT API ACCESS TOKEN>.Run the following
curlcommand to promote the connection to domain level, replacing<CONNECTION ID>,<AUTH0 DOMAIN>, and<MGMT API ACCESS TOKEN>with the values you copied in the previous steps:sh1curl --request PATCH \ 2 --url 'https://<AUTH0 DOMAIN>/api/v2/connections/<CONNECTION ID>' \ 3 --header 'authorization: Bearer <MGMT API ACCESS TOKEN>' \ 4 --header 'cache-control: no-cache' \ 5 --header 'content-type: application/json' \ 6 --data '{ "is_domain_connection": true }'
Your Auth0 setup is now complete. You have an API with an audience and a connection for authentication.
Something went wrong? Try these troubleshooting steps
- Check that the
curlcommand is correct and that you have the correct values for<CONNECTION ID>,<AUTH0 DOMAIN>, and<MGMT API ACCESS TOKEN>. - Check that you have the correct permissions to promote the connection to domain level.
- In your Auth0 dashboard, navigate to Applications -> Applications -> API Explorer Application -> APIs. Ensure that the Auth0 Management API is authorized.
- Expand the Auth0 Management API item and enable the
update:connectionspermission. - Click Update to save your changes.
Step 2: Configure the MCP Server for authorization
Configure the MCP server to use the Auth0 instance for authentication.
Open the example repo you cloned earlier.
In the
graphql/TheSpaceDevsdirectory, open theconfig.yamlfile.Add the following
authconfiguration under thetransportkey:YAMLgraphql/TheSpaceDevs/config.yaml1transport: 2 type: streamable_http 3 4 auth: 5 servers: 6 - https://<AUTH0 DOMAIN> # Fill in your Auth0 domain 7 audiences: 8 - <AUTH0 DEFAULT AUDIENCE> # Fill in your Auth0 Identifier 9 resource: http://127.0.0.1:8000/mcp 10 scopes: 11 - read:users # Adjust scopes as neededReplace the
<AUTH0 DOMAIN>with your own Auth0 domain from earlier.Replace the
<AUTH0 DEFAULT AUDIENCE>with the matchingIdentifieryou set when creating the Auth0 API. In this guide, you usedhttp://localhost:8000/mcp-example.
Your MCP server is now configured to use Auth0 for authentication.
Step 3: Configure the router for JWT authentication
Configure your GraphOS Router to validate JWTs issued by Auth0. This involves setting up the JWKS endpoint and defining the authorization rules.
Define authorization and authentication rules in the router
In the
graphql/TheSpaceDevsdirectory, create a new file calledrouter.yaml.Paste the following configuration, replacing
<AUTH0 DOMAIN>with your Auth0 domain:YAMLgraphql/TheSpaceDevs/router.yaml1authorization: 2 require_authentication: true # Enforces authentication on all requests 3authentication: 4 router: 5 jwt: 6 jwks: 7 - url: https://<AUTH0 DOMAIN>/.well-known/jwks.json 8homepage: 9 enabled: false 10sandbox: 11 enabled: true 12supergraph: 13 introspection: trueWith this configuration, the router requires authentication for all requests. If a request doesn't include an Authorization token, the router returns an
UNAUTHENTICATEDerror.
Retrieve your GraphOS license credentials for auth
You need a graph's credentials and a valid GraphOS plan to use the router's authentication features.
Navigate to GraphOS Studio and log in.
Click Add graph and Connect an existing graph.
Give it a name and click Next.
In the next modal, find the command that looks something like this:
shAPOLLO_KEY=<YOUR_APOLLO_KEY> \ rover subgraph publish <YOUR_APOLLO_GRAPH_REF> \ --schema ./products-schema.graphql \ --name your-subgraph-name \ --routing-url http://products.prod.svc.cluster.local:4001/graphqlNote: You don't need to run this command.
Retrieve the values for
YOUR_APOLLO_KEYandYOUR_APOLLO_GRAPH_REFfrom the modal and click Finish later.
Run the MCP Server and router
Back in your terminal, in the root of the project directory, replace and run the following command to start the MCP Server and the router together:
sh1APOLLO_GRAPH_REF=<YOUR_APOLLO_GRAPH_REF> APOLLO_KEY=<YOUR_APOLLO_KEY> \ 2rover dev --supergraph-config ./graphql/TheSpaceDevs/supergraph.yaml \ 3--router-config ./graphql/TheSpaceDevs/router.yaml \ 4--mcp ./graphql/TheSpaceDevs/config.yamlTest the router by navigating to
http://localhost:4000in your browser. You should see the Explorer, where you can run GraphQL queries against the router.Remember, the router is configured to require authentication on all requests. Any operations without a valid Authorization token returns an
UNAUTHENTICATEDerror. Run the operation:GraphQL1query GetAstronautsCurrentlyInSpace { 2 astronauts(filters: { inSpace: true, search: "" }) { 3 results { 4 id 5 name 6 timeInSpace 7 lastFlight 8 } 9 } 10}You should see an
UNAUTHENTICATEDerror, which means the router is correctly enforcing authentication.
Step 4: Make requests with MCP Inspector
In a new terminal window, run the MCP Inspector:
sh1npx @modelcontextprotocol/inspectorThe browser should open automatically with a proxy auth token.
In the MCP Inspector, select
Streamable HTTPas the Transport Type and enterhttp://127.0.0.1:8000/mcpas the URL.Click Connect. This triggers the OAuth flow, and you are redirected to the Auth0 login page.
Log in with the credentials you set up in the Auth0 connection and allow MCP Inspector access.
After you connect, the browser redirects back to MCP Inspector.
Click List Tools to see the available tools.
Select the
GetAstronautsCurrentlyInSpacetool listed and click Run Tool.You should see the results of the query, which means the authentication is working correctly.
You can select the Auth tab in MCP Inspector to see the details of the authenticated user and the scopes granted.
Alternative: Guided OAuth flow in MCP Inspector
- Click Open Auth Settings.
- In the OAuth Flow Progress section, click Continue to start the Metadata Discovery step.
- Click Continue to start the Client Registration step. Expand the Registered Client Information step to note the
client_idvalue. - Click Continue to start the Preparing Authorization step. Click the link to open up a new tab to authorize MCP Inspector.
- Copy the authorization code and return to MCP Inspector.
- Paste the code in the next step Request Authorization and acquire authorization code then click Continue.
- Click Continue to start the Token Request step. This completes the authentication flow.
- In your Auth0 dashboard, navigate to Applications.
- Select the client for MCP Inspector. If you have multiple entries, find the
client_idvalue from the MCP Inspector. - In the client's Settings -> Application URIs, copy and paste the existing callback URL. Then, remove the
/debugsuffix. Make sure the URLs are comma-separated. It should look something like this:txt1http://localhost:6274/oauth/callback/debug, 2http://localhost:6274/oauth/callback - Back in MCP Inspector, click Connect. You are now authenticated and can run tools as usual.
Step 5: Make requests with an MCP Client (Goose)
We'll use Goose as our MCP Client. Goose allows you to choose between many different LLMs and provides some built-in functionality for connecting to MCP servers, called Extensions.
Install the Goose CLI, following the instructions for your operating system. Set up the LLM provider of your choice with goose configure --> Configure Providers. Each provider has its own set of instructions, rate limiting and pricing.
Then, continue with the following steps:
In your terminal, run
goose configure.Select or enter the following answers at the prompts:
| Prompt | Answer |
|---|---|
| "What would you like to configure?" | "Add Extension" |
| "What type of extension would you like to add?" | "Command Line Extension" |
| "What would you like to call this extension?" | "mcp-auth-quickstart" |
| "What command should be run?" | npx mcp-remote http://127.0.0.1:8000/mcp |
| Other prompts (timeout, description, environment variables) | Use the default values |
To start Goose, type
goose. This will open a browser window and send you through the auth flow.Log in to your Auth0 instance and authorize your MCP server to gain access to your tools.
In Goose, ask "What astronauts are in space right now?". This question is similar to the
GetAstronautsCurrentlyInSpaceoperation from earlier, which fails as unauthenticated without the proper token.Goose will select the
GetAstronautsCurrentlyInSpacetool and respond with information about the astronauts found in TheSpaceDevs.
Troubleshooting
Common Issues
MCP Server Won't Start
Error: "Port 8000 is already in use"
Solution: Kill any existing processes using port 8000 or specify a different port with the
transport.portoption orAPOLLO_MCP_TRANSPORT__PORTenv variable
Error: "Failed to load supergraph configuration"
Solution: Verify you're running the command from the repo root directory
Solution: Check that the path to
supergraph.yamlis correct
Error: "License violation"
Solution: Ensure that the
rover devcommand includes validAPOLLO_KEYandAPOLLO_GRAPH_REFvalues and that your plan supports authentication features.
Error: "What URL is your subgraph running on?" question in terminal
Solution: Verify that the file path for your config files is correct. You should run the
rover devcommand from the root of the example project directory and the file paths should be relative to that root.
MCP Inspector Connection Issues
Error: "Failed to connect to server"
Solution: Ensure the MCP server is running (check terminal output)
Solution: Verify you're using the correct URL (
http://127.0.0.1:8000/mcp)Solution: Check if your firewall is blocking the connection
Infinite loop during OAuth flow
Issue: After logging in to Auth0, MCP Inspector keeps refreshing and doesn't complete the OAuth flow
Solution: In MCP Inspector, open the Authentication panel in the sidebar. Clear out any values in the Header Name and Bearer Token fields. Then try connecting again.
Solution: In MCP Inspector, select Clear OAuth State and try connecting again.
Getting Help
If you're still having issues:
Check the Apollo MCP Server GitHub issues.
Join the Apollo Community MCP Server Category.
Contact your Apollo representative for direct support.