Zero-trust MCP servers with LiteLLM signed JWTs

Make MCP servers refuse tool calls that skip the LiteLLM gateway by verifying a short-lived RS256 JWT on every request against LiteLLM's JWKS endpoint.

On this page

Zero-trust MCP servers with LiteLLM JWTs: what it solves

A platform team that registers MCP servers behind LiteLLM often finds that the servers still accept direct calls. Any client that knows the server's URL and credentials can invoke a tool without passing through the gateway, which means the call skips LiteLLM's request logging, key permissions and budget checks. The gateway only governs the traffic that actually reaches it. LiteLLM's mcp_jwt_signer guardrail closes that gap. It signs each outbound MCP tool call with a short-lived RS256 JWT, and the MCP server verifies that token against LiteLLM's public key. A call that did not pass through LiteLLM carries no valid signature, so the server can reject it.

Teams usually need this when a server is shared across several teams, when its tools touch sensitive systems such as ticketing, customer records or deployment pipelines, or when auditors expect every tool invocation to trace back to a gateway log entry. A single-team server on a private network with limited tools may not justify the extra verification code. Before rollout, confirm in LiteLLM's documentation which signing key settings, token lifetime and claims the signer uses in your release, and confirm how the JWKS endpoint is exposed to your MCP servers.

The control has limits. A signed JWT proves that a call came through LiteLLM. It does not prove which end user made the request, it does not inspect tool arguments for injected instructions, and it does not stop a compromised gateway or a caller with valid gateway access from misusing a tool. Network restrictions, key-based permissions and guardrails on tool inputs and outputs remain separate controls that your design must cover. Plan your MCP server's verification code, key rotation and failure behavior (for example, what happens when the JWKS endpoint is unreachable) as part of the build, and test that a direct call with no token is refused.

Request flow from client to LiteLLM to MCP server

The flow starts when an MCP client or agent sends a tool call to the LiteLLM proxy, which passes the request to its mcp_jwt_signer. The signer adds a short-lived RS256 JWT before the call reaches the MCP server, which verifies the token against LiteLLM's JWKS endpoint. A call that skips the gateway arrives without a valid token and is rejected at verification. Check that the MCP server verifies on every route, and that the network between the client and the MCP server allows only the paths shown.

Gateway-signed calls pass verification; direct calls are rejected.

Which verification setup fits each MCP server

This setup fits servers that only the LiteLLM gateway can reach, for example servers on a private subnet with no route from user networks or the internet. The server still needs to verify the signed token, because a network boundary can be misconfigured or bypassed by a compromised workload inside the same segment. The MCP server must fetch the public keys from LiteLLM's JWKS endpoint, select the key by the token's kid header, verify the RS256 signature, and check the expiry and audience claims before it runs any tool. Requests that fail verification should return an authorization error and never reach tool code.

  • Verification logic: Implement RS256 signature checks against the published key set, with exp and audience validation.
  • Key caching: Cache JWKS responses with a refresh path for unknown kid values, so a rotated key does not cause a hard outage.
  • Network controls: Keep the server's listener off public routes and allow only the gateway's egress addresses.
  • Failure behavior: Log rejected calls with the reason, without logging the token itself.
  • Confirm with the vendor: Whether the server exposes a hook for custom token verification, or whether you must add a proxy in front of it.

Before go-live, send a call with no token and a call with a token signed by another key, and confirm both fail.

Setting up JWT signing and verification in order

