Per-user upstream credentials for shared MCP servers in LiteLLM

LiteLLM can store upstream keys and OAuth tokens per user and per MCP server, so each person calls a shared server under their own identity. Service accounts need separate machine users to keep their upstream identities apart.

On this page

Per-user credentials for shared MCP servers in LiteLLM: when teams need them

Choose per-user upstream credentials when a shared MCP server must act under each person's own account, key or permissions. A typical case is a shared project tracker, code host or data warehouse connector where the upstream system logs actions, enforces row or repository access, or bills usage against the individual. If every caller uses one service credential, the upstream system sees one identity for everyone, so its audit trail and access rules cannot distinguish who did what. In LiteLLM, the stored BYOK keys, per-user environment variables and per-user OAuth tokens belong to the pair of user and MCP server, not to an individual virtual key. That binding determines how you design access: a person's credential follows that person across the virtual keys they hold, and it is not reachable through a key that someone else uses.

Use a single shared service credential when the upstream system only needs to know that the request came from your platform, when the MCP server is read-only over data that all permitted callers may see, or when the upstream account has no per-person permissions to enforce. Shared credentials are simpler to rotate and cost less to administer, but they put every caller's reach on one identity. Before you decide, ask the MCP server owner whether it enforces per-user authorization at all, whether its audit logs record the caller, and which OAuth scopes or API key permissions each user would need. Confirm these with the vendor or the server's documentation, because the answer changes the design more than any LiteLLM setting does.

Service accounts need separate handling. Because the stored credential is tied to the user and server pair, a CI job or automated agent that must have its own upstream identity needs a machine user in LiteLLM with its own stored credentials, rather than borrowing a person's token through a shared key. Plan who owns each machine user, how its upstream credential is rotated, and what happens when the employee who first supplied a token leaves. Map each machine user to the access it needs before you create it, so the separation between human and automated identities is visible in both LiteLLM and the upstream audit logs. The LiteLLM per-user MCP authentication documentation describes how these credentials are stored and selected.

Which credential type fits which upstream server

LiteLLM can attach upstream credentials to a shared MCP server in several ways, and each one binds to a different identity. The right choice depends on whether the upstream service tracks individual users, whether each person must supply their own secret, and whether calls should be attributed to a person or a service.

Stored BYOK keys

A user saves their own API key for a specific MCP server in LiteLLM, and the gateway uses that key when that user calls the server. The key binds to the pair of user and server, not to any virtual key the user holds. Check who issues the key, whether the upstream service bills or limits per key, and how the user rotates or revokes it when they leave.

Per-user MCP docs

Per-user environment variables

Each user supplies environment variables that LiteLLM passes to a server started over stdio, so the server runs with that person's configuration. The binding is again the user and server pair. Confirm that the server reads these values at launch, and that secrets in them are not written to logs or shared process listings.

Per-user OAuth tokens

A user completes an OAuth flow against the upstream MCP server, and LiteLLM stores the resulting token for that user and server. The upstream system then sees that person as the actor. Confirm the scopes requested, how refresh is handled, and whether the upstream service supports the token lifetimes your policy requires.

Machine users for service accounts

Because stored credentials follow the user and server pair rather than the virtual key, a service account that needs its own upstream identity needs its own machine user. Each machine user holds its own BYOK key or token. Plan one machine user per distinct upstream identity, and check that the upstream audit trail names the machine user, not a shared person.

Shared service credentials

A single credential held by the platform team is used for every caller of a server. It needs no per-user setup, but every call appears upstream under one identity, so per-user permissions and audit trails must come from LiteLLM. Use it only for low-risk, read-only servers, and confirm who can view and rotate the shared secret.

Choosing by upstream behavior

Before choosing, list for each MCP server whether it enforces per-user permissions, whether it records the acting identity, and whether users can obtain their own credentials. A server that enforces per-user access needs user-bound credentials. A server with no per-user controls is a candidate for a shared or machine-user credential with gateway-side permissions.

Configuration options and when each fits

This table compares four ways to give a shared MCP server its upstream credentials in LiteLLM: BYOK keys, per-user environment variables, per-user OAuth tokens and machine users. Read each row against audit attribution, rotation burden and offboarding behavior to decide which model fits each server and caller group. Confirm exact configuration keys in the LiteLLM per-user MCP credentials documentation before you build.

