Setting up the LiteLLM MCP gateway

A planning and build guide for running LiteLLM as one governed endpoint in front of your MCP servers, covering transports, naming, REST tool calls and protocol negotiation.

On this page

Why teams set up a LiteLLM MCP gateway and what the setup involves

Teams set up a LiteLLM MCP gateway when Model Context Protocol servers have spread across coding tools, chat clients and internal agents, each holding its own credentials and none of them recorded in one place. Without a gateway, every developer or agent connects straight to each server, so nobody can see which servers are in use, who connects to them, or how the tokens are stored. LiteLLM can sit in front of those servers as one gateway endpoint, so clients register once against a fixed address and the gateway handles the upstream connections.

The setup covers the work that makes that endpoint usable: registering each MCP server in LiteLLM over Streamable HTTP, SSE or stdio, choosing the protocol version clients and servers negotiate, and deciding how tool names from different servers are prefixed so they do not collide. It also covers the REST endpoints for calling tools directly from your own services without going through a model, and a test pass that confirms a client sees the tools it should. Before you start, confirm which transport each MCP server supports and which clients you need to reach, because those answers decide the registration steps.

The setup does not cover the controls that come after the endpoint works. Authenticating to OAuth-protected servers, limiting which keys and teams can see each tool, screening tool inputs and outputs with guardrails, and charging tool calls to teams are each separate topics with their own decisions. Plan those as follow-on work, and confirm with your security team which of them must be in place before any server is opened to users. A written scope that names what is in and out keeps the first phase from stalling on questions it was never meant to answer.

How a client request reaches an MCP server through LiteLLM

The diagram starts with an MCP client in the client network, which connects to one fixed LiteLLM gateway endpoint. The gateway checks the virtual key, looks up the team and server permissions in PostgreSQL, and uses Redis for shared state when more than one proxy instance runs. It then forwards the tool call to the registered MCP server over Streamable HTTP, SSE or stdio. A separate REST path lets applications call a tool without an LLM. Check which side of the trust boundary each upstream server sits on before you register it.

Client requests pass through one gateway endpoint to registered MCP servers.

Choosing Streamable HTTP, SSE or stdio for each MCP server

Streamable HTTP is the transport to choose for remote MCP servers, whether your team hosts them or a vendor exposes them over HTTPS. The gateway opens the outbound connection, so the network boundary sits between the gateway and the upstream server. Clients never connect to the upstream server directly. They connect to the gateway's fixed endpoint, and the gateway holds the upstream connection and its credentials.

  • Registration: add the server with its base URL and transport value in the MCP server configuration or the admin UI. Keep upstream credentials in the gateway and out of client configuration.
  • Egress rules: allow the gateway to reach the upstream host and port. The upstream server sees the gateway's address, so any source-IP allowlist on that server should list the gateway.
  • Authentication: configure upstream headers or OAuth on the gateway side. Confirm which auth modes your release supports for this transport.
  • TLS: require HTTPS to the upstream, validate certificates, and confirm how the gateway trusts any internal certificate authority in your environment.

Before writing the configuration, check the transport value spelling and supported auth options in the LiteLLM MCP documentation for the release you run.

Registration and gateway options and when each fits

This table compares the configuration choices a team makes when registering MCP servers in LiteLLM: transport per server, the fixed gateway endpoint, tool name prefixing, and whether callers use MCP or the REST tool endpoints. Read each row as a decision: the fit describes when the option suits your servers and callers, and the trade-off describes what you take on. Confirm exact behavior against the version you deploy.

OptionBest fitTrade-off
Streamable HTTP transportRemote MCP servers that offer an HTTP endpoint, reachable from the gateway networkGateway needs network reach and upstream credentials; confirm the server supports this transport
SSE transportServers that only expose an SSE endpoint and have no Streamable HTTP optionOlder transport; plan a move to Streamable HTTP if the server adds it, and confirm support in your release
stdio transportLocal MCP servers packaged with the gateway and launched as processesThe gateway runs the process, so it inherits its permissions, secrets and patching; confirm behavior across multiple replicas
Single fixed gateway endpointClients configured once, with upstream servers added or changed behind the gatewayOne place for access control, logging and sizing, so it also needs the most careful hardening and capacity planning
Prefixed tool namesSeveral servers that expose overlapping tool names such as search or createNames are longer, and agent configs or prompts must use the prefixed name; confirm the prefix format
Unprefixed tool namesA single server or a small set of servers with guaranteed unique tool namesName collisions across servers become a risk; confirm how the gateway handles a clash before relying on it
Calls through the MCP protocolMCP-capable clients such as coding tools and chat front ends that discover and invoke toolsClient and gateway must negotiate a compatible protocol version; confirm the versions each side supports
Calls through REST tool endpointsScheduled jobs and backend services that call tools without a model in the loopCaller must supply exact arguments; verify that the same key permissions and logging apply on this path

