This guide covers deploying the MCP Context Server on Kubernetes.
There are two ways to deploy MCP Context Server on Kubernetes:
The Helm chart provides a complete, configurable deployment with:
- Customizable values for different environments
- Pre-configured health checks and probes
- Support for SQLite and PostgreSQL backends
- Optional Ollama sidecar for semantic search
- Ingress configuration
- Service account management
See the Helm Deployment Guide for detailed instructions.
For users who prefer kubectl apply over Helm, you can generate manifests from the Helm chart:
# Generate manifests with default values
helm template mcp ./deploy/helm/mcp-context-server > manifests.yaml
# Apply to cluster
kubectl apply -f manifests.yamlSee deploy/kubernetes/README.md for more details.
helm install mcp ./deploy/helm/mcp-context-serverhelm install mcp ./deploy/helm/mcp-context-server \
-f ./deploy/helm/mcp-context-server/values-postgresql.yaml \
--set storage.postgresql.host=your-postgres-host \
--set storage.postgresql.password=your-passwordhelm install mcp ./deploy/helm/mcp-context-server \
--set search.semantic.enabled=true \
--set ollama.enabled=true+-------------------+ +------------------+ +------------------+
| MCP Client |---->| Ingress/Service |---->| MCP Context |
| (Claude, etc.) | | | | Server Pod |
+-------------------+ +------------------+ +------------------+
|
+------------------+ |
| Ollama Sidecar |<-----------+ (optional)
| (embeddings) |
+------------------+
|
+------------------+ |
| SQLite PVC or |<-----------+
| PostgreSQL |
+------------------+
Minimum:
- CPU: 100m
- Memory: 256Mi
Recommended (with semantic search):
- CPU: 500m-2000m
- Memory: 2Gi-4Gi (Ollama requires significant memory)
SQLite:
- Requires PersistentVolumeClaim
- Single replica only (SQLite doesn't support concurrent writes)
- Good for development and single-user deployments
PostgreSQL:
- External PostgreSQL required (not included in chart)
- Supports multiple replicas
- Recommended for production
MCP Context Server supports horizontal scaling with multiple replicas when configured correctly.
Horizontal scaling requires ALL of the following:
| Requirement | Setting | Why |
|---|---|---|
| HTTP transport | MCP_TRANSPORT=http |
stdio does not support network access |
| Stateless HTTP mode | Enabled by default | Eliminates server-side session state |
| PostgreSQL backend | STORAGE_BACKEND=postgresql |
SQLite is file-based, single-writer |
Why stateless HTTP mode matters:
Stateless HTTP mode is enabled by default in MCP Context Server because it uses no stateful MCP features. Each request creates a fresh transport context, eliminating the need for session affinity (sticky sessions). If needed, you can disable it by setting FASTMCP_STATELESS_HTTP=false. The setting applies to clients on handshake-era protocol versions; clients that negotiate the sessionless 2026-07-28 protocol never create server sessions.
# values-horizontal-scaling.yaml
replicaCount: 3
env:
MCP_TRANSPORT: "http"
# FASTMCP_STATELESS_HTTP defaults to "true" -- no override needed
storage:
backend: postgresql
sqlite:
enabled: false
postgresql:
enabled: true
host: "postgresql-host"
password: "" # Set via --set or existingSecretApply with:
helm install mcp ./deploy/helm/mcp-context-server \
-f ./deploy/helm/mcp-context-server/values-postgresql.yaml \
-f values-horizontal-scaling.yaml \
--set storage.postgresql.host=your-postgres-host \
--set storage.postgresql.password=your-password- SQLite does NOT support horizontal scaling -- it uses a single file on disk with single-writer limitation
- Each replica maintains its own connection pool to PostgreSQL
- Rolling updates work seamlessly since each request is independent
The deployment uses a ConfigMap for non-sensitive configuration:
| Variable | Description |
|---|---|
MCP_TRANSPORT |
Transport mode (http for Kubernetes) |
FASTMCP_HOST |
HTTP bind address |
FASTMCP_PORT |
HTTP port |
FASTMCP_STATELESS_HTTP |
Stateless HTTP mode (enabled by default) |
HTTP_KEEP_ALIVE_TIMEOUT_S |
Seconds an idle kept-alive connection stays open |
LOG_LEVEL |
Logging level |
STORAGE_BACKEND |
sqlite or postgresql |
ENABLE_SUMMARY_GENERATION |
Enable automatic LLM-based summary generation |
SUMMARY_PROVIDER |
Summary provider: ollama, openai, or anthropic |
SUMMARY_MODEL |
Summary model name (default: qwen3:0.6b for Ollama) |
SUMMARY_MAX_TOKENS |
Maximum output tokens for summary generation (default: 4000) |
ENABLE_FTS |
Full-text search |
ENABLE_SEMANTIC_SEARCH |
Semantic search |
ENABLE_HYBRID_SEARCH |
Hybrid search |
PostgreSQL credentials are stored in a Kubernetes Secret:
apiVersion: v1
kind: Secret
metadata:
name: mcp-context-server
type: Opaque
data:
postgresql-password: <base64-encoded-password>Or use an existing secret:
storage:
postgresql:
existingSecret: "my-postgres-secret"
existingSecretKey: "password"The chart creates a ClusterIP service by default. To expose externally:
LoadBalancer:
service:
type: LoadBalancer
port: 8000NodePort:
service:
type: NodePort
port: 8000Enable ingress for external access:
ingress:
enabled: true
className: "nginx"
annotations:
nginx.ingress.kubernetes.io/proxy-body-size: "5m"
nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
nginx.ingress.kubernetes.io/proxy-send-timeout: "3600"
hosts:
- host: mcp.example.com
paths:
- path: /
pathType: Prefix
tls:
- secretName: mcp-tls
hosts:
- mcp.example.comThe annotations raise ingress-nginx's defaults of a 1 MiB request body and 60-second read and send timeouts. The server accepts request bodies up to 4 MiB, and a batch call that generates before it returns, such as one mcp-context-ingest sends to sync a corpus without --defer-generation, can run far longer than a minute, so keep the body limit above 4 MiB and the timeouts at least the client's --call-timeout (see Limits). Other ingress controllers take the same limits under their own annotations.
The chart configures three probes:
Liveness Probe:
- Path:
/health - Restarts container if unhealthy
- Recommended:
failureThreshold: 3,periodSeconds: 10
Readiness Probe:
- Path:
/health - Removes from service if not ready
- Recommended:
failureThreshold: 1,periodSeconds: 5
Startup Probe:
- Path:
/health - Allows slow startup (e.g., model loading, embedding initialization)
- Recommended:
failureThreshold: 30,periodSeconds: 10(5 minutes max startup)
The MCP Context Server uses BSD sysexits.h exit codes:
| Exit Code | Meaning | Kubernetes Behavior |
|---|---|---|
| 0 | Normal shutdown | Pod terminates successfully |
| 1 | General error | CrashLoopBackOff with backoff |
| 69 | Dependency unavailable | CrashLoopBackOff (may recover) |
| 78 | Configuration error | CrashLoopBackOff (requires fix) |
Exit Code 69 (EX_UNAVAILABLE) - transient dependency issues:
- Ollama service not yet running
- Embedding model not pulled
- Database temporarily unreachable
Exit Code 78 (EX_CONFIG) - configuration problems:
- Missing API keys (OPENAI_API_KEY, etc.)
- Missing required packages
- Invalid EMBEDDING_PROVIDER
spec:
containers:
- name: mcp-context-server
livenessProbe:
httpGet:
path: /health
port: 8000
initialDelaySeconds: 30
periodSeconds: 10
failureThreshold: 3
readinessProbe:
httpGet:
path: /health
port: 8000
initialDelaySeconds: 10
periodSeconds: 5
failureThreshold: 1
startupProbe:
httpGet:
path: /health
port: 8000
failureThreshold: 30 # 30 * 10s = 5 minutes max startup
periodSeconds: 10Note: The startup probe allows time for:
- Ollama to start (when using sidecar)
- Embedding model to download (~2-3 minutes for qwen3-embedding:0.6b)
- Database migrations to complete
kubectl port-forward svc/mcp-context-server 8000:8000
curl http://localhost:8000/healthkubectl logs -l app.kubernetes.io/name=mcp-context-server -fUse the /health endpoint to monitor server status. The server does not expose a /metrics endpoint.
# Check pod status
kubectl get pods -l app.kubernetes.io/name=mcp-context-server
# Check pod events
kubectl describe pod <pod-name>
# Check logs
kubectl logs <pod-name># Check ConfigMap
kubectl get configmap mcp-context-server -o yaml
# Check Secret
kubectl get secret mcp-context-server -o yaml
# Test connectivity from pod
kubectl exec -it <pod-name> -- nc -zv postgres-host 5432# Check PVC status
kubectl get pvc
# Check PV
kubectl get pv
# Describe PVC for events
kubectl describe pvc mcp-context-server-data- Helm Deployment Guide - Detailed Helm configuration
- Docker Deployment Guide - Alternative Docker Compose deployment
- Summary Generation Guide - LLM-based summary configuration
- Database Backends - Database configuration
- API Reference - MCP tools documentation