Skip to main content

LiteLLM as requesting app

Let LiteLLM call MCP tools on behalf of a signed-in user. LiteLLM exchanges the user's login token for an ID-JAG, then exchanges the ID-JAG for an access token at the MCP server's authorization server.

info

This feature requires an enterprise license, a database, and LiteLLM SSO.

Get started​

Select your identity provider.

This walkthrough uses your existing LiteLLM OIDC app in Okta.

1. Register LiteLLM as an AI agent​

Open LiteLLM in Applications and Resources > Applications.

  1. Under Grant type, enable Authorization Code and Refresh Token.
  2. In Assignments, assign the users who will test the flow.
  3. Open Machine Assignments > Resources and select Register AI agent. Under User access and authentication, choose Select an existing app, select LiteLLM, and complete the registration.
Okta grant types with Authorization Code and Refresh Token selected
Enable Authorization Code and Refresh Token
Okta AI agent registration with Select an existing app and LiteLLM Admin UI selected
Link the agent to your existing LiteLLM app

In the agent's Client registration, select Client secret authentication. Use its client ID and secret as GENERIC_CLIENT_ID and GENERIC_CLIENT_SECRET in your LiteLLM SSO settings. Use https://your-org.okta.com as the SSO issuer.

Okta client registration showing masked client secret and client ID fields
Client secret and client ID

2. Set up the MCP resource app​

The MCP authorization server must accept ID-JAGs from your Okta org. If the resource is another LiteLLM proxy, follow its resource-app setup.

  1. At the MCP authorization server, register LiteLLM as a client. Save its client ID and secret, plus the server's issuer and token endpoint, for step 4.
  2. In Okta's Applications and Resources > Applications, add or open the MCP resource app using the provider's SSO settings. Assign the users from the LiteLLM app.
  3. Open Machine Assignments > Callers > Cross App Access > Edit and enable XAA. Set Issuer URL to the MCP authorization server's issuer and add its supported scopes.
Okta XAA settings with the as.mcp.example.com issuer and mcp.tools.read scope
Example XAA settings for the MCP resource

3. Connect LiteLLM to the resource​

Return to the LiteLLM AI agent's Resource connections tab and add the MCP resource app.

FieldValue
AI agent's client ID registered in this appThe client ID from the MCP authorization server in step 2.
Resource identifierThe MCP service's resource URL.
ScopesSelect Allow specific scopes and choose the scopes LiteLLM may request.
Okta resource connection with client ID litellm-client, resource https://mcp.example.com, and mcp.tools.read scope
Connect LiteLLM to the MCP resource

Activate the agent if its status is STAGED.

4. Configure LiteLLM​

Use your Okta SSO credentials for the ID-JAG exchange. Set RESOURCE_AS_CLIENT_SECRET to LiteLLM's client secret at the MCP authorization server.

Add these settings to your existing deployment. Replace the example URLs, <resource-client-id>, and scopes with the values from steps 2 and 3.

values.yaml
envVars:
GENERIC_SCOPE: "openid profile email offline_access"
environmentSecrets: [litellm-id-jag]
proxy_config:
mcp_servers:
internal_tools:
url: "https://mcp.example.com/mcp"
transport: http
auth_type: oauth2_id_jag
token_exchange_endpoint: "https://your-org.okta.com/oauth2/v1/token"
client_id: os.environ/GENERIC_CLIENT_ID
client_secret: os.environ/GENERIC_CLIENT_SECRET
id_jag_subject_source: refresh_token
id_jag_resource_token_endpoint: "https://as.mcp.example.com/oauth2/token"
id_jag_resource_client_id: "<resource-client-id>"
id_jag_resource_client_secret: os.environ/RESOURCE_AS_CLIENT_SECRET
audience: "https://as.mcp.example.com"
id_jag_resource: "https://mcp.example.com"
scopes: [mcp.tools.read]

5. Sign in and call the MCP server​

After deploying, sign in to https://litellm.example.com/ui through Okta. Use that user's credential with access to internal_tools:

curl -X POST "https://litellm.example.com/internal_tools/mcp" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "x-litellm-api-key: Bearer <user-credential>" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'

A successful response lists the server's tools.

Troubleshooting​

Response or logCause and fix
401 invalid_clientMatch the IdP client credentials to the AI agent's Client registration.
invalid_targetMatch audience to the resource app's Issuer URL, and id_jag_resource to its resource identifier.
unauthorized_clientAllow the requested scopes on the agent's Resource connection.
requested_token_type invalid or not supportedUse https://<your-org>.okta.com/oauth2/v1/token for the ID-JAG exchange.
invalid_grant with a SAML subjectSet id_jag_subject_source: refresh_token and the SAML app's audience to the AI agent's client ID. Check assertion expiry. Okta SAML setup.
412: missing or expired credentialsSign in to LiteLLM again. For a missing refresh token, check login logs and enable Refresh Token on the Okta app.
Login logs report multiple refresh-token clientsGive all servers using id_jag_subject_source: refresh_token the same client_id and token_exchange_endpoint.
Resource authorization server rejects the ID-JAGCheck the resource client credentials and match audience and id_jag_resource_token_endpoint to the resource authorization server.
MCP server receives the user's credentialSend the credential in x-litellm-api-key.
503 on connectCheck database connectivity.
No tools; _meta contains http_status: 412Call /internal_tools/mcp to read the full error.
LiteLLM Enterprise
SSO/SAML, audit logs, spend tracking, multi-team management, and guardrails, built for production.
Learn more →