Setup sequence for the LiteLLM MCP gateway

This sequence takes a self-hosted LiteLLM proxy from a working base to a verified MCP gateway, with each server registered, tools discovered, names prefixed, and a test client and REST call confirmed. Each step closes with a check so your team knows it can move on.

  1. Confirm the LiteLLM proxy and database

    Your platform team deploys or confirms the LiteLLM proxy with PostgreSQL as the database, which the production guide names as the primary supported option. If more than one proxy instance will run, add Redis 7.0 or newer for shared rate limits, router state and cache. Done is confirmed when the proxy starts, reports healthy, and can write to and read from the database without errors in its logs.

  2. Store the master key in a secret manager

    Generate LITELLM_MASTER_KEY, which must start with sk-, and place it in a secret manager your organization already operates rather than in a config file or image. Restrict read access to the service that runs the proxy and to the administrators who manage it. Done is confirmed when the proxy reads the key from the secret store at startup and a test admin request succeeds with it, while the value does not appear in configuration files or container environment listings.

  3. Register each MCP server with its transport

    Add each MCP server to the gateway configuration or admin UI, choosing Streamable HTTP, SSE or stdio for each one based on how the server runs. Record the server name, transport, endpoint or command, and any upstream credentials in your configuration inventory. Done is confirmed when the proxy shows each server as registered with its transport type, and a restart of the proxy keeps all registrations in place.

  4. Confirm tool discovery for each server

    For each registered server, request its tool list through the gateway and compare the result with the tools the server publishes directly. Check that the list is complete, that no tools appear from a different server, and that connection errors are reported clearly when a server is unreachable. Done is confirmed when every server returns the expected tool set, and a deliberately stopped test server produces a visible error rather than an empty list.

  5. Confirm tool name prefixing across servers

    Check that tool names are prefixed with their server identifier so two servers that expose a tool with the same name do not collide. Use a test pair of servers with a deliberately shared tool name to confirm both remain callable under distinct names. Done is confirmed when the gateway lists both tools with different prefixes, and each one routes to the correct upstream server.

  6. Connect one test client to the fixed endpoint

    Point one MCP client at the gateway's fixed endpoint using a virtual key created for testing, not the master key. Confirm the client completes its handshake, lists tools from the expected servers and nothing else, and can run one low-risk read-only tool. Done is confirmed when the client session succeeds, the tool call appears in the proxy request logs under the test key, and the endpoint address needs no change when a server is re-registered.

  7. Call a tool through the REST endpoint

    Invoke the same low-risk tool through the REST endpoint for calling tools without an LLM, using the same test key. Compare the returned result with the result the MCP client received. Done is confirmed when both paths return matching output and both calls are recorded in the logs, which shows the REST path enforces the same key checks as the MCP path.

  8. Verify protocol version negotiation

    Connect clients that request different MCP protocol versions and record which version the gateway agrees to in each session. Confirm that the gateway returns a clear failure for a version it does not support, and that the version it selects is the one your approved clients expect. Confirm the supported versions against the LiteLLM release you run, because versions change between releases. Done is confirmed when each approved client completes negotiation and the outcome for unsupported versions is documented in your runbook.

How tool name prefixing avoids collisions across servers

Two MCP servers can each expose a tool called search or create_issue without any conflict on their own side. The collision only appears when the gateway merges both servers into one tool list for a client or model, because a model choosing a tool by name has no way to tell which server it belongs to. LiteLLM addresses this by prefixing each tool name with the identifier of the server it came from, so that the names a model sees stay unique across everything registered at the gateway. The server prefix is what makes the merged list safe to use, and it is the first thing to check when a tool call lands on the wrong backend.