OptionAudit attributionRotation and offboardingWhen it fits
BYOK key stored per user and serverUpstream calls tie to the user who stored the keyEach user rotates their own key; removing the user's stored key is a separate step to confirmUsers who already hold personal API keys for a shared server and need their own quota
Per-user environment variableUpstream calls tie to the user who holds the variableValues live per user and server, so each change must be made for every affected userStdio-style servers that read identity from environment settings; confirm how the setting is scoped in your version
Per-user OAuth tokenUpstream actions show the individual user's identityTokens expire and refresh per user; offboarding depends on revoking the user's upstream grant as well as their LiteLLM accessInteractive tools where each person must act as themselves in the upstream system
Machine user (service account)Upstream actions show the service identity, not a personOne credential to rotate per service; retire the machine user when the workload endsPipelines and agents that need their own upstream identity, since stored credentials attach to a user and server pair, not to a virtual key

How a request resolves the right upstream credential

The request starts with a caller presenting a LiteLLM virtual key tied to a user or to a machine user. The gateway identifies the caller, then looks up the credential stored for that user and MCP server pair, such as a BYOK key or a per-user OAuth token, before it calls the shared MCP server. Service accounts take the machine user branch, because stored credentials belong to the user and server pair rather than to a virtual key. Check that every stored secret stays inside the trust boundary you control.

Credential resolution per user and MCP server, with the machine user branch and stored secrets boundary.

Setting up per-user credentials for one MCP server

This sequence takes one shared MCP server from its upstream auth model to a tested per-user credential, then adds machine users so service accounts keep their own upstream identities. Each step ends with a check you can run before moving on.

  1. Confirm the upstream auth model

    Before touching LiteLLM, confirm with the MCP server owner how the server authenticates callers. Ask whether it accepts a static API key, a per-user BYOK key, a per-user OAuth access token, or a service credential, and whether it can tell users apart at all. Record the answer, the token lifetime and the scopes each user needs. You are done when the owner has confirmed in writing which method applies, because every later step depends on it.

  2. Register the MCP server in LiteLLM

    An administrator adds the MCP server to the LiteLLM proxy over the transport the server supports, such as Streamable HTTP, SSE or stdio, and sets its authentication mode to match the answer from the first step. Keep the server's configuration under version control, and keep any shared upstream secret in your secret manager, not in the config file. You are done when the server appears in the LiteLLM admin UI and a test call from an administrator key lists its tools.

  3. Choose the user credential method

    Pick one credential method per server. BYOK stores a key the user supplies, per-user environment variables hold values the server reads at call time, and per-user OAuth tokens come from a sign-in the user completes. Note that stored BYOK keys, per-user environment variables and per-user OAuth tokens belong to the pair of user and MCP server, so a credential is never shared across users. Confirm with security whether the chosen method meets your token storage and revocation rules. You are done when the method and its owner are written down for this server.

  4. Store and test one user credential

    Pick one pilot user and have that user store their credential for this server through the LiteLLM flow for the chosen method. Then make one tool call as that user and check the upstream server's own logs to confirm the request arrived under that user's identity, not the administrator's. Also confirm that a second user calling the same server does not see the first user's credential. You are done when the pilot call succeeds and the upstream log shows the correct identity.

  5. Test revocation and missing credentials

    Run two negative tests before widening access. First, call the server as a user who has not stored a credential and confirm the call fails with a clear error rather than falling back to a shared key. Second, remove or revoke the pilot user's credential and confirm later calls stop working. Log both results. You are done when both failures behave as designed and no shared fallback path exists.

  6. Create machine users for service accounts

    For each service account that needs its own upstream identity, create a separate machine user in LiteLLM and store that identity's credential against the machine user and the server. Do not reuse a person's virtual key or credential for a service, because credentials attach to the user and server pair rather than to an individual virtual key. You are done when each service account maps to its own machine user and the upstream logs show distinct identities for people and services.

  7. Verify service and user separation end to end

    Run one call from a person and one from each service account against the same MCP server, then compare the upstream logs and LiteLLM request logs side by side. Check that each call carries the expected identity and that no call used another party's credential. Record the results with the server owner and the security team. You are done when the evidence shows clean separation and the owner signs off on the configuration.

Why service accounts need their own machine users

Stored upstream credentials belong to the pair of user and MCP server, not to a virtual key, so a service account that shares a virtual key with people cannot have an upstream identity of its own. BYOK keys, per-user environment variables and per-user OAuth tokens are all stored against that user and server combination. If a CI job, a scheduled agent or a batch process needs to call a shared MCP server as a different upstream identity from the people who hold the same key, the only supported way to separate them in LiteLLM is a distinct machine user with its own stored credentials.