This sequence turns on LiteLLM's MCP JWT signer, confirms the MCP server can reach the signing keys, and makes the server verify each token before it runs a tool. The result is an MCP server that accepts tool calls from the gateway and rejects calls that arrive directly.

  1. Enable the mcp_jwt_signer guardrail

    The platform team adds the mcp_jwt_signer guardrail to the LiteLLM proxy configuration, then restarts or redeploys the proxy using your normal configuration process. Confirm the exact guardrail configuration keys in the LiteLLM MCP zero trust documentation for your release, because the names are not repeated here. Check that the proxy starts without configuration errors and that the MCP servers you intend to protect are still registered and listed for a test key. The step is complete when the proxy is healthy and a tool call routed through it completes normally.

  2. Confirm the JWKS endpoint is reachable

    The MCP server needs to fetch the public keys that LiteLLM uses to sign tokens, so the network team confirms that the MCP server's network segment can reach the LiteLLM JWKS endpoint. Ask the platform team for the exact JWKS URL in your environment and check it from the MCP server host with a simple HTTP request. Confirm the response is a JSON key set that contains an RSA key with an RS256 algorithm entry. Also decide how the MCP server caches keys and how it behaves if the endpoint is temporarily unavailable, and record that behavior. The step is complete when the MCP server can retrieve the key set from its own runtime environment.

  3. Add RS256 signature verification

    The MCP server developers add middleware or a check at the entry point of each tool call that reads the bearer token, selects the matching key by key ID from the cached JWKS, and verifies the RS256 signature. Reject tokens that use any algorithm other than RS256 so that an attacker cannot downgrade the check. Use a maintained JWT library rather than hand-written parsing, and keep the JWKS URL in configuration instead of code. The step is complete when unit tests show that a correctly signed token passes and a token with a modified payload or an unknown key ID fails.

  4. Check issuer, audience and expiry claims

    Signature verification alone does not confirm that the token was meant for this server or is still current, so the MCP server also checks the issuer (iss), audience (aud) and expiry (exp) claims. The issuer and audience values should match what LiteLLM writes into its tokens for your deployment, so confirm those exact values in the LiteLLM documentation or by decoding a token from a test call. Reject tokens that are expired or outside their validity window, and reject tokens with any other audience. The step is complete when tests show that a token for a different audience or an expired token is refused even though its signature is valid.

  5. Test a direct call that should be rejected

    The security engineer sends a tool call straight to the MCP server, bypassing LiteLLM, using the same tool and arguments that work through the gateway. The request should arrive without a valid gateway-signed token and the server should return an authorization error without running the tool. Check the MCP server logs to confirm the rejection was recorded with a reason that identifies the missing or invalid token. Repeat the test with a token copied from another MCP server or from an expired session if you can obtain one. The step is complete when every bypass attempt is refused and logged.

  6. Test a gateway call that should succeed

    The tester sends the same tool call through the LiteLLM gateway, using a virtual key that is permitted to use that MCP server. LiteLLM should attach its signed token, the MCP server should verify it, and the tool should run and return a normal result. Confirm the call appears in LiteLLM request logs with the expected key, team and server, and that the MCP server log shows a successful verification. If the call fails, compare the token claims with the server's expected issuer and audience before changing any other setting. The step is complete when the gateway call succeeds and both logs agree.

Security and operational risks to plan for

Signed JWTs only protect an MCP server when the signing key, the network path and the verification logic all hold up. The cards below cover the places where a zero-trust setup usually fails in practice, from key handling to logging, so the design review can assign an owner to each one.

Protect the master key

The LITELLM_MASTER_KEY controls administration of the gateway, and it must start with sk-. Store it in a secret manager rather than in configuration files or container images, and limit who can read it. Check which identities can read the secret, whether access is logged, and how the key is replaced if it leaks. Confirm the current key handling guidance in the LiteLLM production docs before you set this up.

Production guide

Close direct network paths

A zero-trust check only works if nothing else can reach the MCP server. Review every route that leads to it, including internal services, debugging ports, load balancer rules and older ingress paths that still accept traffic from clients. Test each path with a call that carries no LiteLLM token and confirm the server rejects it. Network controls and JWT checks should be tested together.

Plan key rotation and JWKS caching

The MCP server fetches LiteLLM's public keys from the JWKS endpoint and usually caches them. Decide how long that cache lives, and confirm that the server refreshes keys when it sees an unknown key ID. Test a rotation in a non-production environment before it happens in production, so a rotation does not cause a sudden outage of every MCP tool. Record who runs each rotation and how it is communicated.

MCP zero trust docs

Handle clock skew and expiry

Short-lived tokens fail when the gateway and the MCP server disagree about the time. Check that both hosts sync time from a trusted source, and set a small, documented tolerance for exp and iat checks. Expect some legitimate calls to fail near expiry under load, and tell the platform team which error to look for. Alerts on a rise in expiry errors help separate clock problems from real attacks.

Log every rejected call

Rejected calls are the evidence that the control is working, and they can also show an attempt to bypass the gateway. Log the MCP server name, the tool name, the reason for rejection, the source address and the time, but do not log the token itself. Send these events to the SIEM or log store your team already runs. Confirm who receives alerts and how quickly they are reviewed.