Before you write any client configuration, confirm the exact prefix format in your LiteLLM version, including the separator character, whether the prefix uses the server name or an alias you set at registration, and whether the prefix is applied to tool lists returned by discovery as well as to tool calls. Pin the server alias early, because changing it later renames every tool that depends on it. Check the current LiteLLM routing docs only for model routing; the MCP registration reference in the LiteLLM documentation is the source to confirm prefix behavior against.

Clients and prompts that name tools must use the prefixed name, not the bare name from the upstream server. Any allowlist, system prompt, agent instruction or guardrail rule that refers to create_issue will miss a tool exposed as the prefixed form, so review those references when you add or rename a server. Test this with two servers that share a tool name in a non-production environment (illustrative: one issue tracker and one ticketing system, each with a search tool), and confirm that each call reaches the intended upstream server and that permission rules apply to the prefixed names.

Security and operational considerations for the gateway endpoint

A single LiteLLM MCP gateway endpoint becomes the place where every client reaches every registered server, so its keys, processes and logs carry more weight than any single tool. The cards below cover the controls to decide before clients connect, and each one names what to check in your own environment.

Protect the master key

The LITELLM_MASTER_KEY grants administrative control over the proxy, including server registration and key issuance. Store it in a secret manager rather than in configuration files, and confirm it starts with sk- as the production guide requires. Check who can read the value from the runtime environment, and rotate it through a planned change window because clients and automation depend on the proxy being reachable with it.

Production guide

Isolate stdio server processes

Servers registered over stdio run as child processes of the gateway, so they inherit its filesystem access, network reach and environment. Run the gateway container with the least privilege it needs, give each stdio server only the credentials it uses, and confirm that the process cannot read the proxy's database or master key. Review which commands can be registered, because a stdio entry is effectively code execution on the gateway host.

Limit who can register servers

Registering or editing an MCP server changes what every permitted key can reach, so this right should sit with a small administrator group, not with every team lead. Decide in advance who may add servers, who approves new upstream URLs and credentials, and who may change transport or authentication settings. Confirm in the admin UI and API that these roles are separated, and record the approver for each registration.

Log every tool call

Tool calls leave the gateway with the caller's identity, the server, the tool name and the arguments, so logs answer who invoked which upstream system and when. Decide what to store, since arguments can contain personal data or secrets, and set retention to match your policy. Route these logs to the system your security team monitors and test that a failed or denied call still produces a record.

Contain the concentration risk

One endpoint now reaches many upstream systems, so a leaked client key or a permissive team rule exposes all of them at once. Group servers by sensitivity, grant each key only the servers and tools its work needs, and avoid a single broad key for automation. Test a key scoped to one team to confirm it cannot list or call tools from another team's servers.

Verify the endpoint before go-live

Before clients connect, run a checklist against the deployed gateway: confirm the master key is not in logs, stdio processes run with the intended user, unauthorized keys receive no tool list, and the audit records appear in the monitoring system. Repeat the checks after each upgrade or server change. Ask your team which of these checks they will own and how often they will run them.

Questions buyers ask before setting up the MCP gateway

What drives the cost of setting up the LiteLLM MCP gateway?

The main drivers are the number of MCP servers to register, the transport each one uses (Streamable HTTP, SSE or stdio), the authentication each upstream server requires, and the number of test clients that must be verified. Each server adds its own registration, its own credentials and its own test cases, so cost grows with the inventory rather than with LiteLLM itself. Servers that need OAuth flows or per-user credentials take longer than servers that accept a single API key. Ask any provider for a written scope that lists each server, its transport, its auth method, and each client that must connect, because a quote is only as firm as that list. Recurring costs are separate: upgrades of the gateway, changes to upstream servers, and ongoing support are usually priced as a retainer.

Can our own team set up the LiteLLM MCP gateway in-house?

A team with working knowledge of LiteLLM, its PostgreSQL database and its configuration can register servers and test them, provided it has time and access to the environment. The harder parts are usually outside LiteLLM: confirming how each upstream server authenticates, agreeing who may call which tool, and testing that clients receive the right tool lists. Teams that have not run an MCP server before tend to underestimate the testing of stdio servers and OAuth flows. A reasonable test is whether the team can name the owner of every server, reproduce a tool call through the gateway, and explain where each credential is stored. If any of those are missing, a partner or an internal pilot on a few servers is a practical way to close the gap.