Plan the machine users before you register credentials. For each service account, decide which team owns it, who can rotate its upstream credential, and which MCP servers and tools it needs. Give each machine user the narrowest upstream permissions the target system allows, and record the owner in your inventory so a departing engineer does not leave an orphaned identity behind. Confirm with your MCP server's administrators how they issue and revoke credentials for non-human accounts, because LiteLLM can only store what the upstream system will issue.

Attribution follows the same boundary. Logs and spend records tied to a machine user show that identity's calls, so a single shared key makes every automated call look like the same person or the same team. Separate machine users let audit reviewers and cost reports tell a scheduled job from an engineer's interactive session. Before rollout, check in a test environment exactly which user and key fields your logging pipeline records for MCP calls, since that determines what your audit trail can answer.

Security and operational considerations for stored upstream credentials

Stored upstream credentials are the part of a shared MCP setup that outlives a single request. The cards below cover where those secrets sit, how they are protected, how they are rotated and removed, and what the audit trail does and does not show in each LiteLLM edition.

Where stored secrets live

Stored BYOK keys, per-user environment variables and per-user OAuth tokens are kept per pair of user and MCP server, not per virtual key. That means the database holding them becomes a credential store and must be covered by the same access, backup and encryption controls as any other secret-bearing system. Ask your team to confirm exactly which tables hold these values in the version you run, and who can read them directly.

Per-user MCP docs

Encryption and secret manager options

Confirm with the Enterprise docs whether stored per-user credentials can be encrypted at rest with a key you control and whether they can be read from a secret manager such as Vault, AWS, Azure, Google or CyberArk. Enterprise lists these secret manager integrations, but the mapping to per-user credential storage is not something to assume. Get the answer in writing before you design key custody.

Enterprise docs

Offboarding a departing user

When a user leaves, their stored BYOK keys and OAuth tokens for each shared server must be removed or revoked, or the upstream access they represent stays live. Revoke the token at the upstream provider as well as in LiteLLM, since deleting a stored copy does not invalidate it. Write this into the offboarding runbook and test it on a dummy account before relying on it.

Rotation of shared and per-user secrets

Machine users hold their own upstream identities, so their credentials need a rotation schedule separate from human users. Plan who rotates each BYOK key, how the new value is written without downtime, and how a failed rotation is detected. Confirm with the upstream provider how long old tokens remain valid after reissue, because that window sets how quickly a leaked secret stops working.

Audit trail gaps by edition

Audit logs are listed as an Enterprise feature, so an open-source deployment should be assumed to lack the same record of who changed or used a stored credential. Before go-live, confirm what request logging captures in your edition and whether it records credential changes, not only tool calls. Fill any gap with upstream provider logs and your own change records.

Machine user review cadence

Machine users that call shared servers accumulate permissions over time. Set a recurring review that lists each machine user, the MCP servers it can reach and the upstream identity behind it, then removes anything unused. Ask your team to confirm how you will export that list from the gateway, since a review you cannot run from data is hard to evidence to an auditor.

Questions teams ask before per-user MCP credentials go live

What drives the cost of setting up per-user MCP credentials in LiteLLM?

The main drivers are the number of shared MCP servers, the number of users and service accounts that need their own upstream identity, and the upstream auth types involved, such as BYOK API keys, per-user OAuth tokens or per-user environment variables. Each server needs its own credential flow and its own test cases, so more servers and auth types add design and verification work. Machine users add a set of identities to create, map and review. Ask any partner to price these items separately in a written scope, and ask which parts are one-time setup and which recur, such as token rotation reviews, user offboarding checks and retesting after upgrades.

How long does it take to put per-user credentials into production?

The duration depends on your environment more than on the LiteLLM configuration itself. The time usually goes to upstream admin approvals, confirming how each MCP server issues and scopes tokens, agreeing on how machine users map to service accounts, and running a security review before release. If your identity provider and upstream servers already support the flows you need, the work is shorter. If you must add OAuth clients, change consent settings or split service accounts, expect more coordination. Ask for a timeline that lists the dependencies on your side and the dates each one needs.

Can our internal team set this up without outside help?

Yes, if you have people who can administer the LiteLLM proxy, configure your identity provider and get admin access to each upstream MCP server. The harder parts are the decisions: which credential type belongs to which user and server, how service accounts are separated, and what happens when a person leaves. Teams without prior experience with OAuth token storage or MCP server administration often use an outside partner for design and review, then run the platform themselves. DeployOpen works this way with fixed-scope engagements, and ongoing support is available as a retainer.