Keep the MCP server's own authorization

A valid JWT proves that a call came through LiteLLM. It does not prove that the caller may perform a given action on a given record. The MCP server still needs its own checks for user roles, tool permissions and data scope, and those checks should run even for calls that pass verification. Review each tool with the owning team and document which permissions it enforces itself.

Questions buyers ask before adding JWT verification to MCP servers

What drives the cost of adding JWT verification to MCP servers?

The cost depends mainly on how many MCP servers need verification, whether each server's code can verify a JWT without major changes, and how the network is designed. Each server needs a verifier wired to LiteLLM's JWKS endpoint, a check that rejects tokens with the wrong issuer, audience or expiry, and tests showing that a direct call without a valid token fails. Servers you build yourself are usually simpler than vendor servers you cannot modify. Network design matters because the server must be able to reach the JWKS endpoint and must not be reachable around the gateway. Ask any partner for a quote that lists each server, its owner, the verification method and the test plan, and separate one-time setup from ongoing review after LiteLLM upgrades.

How long does MCP JWT verification take to roll out?

The engineering work per server is often less than the time spent on your change process. Typical gating steps include code review, a test environment, security sign-off, a change window for production, and rollback planning. Duration depends on how many servers are in scope, how many teams own them, and whether your change board meets on a fixed schedule. Start with one low-risk server to prove the verifier, the failure behavior and the logging, then repeat for the rest. Ask for a schedule that shows which steps wait on your teams, not only the build steps.

What does our team need to provide for the work?

Your team needs to supply source access or build artifacts for each MCP server, a named owner who can approve changes, and test environments where verification can be turned on without affecting production. You also need access to the LiteLLM deployment so the JWKS endpoint and signing configuration can be checked, and a way to deploy changes to each server. Without source access for vendor servers, verification may not be possible on that server, and the gateway alone will not protect it. Confirm early which servers you can modify and which need a different control.

Can our own engineers implement JWT verification without a partner?

Yes, if your team has engineers who can change the MCP server code, read JWT and JWKS behavior, and write tests for rejected requests. The work is mostly verification logic, configuration and testing, not new platform builds. A partner adds value when many servers are involved, when servers come from several teams, or when you need independent testing that the bypass path is closed. Judge capability by asking your engineers to confirm they can verify a signature, check claims and handle key rotation. If any of those are unfamiliar, plan for training or outside help before the first change window.

Does the signed JWT replace authentication to upstream MCP servers?

No. The signed JWT proves that a tool call passed through LiteLLM, but it does not replace the credentials the upstream server requires for its own resources. A server may still need an OAuth token, an API key or a service account to reach a database or SaaS API. Treat the gateway token as one check in a layered design: the server verifies the gateway signature, then applies its own authorization, then uses its own upstream credentials. Confirm what each server expects from the caller before you remove or change any existing authentication.

What changes when we upgrade LiteLLM?

Upgrades can change signing configuration, key handling or the JWKS endpoint behavior, so every MCP server verifier needs to be retested after each LiteLLM upgrade. LiteLLM maintains support for the four most recent stable minor versions, so plan upgrades within that window and check the release notes for MCP-related changes. Keep the verification tests in your pipeline so a failed signature check shows up before users do. Ask your partner or internal team to document which configuration keys, JWKS URLs and claim checks each server depends on, so the upgrade review has a clear checklist.

What happens if a server is not behind the gateway at all?

Verification only blocks calls that lack a valid LiteLLM-signed token, so a server that is still reachable directly from clients or other networks remains exposed to unsigned requests if it accepts them. Before rollout, check which network paths reach each server, including internal routes, debug ports and legacy endpoints. Pair verification with network restrictions so the server accepts traffic only from the gateway. Then test a direct call from an unauthorized client to confirm it is rejected.

Trade-offs of gateway-only access to MCP servers

Gateway-only access gives you one enforcement point and one audit trail for every MCP tool call, but it makes LiteLLM a dependency for those calls. If the gateway is down, degraded or misconfigured, agents lose access to tools that worked before, and the MCP servers have no direct path to fall back on. Before you enforce the signed JWT check, decide what your availability target for tool calls is and whether the gateway's deployment (replicas, Redis, database) is sized to meet it. Ask your team to document what happens to agent workflows during a gateway outage, and whether any tool must stay reachable through a break-glass route with its own controls.

