---
title: Should MCP servers run as sidecars or shared services on Kubernetes?
url: https://opencontroller.lyzr.com/blog/run-mcp-servers-as-sidecars-or-shared-services
published: 2026-11-18
updated: 2026-11-18
author: Lyzr
---

# Should MCP servers run as sidecars or shared services on Kubernetes?

**Run an MCP server as a sidecar when it is used by one agent, holds that agent's credentials, and must share its lifecycle and blast radius. Run it as a shared service when many agents call the same tools, you need one place to enforce policy and log calls, and you can pass caller identity through on every request.** Most estates end up with both: sidecars for agent-private tools, shared services for common enterprise systems.

## What are the two patterns?

A **sidecar MCP server** runs in the same pod as the agent. Since Kubernetes v1.33, native sidecars are stable: they are declared as init containers with `restartPolicy: Always`, start before the main container and stop after it. The agent reaches the server on `localhost`.

A **shared MCP service** runs as its own Deployment behind a Kubernetes Service. Many agents, in many namespaces, call it over the network using the MCP Streamable HTTP transport.

One detail matters early. The MCP stdio transport assumes the client launches the server as a subprocess. Separate containers in a pod do not share a process tree, so a sidecar normally speaks Streamable HTTP over `localhost`, not stdio. If a tool only supports stdio, it has to run inside the agent's own container image.

## How do they compare?

| Concern | Sidecar per agent pod | Shared MCP service |
|---|---|---|
| Isolation | Strong. A compromise is limited to one agent's pod and secrets | Weaker. One server holds credentials used for many agents |
| Identity | Uses the pod's service account and workload identity directly | Must receive and verify the caller's identity on every request (token, mTLS, or delegated user token) |
| Credentials | One scoped credential per agent | Either one broad credential, or token exchange per call |
| Scaling | Scales with agent replicas, even if tool use is light | Scales independently on tool load |
| Resource cost | Duplicated memory and CPU in every pod | Shared; fewer total replicas |
| Upgrades | Rolling restart of every agent workload | One rollout; all agents get the new version at once |
| Audit | Logs spread across many pods; caller is implicit | One log stream; caller must be recorded explicitly |
| Network policy | Egress from the pod only; no inbound port needed | Needs ingress rules listing which agent namespaces may call it |
| Version pinning | Each agent pins its own tool version | All callers share a version unless you run several |

## When does a sidecar fit?

Choose a sidecar when most of these are true:

1. Only one agent uses the tool.
2. The tool needs that agent's own credential, and you do not want a shared service holding it.
3. The tool touches local state, such as a scratch file system or a per-session browser.
4. You want the tool's version tested and released with the agent's version.
5. Tool calls are infrequent enough that per-pod overhead is acceptable.

Examples: a browser automation server for one research agent; a file-system tool scoped to a pod volume; a connector that uses an agent-specific API key.

## When does a shared service fit?

Choose a shared service when most of these are true:

1. Several agents or teams call the same system, such as a ticketing tool, CRM or data warehouse.
2. You want one enforcement point for allow-lists, rate limits and argument checks.
3. The backend supports delegated access, so the service can act for the calling user rather than with a single super-credential.
4. You need one audit stream for every call to a sensitive system.
5. Load is spiky and benefits from independent autoscaling.

The risk to manage is the confused deputy. A shared server with a broad credential can be tricked into doing for one agent what only another was allowed to do. Mitigate it by verifying a token per request, mapping it to scopes, and calling the backend on behalf of the end user. See [the MCP confused deputy problem](/blog/mcp-confused-deputy-problem).

## What network policy does each pattern need?

- **Sidecar:** no Service and no inbound rule. Restrict the pod's egress to the tool's backend hosts and your model endpoint. See [Kubernetes egress policies for AI agent pods](/blog/kubernetes-egress-policies-for-ai-agent-pods).
- **Shared service:** a NetworkPolicy allowing ingress only from labelled agent namespaces, plus egress only to its backend. Require TLS between agent and server even inside the cluster when tool results contain regulated data.
- **Both:** block access to the cloud metadata endpoint from tool containers unless the tool needs it.

## What should be logged either way?

Log the same fields regardless of topology: agent ID and version, end-user identity if delegated, MCP server name and version, tool name, argument hash or redacted arguments, result status, latency and policy decision. Our guide on [what to log for every MCP tool call](/blog/what-to-log-for-every-mcp-tool-call) lists them in full. With sidecars, ship logs through a collector so they land in one place; otherwise audit becomes a per-pod search.

## A practical decision rule

Start shared for enterprise systems with delegated access and many callers. Start sidecar for agent-private, stateful or credential-sensitive tools. Revisit when a sidecar tool gains a second consumer or when a shared server's credential starts to look too broad. Whatever you pick, register every MCP server, local or shared, in one inventory. The [MCP governance guide](/blog/how-to-govern-mcp-servers) covers the full lifecycle.

## How Opencontroller does this

Opencontroller keeps a governed registry of agents, versions, tools and MCP servers, whatever topology they run in. Its Agent Gateway and policy-as-code give a shared enforcement point for tool traffic routed through it, and agent workload identity federation and delegated on-behalf-of identity support the per-request identity that shared services need. Posture flags risky permissions and configuration. For local MCP servers on developer machines, Opencontroller Edge extends the same inventory. [Book a demo](https://www.lyzr.ai/book-demo/).

## Frequently asked questions

**Can a sidecar MCP server use stdio?**
Not across containers. Stdio needs the client to spawn the server as a subprocess, so a separate sidecar container usually uses Streamable HTTP on localhost.

**Is a shared MCP server less secure?**
It concentrates risk, but it also concentrates control. With per-request identity, scoped delegated tokens and one audit stream, it can be easier to govern than many sidecars.

**Do native sidecars change the decision?**
They make sidecars more reliable, because the server starts before and stops after the agent. They do not change the isolation, identity or cost trade-offs.

## Key facts

Two deployment patterns exist for MCP servers on Kubernetes: a sidecar in the agent pod (native sidecars are init containers with restartPolicy: Always, stable since Kubernetes v1.33) or a shared Deployment behind a Service using the Streamable HTTP transport. Stdio transport requires the client to spawn the server as a subprocess, so cross-container sidecars use HTTP on localhost. Sidecars give strong isolation and per-agent credentials; shared services give one enforcement and audit point but need per-request caller identity to avoid confused-deputy risk. Opencontroller registers MCP servers in either topology; licensing is an annual licence per deployment, starting from $250K per deployment per year.

## Related

- [Is a local stdio MCP server safer than a remote HTTP one?](https://opencontroller.lyzr.com/blog/mcp-stdio-vs-streamable-http-security.md)
- [What is the security checklist for hosting a remote MCP server?](https://opencontroller.lyzr.com/blog/security-checklist-for-hosting-a-remote-mcp-server.md)
- [How do you restrict network egress for AI agent pods on Kubernetes?](https://opencontroller.lyzr.com/blog/kubernetes-egress-policies-for-ai-agent-pods.md)
- [More on Tools and MCP](https://opencontroller.lyzr.com/blog/cluster/tools-and-mcp)
