- OIDC · Identity-based LLM — an LLM consumer whose routing is chosen from the
token’s
groupsclaim (roles). - OAuth2 · MCP — an MCP consumer gated by a custom scope. Interactive agents (Cursor, Claude Desktop, MCP Inspector) use TrustGate’s authorization-code broker; optional client-credentials tokens are only for curl checks.
Everything below uses Okta’s custom authorization server (the
/oauth2/{authServerId}
path). The default custom auth server ships in every Okta org, including the free
Integrator Free Plan org — ideal for a POC. In production Workforce orgs the custom
authorization server feature is the API Access Management product.Prerequisites
- An Okta org — note your domain, e.g.
dev-123456.okta.com. - Admin access to Security → API and Applications.
- A group you can route on (e.g.
TrustGate-Engineering) under Directory → Groups. - For Cursor / agent MCP login: the public MCP base URL of your gateway (e.g.
https://default-xxxxxxxx.mcp.neuraltrust.ai), so you can register the OAuth redirect URI.
SaaS vs Private
mcp_base_url: SaaS uses {slug}.mcp.neuraltrust.ai. Private/Hybrid uses the Dataplane MCP URL from Settings → Agent Gateway → General. Register {mcp_base_url}/oauth/callback on the IdP before testing agent login.The values you will collect
1. Authorization server
All steps happen in the Okta Admin Console at
https://<your-org>-admin.okta.com
(the admin console, not the end-user dashboard). Use the left sidebar to navigate.1
Open the authorization servers list
In the left sidebar go to Security → API, then open the Authorization Servers
tab.
2
Pick or create the server
Use the row named
default, or click Add Authorization Server (top right) and
fill:- Name:
trustgate - Audience:
api://trustgate - Description: anything.
3
Record the issuer and audience
Open the server and read the Settings tab. Copy the Issuer URI
(
https://{okta_domain}/oauth2/{okta_auth_server_id}) and the Audience — you will
paste both into the TrustGate credential. The keys endpoint is the issuer plus
/v1/keys:2. Add a custom scope (for MCP)
Stay in Security → API → Authorization Servers → your server; the tabs below are on that server’s detail page.1
Create the scope
Open the Scopes tab → click Add Scope:
- Name:
mcp.access - Display phrase:
MCP access - Tick Include in public metadata.
2
Add an access policy
Open the Access Policies tab → click Add Policy:
- Name:
trustgate - Assign to clients: All clients (or select your app once it exists).
3
Add a rule to the policy
On the policy you just created click Add Rule:
- Rule name:
mcp - Grant type: tick Authorization Code (required for Cursor and other interactive MCP clients). Also tick Client Credentials if you want curl / M2M test tokens from the same app.
- Scopes requested: Any scopes (or The following scopes →
mcp.access).
3. Add a groups claim (for role-based routing)
For OIDC role-based routing, the token must carry the claim you match roles on.1
Create a group (if you don't have one)
In the left sidebar go to Directory → Groups → Add Group. Name it
TrustGate-Engineering, save, then open it and use Assign people to add users.2
Add the claim
Back in Security → API → Authorization Servers → your server, open the Claims
tab → Add Claim:
- Name:
groups - Include in token type:
Access Token→Always(repeat forID Tokenif you also send ID tokens) - Value type:
Groups - Filter:
Matches regex.*(orStarts withTrustGate-to scope it)
3
Verify
After you mint a token (below), decode it and confirm the
groups array carries the
user’s group names.4. OIDC identity-based routing (LLM)
Use this when an LLM consumer should pick registries and models from the caller’s Okta token (for example thegroups claim). Everything below is done in the NeuralTrust app
under Agent Gateway — no API payloads.
Recommended order: Auth → Role → Consumer.
1
Create an OIDC auth
Go to Agent Gateway → Identity → Auth → New Auth.
- Type:
OIDC - Name: e.g.
okta-idp - Status: Active
- Issuer:
https://{okta_domain}/oauth2/{okta_auth_server_id}
(example:https://dev-123456.okta.com/oauth2/default) - JWKS URL:
https://{okta_domain}/oauth2/{okta_auth_server_id}/v1/keys - Audiences: the authorization server audience (example:
api://default) - Subject claim (optional): leave as
subunless your tokens use another claim
2
Create a role that matches Okta groups
Still under Identity, open the Roles tab → New Role.
- Role name: e.g.
engineering - Claim:
groups(the JWT claim path from step 3) - Value: the Okta group name to match, e.g.
TrustGate-Engineering
(the UI maps this as “claim contains any of these values”) - Resources: Add resource and select the LLM registries (and optional models) this role may reach
3
Create an LLM consumer with Identity-based routing
Go to Agent Gateway → Consumers → Consumer (new consumer panel).On General:
- Name: e.g.
okta-llm - Protocol:
LLM - Authentication → Method:
OIDC - OIDC provider: select the auth from the first step
- Switch from Static to Identity-based
- Roles: select the role(s) you created (at least one)
5. OAuth2 for MCP
Use this when Cursor (or another MCP client) should log in through Okta. Access is gated by the custom scope from step 2 (for examplemcp.access).
How interactive MCP login works
Agents such as Cursor do not call Okta with client credentials. They talk to TrustGate’s MCP OAuth facade (authorization code + PKCE):- The agent discovers TrustGate as the authorization server
(
/.well-known/oauth-protected-resource— often path-scoped to/{consumer_slug}/mcp— and/.well-known/oauth-authorization-server). - It opens TrustGate
/oauth/authorize. - TrustGate redirects the browser to Okta’s authorize endpoint using the Web app
Client ID from your OAuth2 auth, with
redirect_uri={mcp_base_url}/oauth/callback(host root — not under the consumer path). - After the user signs in, Okta returns to TrustGate
/oauth/callback; TrustGate finishes the agent handshake. - If the virtual MCP has upstream providers (Notion, Linear, …), TrustGate may show a
Connect your accounts page at
/{consumer_slug}/mcp/connectafter Okta succeeds — that is a separate consent detour, not a substitute for Okta login.
1
Create an OIDC Web Application in Okta
In the Okta Admin Console go to Applications → Applications → Create App
Integration:
- Sign-in method: OIDC - OpenID Connect
- Application type: Web Application → Next
-
App integration name:
trustgate-mcp - Grant types: tick Authorization Code (required). Optionally tick Refresh Token, and Client Credentials if you also want curl M2M tests from this same app.
-
Sign-in redirect URIs: add exactly
Example:Match character-for-character (scheme, host, path
/oauth/callback, no trailing slash). - Controlled access: assign the users or groups that should be able to connect (or allow everyone in the org for a POC).
mcp.access scope for this client.2
Create an OAuth2 auth in the app
Go to Agent Gateway → Identity → Auth → New Auth.
- Type:
OAuth2 - Name: e.g.
okta-mcp - Status: Active
- Setup: Interactive login · IdP with discovery (Okta, Entra ID)
- Issuer:
https://{okta_domain}/oauth2/{okta_auth_server_id}
(example:https://dev-123456.okta.com/oauth2/default) - Audiences: the authorization server audience (example:
api://default) - Client ID / Client secret: from the Web app above
- Session mode: Disabled (Okta issues JWTs; session mode is for opaque-token IdPs such as GitHub)
- Required scopes:
mcp.access(do not addopenid/profile/email)
https://{okta_domain}/oauth2/{okta_auth_server_id}/v1/keys.Click Create Auth.3
Create an MCP consumer and attach the auth
Go to Agent Gateway → Consumers → Consumer.
- Name: e.g.
okta-mcp - Protocol:
MCP - Authentication → Method:
OAuth2(MCP does not use OIDC) - OAuth client: select the auth from the previous step (or create one inline via Create Auth entity ”…”)
4
Connect from Cursor
Open the consumer → Connect tab. Copy the Cursor snippet (URL only — no API key):Add it as an MCP server in Cursor and start authentication. You should land on Okta
(login or an existing SSO session), then optionally TrustGate Connect your
accounts, then return to Cursor.After you change the Okta Client ID in the app, confirm the next browser authorize
URL’s
client_id= matches the Web app — a stale API Services client id means the
auth was not saved or the agent is still using an old server config.6. Get a test token (optional M2M)
Client credentials are not what Cursor uses. Use this only to decode a token and confirm issuer, audience, and scopes. The Okta app must allow the Client Credentials grant on the access-policy rule (and on the Web app if you enabled that grant type).access_token and confirm:
iss=https://dev-123456.okta.com/oauth2/defaultaud=api://defaultscp=["mcp.access"]
7. Force Okta login again (clear session)
If the browser skips the Okta UI and jumps straight to TrustGate’s connect page, you already had an Okta SSO cookie. To see login again:- Sign out at
https://{okta_domain}, or use a private / incognito window. - Clear site data for
{okta_domain}(and optionally{mcp_base_url}if a connect ticket is stuck). - In Admin → Directory → People → your user, clear active sessions if available.
- Retry MCP auth from the agent.
Troubleshooting
Next: Entra ID.