Deploy the MCP Server

Deployment using Docker containers, when to choose which option, and production considerations


To deploy Apollo MCP Server in your production environment, use the recommended Apollo Runtime Container. You can also use a standalone Apollo MCP Server container if needed.

For most production deployments, use the all-in-one Apollo Runtime Container. It includes everything you need to serve both GraphQL and MCP requests in a single, optimized container.

Why choose the Apollo Runtime Container?

  • Simplified operations: Single container to deploy and manage

  • Optimized performance: Apollo Router and Apollo MCP Server are co-located

  • Built-in best practices: Pre-configured for production use

  • Easier scaling: Scale both GraphQL and MCP together

  • Unified monitoring: Single service to monitor and debug

Deploy the Apollo Runtime Container

The Apollo Runtime Container includes all services necessary to serve GraphQL and MCP requests, including Apollo Router and Apollo MCP Server. Both port 4000 (GraphQL) and 8000 (MCP) are exposed.

Bash
Deploy with GraphOS (Recommended)
1docker run \
2  -p 4000:4000 \
3  -p 8000:8000 \
4  --env APOLLO_GRAPH_REF="<your-graph-ref>" \
5  --env APOLLO_KEY="<your-graph-api-key>" \
6  --env MCP_ENABLE=1 \
7  -v /path/to/config:/config/mcp_config.yaml \
8  --rm \
9  ghcr.io/apollographql/apollo-runtime:latest

When you run this, it will:

  • Fetch your schema from GraphOS using your graph credentials (APOLLO_GRAPH_REF and APOLLO_KEY)

  • Start the Apollo Router with your graph configuration

  • Provides a configuration file for the MCP server by mounting it to config/mcp_config.yaml

  • Enable the Apollo MCP Server endpoint at /mcp

This command uses GraphOS-managed persisted queries for MCP tools. You'll need to publish your operations to the GraphOS-managed persisted queries list. If you want to use other methods for defining MCP tools, see the Define MCP Tools page.

To learn more, see the Apollo Runtime Container documentation.

Standalone Apollo MCP Server container

Use the standalone Apollo MCP Server container if you already have a GraphQL API running elsewhere and want to add MCP capabilities to it.

Deploy standalone Apollo 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 directory within the container and that clients use Streamable HTTP transport on container port 8000.

Here's an example docker run command that runs Apollo MCP Server for an example using TheSpaceDevs graph:

YAML
mcp_config.yaml
1endpoint: https://thespacedevs-production.up.railway.app/
2operations:
3  source: local
4  paths:
5    - /data/operations/
6schema:
7  source: local
8  path: /data/api.graphql
sh
docker run \
  -it --rm \
  --name apollo-mcp-server \
  -p 8000:8000 \
  -v <path/to>/mcp_config.yaml:/config.yaml \
  -v $PWD/graphql/TheSpaceDevs:/data \
  --pull always \
  ghcr.io/apollographql/apollo-mcp-server:latest /config.yaml

When to choose which option?

ScenarioRecommended OptionWhy
New GraphQL + MCP deploymentApollo Runtime ContainerSingle container, easier to manage, optimized performance
GraphOS-managed graphApollo Runtime ContainerAutomatic sync for schema and persisted queries, unified telemetry
Kubernetes/orchestrated environmentApollo Runtime ContainerFewer moving parts, simpler networking
Adding MCP to existing GraphQL APIStandalone Apollo MCP ServerConnect to your existing GraphQL endpoint
Local developmentrover devRun rover dev to develop locally with both GraphQL and MCP

Production Considerations

Load Balancing & Session Affinity

MCP is a stateful protocol that requires session affinity (sticky sessions).

When an 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 in your load balancer so that all requests sharing the same mcp-session-id are routed to the same backend instance.

Most cloud load balancers (ALB, GCP LB) don't support header-based session affinity. Use Nginx, HAProxy, or Envoy/Istio for proper session routing.

Stateless mode

Although MCP is a stateful protocol by default, the Streamable HTTP transport supports operating in a stateless mode. This means that the session ID will not be passed back and forth between the client and server and each request made to the MCP server happens in its own HTTP POST. Disabling the session state being managed in memory by a single host allows for horizontal scaling of the server, though could lead to unknown issues if your MCP client has a dependency on sticky sessions.

You can configure stateless mode in the transport config section:

YAML
1transport:
2  type: streamable_http
3  stateful_mode: false

Scaling Recommendations

For the Apollo Runtime Container:

  • Scale both GraphQL and MCP together as a single unit

  • Simpler horizontal scaling

  • Consistent performance characteristics

For the standalone Apollo MCP Server container:

  • Scale Apollo MCP Server independently of your GraphQL API

  • More complex but enables fine-tuned resource allocation

Next steps

After you deploy, configure:

  1. Health checks for monitoring

  2. CORS settings for browser clients

  3. Authorization for production security

Feedback

Edit on GitHub

Ask Community