---
title: Deploy the MCP Server
---
You can deploy and operate the MCP server by:
- Using the [MCP server container](#deploying-the-mcp-server-container) or binary, which connects to an existing GraphQL API endpoint
- Using the [Apollo Runtime container](#deploying-mcp-using-the-apollo-runtime-container), which includes both an MCP server as well as the Apollo router
### Deploy the MCP Server container
Apollo MCP Server is available as a standalone docker container. Container images are downloadable using
the image `ghcr.io/apollographql/apollo-mcp-server`.
By default, the container expects all schema and operation files to be present in the `/data` folder within the container
and that clients will use the Streamable HTTP transport on container port 5000.
An example `docker run` command that runs the MCP Server for the space dev example:
```yaml title="Example config for using Docker"
endpoint: https://thespacedevs-production.up.railway.app/
operations:
source: local
paths:
- /data/operations/
schema:
source: local
path: /data/api.graphql
```
```sh showLineNumbers=false
docker run \
-it --rm \
--name apollo-mcp-server \
-p 5000:5000 \
-v <path to the preceding config>:/config.yaml \
-v $PWD/graphql/TheSpaceDevs:/data \
ghcr.io/apollographql/apollo-mcp-server:latest /config.yaml
```
### Deploy the MCP Server using the Apollo Runtime container
The Apollo Runtime container includes all services necessary to serve GraphQL and MCP requests, including the Router and MCP Server. It is the easiest way to operate a GraphQL API with MCP support.
To serve both MCP and GraphQL requests, both port `4000` and `5000` will need to be exposed. An example command which retrieves the schema from Uplink is:
```bash title="Docker" {3, 6}
docker run \
-p 4000:4000 \
-p 5000:5000 \
--env APOLLO_GRAPH_REF="<your-graph-ref>" \
--env APOLLO_KEY="<your-graph-api-key>" \
--env MCP_ENABLE=1 \
--rm \
ghcr.io/apollographql/apollo-runtime:latest
```
To learn more, review the [Apollo Runtime container documentation](/graphos/routing/self-hosted/containerization/docker).
### Using a load balancer
Because [MCP is a stateful protocol](https://modelcontextprotocol.io/docs/learn/architecture#lifecycle-management), you need to configure your load balancer to keep each session on the _same server instance_.
When the MCP client initializes a session with Apollo MCP Server, it receives a session identifier unique to that server instance through the `mcp-session-id` header. You must enable session affinity ("sticky sessions") in your load balancer so that all requests that share the same `mcp-session-id` are routed to the same backend instance.
If the load balancer routes subsequent requests to a different instance, Apollo MCP Server rejects the request because it doesn't recognize the session id.
Many load balancers offered by major cloud vendors don't support header-based session affinity. If yours does not, use software such as Nginx, HAProxy, or Envoy/Istio in front of the Apollo MCP Server instances.