Each MCP server also takes on new code. Every server must fetch the public key from LiteLLM's JWKS endpoint, cache it, check the RS256 signature, validate the token's expiry and audience, and reject anything that fails. That verification logic is small but it must be written, reviewed and tested in every server language and framework you run, and it must be kept in step when the signing configuration changes. Confirm with the LiteLLM documentation in LiteLLM docs: MCP zero trust exactly which claims the token carries and which values your verifier should check, rather than inferring them from a sample.

Operational effort sits in key and JWKS handling. You need to plan key rotation, confirm how old keys are retired so in-flight tokens do not fail at the wrong moment, and monitor for verification failures that indicate misrouted traffic or a stale key cache. Some tools may justify direct access, such as read-only internal utilities on a private network with no sensitive data, but each exception should be recorded and reviewed. Use the sibling topics on [LiteLLM MCP access control by key, team and organization] and [LiteLLM MCP OAuth: interactive and machine-to-machine flows] to decide who may call each server and how upstream authentication works, because those choices set the boundary this topic enforces.

How DeployOpen scopes and delivers MCP zero-trust work

The sequence turns a set of MCP servers that accept direct calls into servers that accept tool calls only when they carry a valid LiteLLM-signed token, with the scope, evidence and tests agreed before any change is made.

  1. Inventory MCP servers and trust boundaries

    DeployOpen lists every MCP server the gateway fronts or could reach, including its transport, hosting location, owning team and the network paths that currently allow direct calls. The inventory also records which servers handle sensitive data or write actions, since those are usually the first to be locked down. The step is done when your team has reviewed the list and confirmed which servers are in scope and which clients are expected to reach them through LiteLLM.

  2. Agree the fixed written scope

    DeployOpen and your team write down the servers to change, the verification code each server needs, the environments covered, the test cases and the documentation to be delivered. Items such as the identity of the team that owns each server, how keys are stored and who approves changes are recorded in the same document. The step closes when both parties have signed the scope and a quote has been issued from it. Ask for the quote to list each server and environment separately.

  3. Confirm the LiteLLM signing configuration

    The team confirms how the LiteLLM deployment is configured to sign outbound MCP tool calls with the mcp_jwt_signer guardrail, which key material is used, and how the public key is published for verification. DeployOpen checks that the signing key lives in a secret manager and that the gateway version in use supports the feature, referring to the LiteLLM MCP zero trust documentation for the exact settings. The output is a short configuration record that names the issuer, key location and token lifetime settings your team will rely on.

  4. Implement verification on each MCP server

    DeployOpen adds verification to each in-scope MCP server so that it fetches the public key from LiteLLM's JWKS endpoint, checks the RS256 signature, and rejects tokens that are expired or fail the expected claims. Changes are made in your repositories or deployment pipelines, following your review process, and the server's own logic is left unchanged where possible. The step is complete when each server builds, starts and passes its unit tests with the verification path enabled.

  5. Test direct-call rejection and gateway success

    DeployOpen runs two sets of tests against each server in a non-production environment. Direct calls that bypass LiteLLM, including calls with no token, a forged token, and an expired token, must be refused, while tool calls routed through the gateway must succeed. Results are recorded per server with request samples and response codes. The step closes when every case passes, and any failures are fixed and retested before the next step begins.

  6. Roll out and verify in target environments

    Your operations team deploys the changed servers to the agreed environments using your normal release process, and DeployOpen repeats the direct-call and gateway tests there. The team also confirms that key rotation on the LiteLLM side does not break verification, using the rotation steps the team documented in the earlier configuration record. The step is done when the test results for production or the agreed environment match those from the staging run.

  7. Document the controls and hand over

    DeployOpen delivers a written record covering the trust boundaries, the signing and verification design, the test cases with their results, the runbook for key rotation and failed verification, and the list of servers that remain outside the zero-trust boundary. Your team reviews the record and signs off the handover. This record is evidence your own compliance or security reviewers can use, though it is not an audit report or certification.

  8. Continue with retainers for upgrades and testing

    After handover, ongoing work such as LiteLLM upgrades, changes to the MCP server estate and repeated testing can be covered by a retainer. Upgrades are tested against the verification path before they reach production, and continuous testing repeats the direct-call checks on a schedule you agree. Retainer scope, frequency and cost are set in writing, and the quote for any retainer follows from that written scope.

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.