What does our organization need to provide for the gateway setup?

Plan to provide four things before work starts:

  • A written inventory of MCP servers, with the transport, the upstream URL or command, and the expected callers for each one.
  • Network access from the LiteLLM proxy to each upstream server, and from clients to the gateway, including any internal IP ranges that must be allowed.
  • A location for secrets, such as a secret manager, where upstream credentials and the LITELLM_MASTER_KEY can be stored. LiteLLM recommends keeping the master key, which must start with sk-, in a secret manager.
  • A named owner for each server who can confirm its behavior, approve test calls and make decisions about access.

Without owners, testing stalls at the first question about which tools are allowed.

How long does the gateway setup take?

Duration depends on the scope, so no general figure applies. The main variables are the number of servers, how many use OAuth or per-user credentials, whether stdio servers need packaging into the proxy environment, and how many clients must be tested. The timeline should appear in a written plan with milestones for each server, the test window and the handover. Ask for the assumptions behind the schedule, including what the client must provide and how many rounds of review are included. If an upstream owner is slow to respond, the schedule slips, so confirm the owners and their availability early.

What is the difference between MCP client access and the REST endpoints?

MCP client access is for applications such as coding tools and chat clients that speak the Model Context Protocol. They connect to the fixed gateway endpoint, negotiate a protocol version, list the tools they may see, and decide when to call them, usually through a model. The REST endpoints let a service call a registered tool directly, without an LLM in the loop, which suits scheduled jobs, pipelines and tests. Both paths pass through the same key checks, permissions and logging, but they differ in who decides the call. Engineers should test both paths separately, because a permission that works for a model-driven client may not be the one a service account needs. Confirm the exact endpoint paths and request format against the LiteLLM documentation for your release before writing integration code.

Why do tool names change when several MCP servers are registered?

When several servers expose tools with the same name, LiteLLM avoids collisions by prefixing tool names with the server they come from. Clients therefore see names that identify the server, which helps models choose the right tool and helps administrators read logs. The prefix becomes part of the contract with your callers, so changing a server alias later can break saved prompts, scripts and allowlists. Decide server aliases before registration, record them in the inventory, and test the tool list each client receives. Ask your provider to show the exact prefixed names in the test results.

Which transports and protocol versions should we plan for?

Plan for each server's transport as it is deployed: Streamable HTTP for remote servers, SSE for servers that still use it, and stdio for local processes that must run alongside the proxy. Stdio servers add operational work because the process must be installed, updated and monitored inside the gateway environment. Protocol version negotiation determines whether a client and a server agree on features, so test each client against each server rather than assuming compatibility. Confirm which protocol versions your LiteLLM release supports and which versions each client and server uses before the test plan is final.

How DeployOpen scopes and delivers the MCP gateway setup

DeployOpen plans and builds the LiteLLM MCP gateway inside your own infrastructure, starting from a written scope that names each MCP server, transport and client. We test the registrations and endpoints before handover and leave your team with documentation and a supported path for changes.

How we scope

  • Inventory every MCP server to register, with its transport: Streamable HTTP, SSE or stdio.
  • Confirm which clients will connect to the fixed gateway endpoint and which MCP protocol versions they negotiate.
  • Agree in writing how tool name prefixes will be set across servers, and which REST tool calls non-LLM systems need.

How we build

  • Register each MCP server in LiteLLM and verify that tool discovery and tool calls work for every transport.
  • Configure the gateway endpoint and test protocol version negotiation with each client you run.
  • Check the REST endpoints for calling tools without an LLM, and confirm prefixed tool names resolve correctly.

How we hand over

  • Deliver a registration record listing each server, transport, prefix, owner and the configuration as code used to set it up.
  • Walk your platform and security teams through the endpoint, client connection steps and the known limits of each transport.
  • Document how to add, change or retire an MCP server without breaking clients that already depend on the gateway.

How we support

  • Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.
  • Ongoing support, upgrades and continuous testing are available as a retainer, so new servers and LiteLLM releases can be handled after launch.
  • Ask for the support terms, response expectations and retest approach in your quote before you commit.

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.