What do we need to provide before the work starts?

You need administrative access to the LiteLLM proxy and its PostgreSQL database, plus admin rights on each upstream MCP server that will hold per-user credentials. You also need decisions from your identity and security teams: which identity provider is the source of truth, who approves machine users, how long user tokens may live and how offboarding removes stored credentials. A security review of the design is usually needed before go-live. Confirm these inputs in the written scope so that delays are visible early.

Which upstream MCP servers are the hardest to set up for per-user access?

Servers that use OAuth with strict consent rules, require tenant-specific app registrations, or do not document how tokens are scoped tend to take the longest. Servers that accept a BYOK API key per user are usually simpler, but the key storage and rotation rules still need to be agreed. Before scoping, list each server, its auth method, whether it supports client credentials, and who administers it. Ask the vendor or your server owner to confirm these details in writing.

How do we keep a service account from using a person's upstream credentials?

Stored BYOK keys, per-user environment variables and per-user OAuth tokens are tied to the pair of a user and an MCP server, not to a virtual key. A service account that needs its own upstream identity therefore needs its own machine user, with credentials stored against that machine user. Do not let automation run under a personal identity to avoid this step. Document which machine users exist, who owns each one and how their credentials are rotated, so audit trails show the right actor.

What should we check after go-live and after LiteLLM upgrades?

Check that each user's stored credential resolves only for the intended server, that removed users lose access to stored credentials, and that machine users cannot reach other identities' tokens. Repeat these checks after each LiteLLM upgrade, because the supported release line moves forward and configuration behavior can change. Keep the proxy on a release line that LiteLLM still supports. The current release on the GitHub releases page is v1.105.1, published October 14, 2026, so confirm the version you plan to deploy against that page before you lock the design.

How DeployOpen scopes per-user MCP credential work

DeployOpen fixes the scope of per-user MCP credential work in writing before any build starts, so the client knows which MCP servers are covered, how users and service accounts map to upstream identities, and what testing and documentation will be delivered. The scope document names each shared server, the credential type it uses (BYOK key, per-user environment variable, per-user OAuth token, or a delegated flow handled by a sibling topic), the teams that will hold each credential, and the machine users planned for service accounts. Because stored BYOK keys, per-user environment variables and per-user OAuth tokens are keyed to the pair of user and MCP server, the scope also records which automated callers need their own machine user rather than sharing a person's credentials.

The written scope also covers the self-hosted footprint. It states where the LiteLLM proxy, its PostgreSQL database and any Redis instance run, which identity provider issues user identities, how the secret store holds encrypted upstream credentials, and what test environment is used before production. Testing is scoped as a set of checks: a user can store and revoke only their own upstream credential, a machine user cannot read a person's credential, and a removed user's tokens stop working for the servers they were attached to. Documentation covers the registration steps, the offboarding procedure and the evidence an internal reviewer would ask for. Ask DeployOpen to list each deliverable and the acceptance check for it. Retainers are available for ongoing support, upgrades and continuous testing after the initial scope closes.

How DeployOpen delivers LiteLLM MCP credential integrations

DeployOpen scopes, builds, tests and documents per-user upstream credentials for shared MCP servers in LiteLLM inside infrastructure you control. Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.

How we scope

  • We list each shared MCP server, the upstream system behind it, and whether it uses BYOK keys, per-user OAuth or both.
  • We map which people and service accounts need their own upstream identity, and which can safely share one.
  • The written scope names the machine users, the credential storage location and the test cases agreed with your security team.

How we build

  • We configure per-user BYOK keys and per-user OAuth token storage against each MCP server in your LiteLLM deployment.
  • We create machine users for service accounts so each automated caller holds its own upstream credentials, not a shared personal token.
  • We test that one user's stored credentials cannot be read or used by another user, and that virtual key changes do not reassign upstream identity.

How we hand over

  • You receive a written record of which user and server pairs hold credentials, and which machine users map to which service accounts.
  • The runbook covers credential rotation, revocation when someone leaves, and how to add a new MCP server to the model.
  • Your team receives the test results and a walkthrough so reviewers can confirm the controls against your own requirements.

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers, so credential handling can follow LiteLLM release changes.
  • Retesting after new MCP servers or identity changes can be added to the retainer scope or quoted separately.
  • Ask for a quote built from the written scope, which sets out the work, the recurring support items and who performs each task.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.