---
title: "Deploy ContextForge MCP Gateway + Postgres"
description: "IBM MCP gateway and registry with Postgres, Redis, auth and SSRF guard on"
category: "AI/ML"
url: https://railway.com/deploy/contextforge-mcp-gateway-postgres
---

# Deploy ContextForge MCP Gateway + Postgres

IBM MCP gateway and registry with Postgres, Redis, auth and SSRF guard on

**[Deploy ContextForge MCP Gateway + Postgres on Railway](https://railway.com/template/contextforge-mcp-gateway-postgres)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/contextforge-mcp-gateway-postgres/manifest.json

- **Creator:** Protemplate
- **Category:** AI/ML
- **Total deploys:** 2

## Template content

### Redis https://devicons.railway.app/i/redis.svg

- **Image:** redis:7.4.2-alpine
- **Start command:** `sh -c 'exec docker-entrypoint.sh redis-server --requirepass "$REDIS_PASSWORD" --bind :: 0.0.0.0 --save "" --appendonly no --maxmemory 256mb --maxmemory-policy allkeys-lru'`

### ContextForge https://raw.githubusercontent.com/IBM/mcp-context-forge/v1.1.0/mcpgateway/static/contextforge-icon.png

- **Image:** ghcr.io/ibm/mcp-context-forge:v1.1.0
- **Health check:** /ready
- **Public domain:** Yes

### Postgres https://devicons.railway.app/i/postgresql.svg

- **Image:** ghcr.io/railwayapp-templates/postgres-ssl:17

## Documentation

# Deploy and Host ContextForge MCP Gateway on Railway

ContextForge is IBM's open-source MCP gateway and registry. It puts MCP servers, REST APIs and A2A agents behind one authenticated endpoint, lets you bundle their tools into virtual MCP servers, and adds an Admin UI, API tokens, teams, RBAC, rate limiting and observability.

## About Hosting ContextForge MCP Gateway

This template runs the official `ghcr.io/ibm/mcp-context-forge:v1.1.0` image with PostgreSQL for durable state and Redis for the cache and session registry shared by the gunicorn workers. The gateway runs its own database migrations on boot, listens on port 4444, and reports ready at `/ready` only when Postgres and Redis both answer. Every credential is generated at deploy time, and ContextForge itself refuses to start if a signing secret is weak or a password is still `changeme`. Self registration is closed, Basic auth is off, and SSRF protection keeps its strict defaults.

## Common Use Cases

- **One MCP endpoint for many servers**: federate remote MCP servers and expose curated virtual servers to Claude, Cursor or any MCP client
- **Wrap REST APIs as MCP tools**: register an HTTP endpoint once and call it as a tool
- **Central auth for agents**: issue scoped, expiring API tokens per team instead of sharing upstream keys
- **Governance**: RBAC, rate limits, audit and metrics in front of every tool call
- **A2A agent registry**: expose agents as tools inside virtual servers

## Dependencies for ContextForge MCP Gateway Hosting

- **PostgreSQL**: included, stores users, tokens, servers, tools and metrics
- **Redis**: included, cache and multi-worker session state
- **No external API keys required to boot**: add upstream MCP servers and LLM providers later from the Admin UI

### Deployment Dependencies

- [ContextForge documentation](https://ibm.github.io/mcp-context-forge/)
- [Container deployment guide](https://github.com/IBM/mcp-context-forge/blob/v1.1.0/docs/docs/deployment/container.md)
- [ContextForge GitHub repository](https://github.com/IBM/mcp-context-forge)

### Implementation Details

First steps after deploy:

1. Copy `PLATFORM_ADMIN_EMAIL` and `PLATFORM_ADMIN_PASSWORD` from the ContextForge service variables.
2. Sign in at `https:///admin`.
3. Create an API token, register an MCP server or REST tool, and group tools into a virtual server.
4. Point your MCP client at `https:///servers//mcp` with `Authorization: Bearer `.

Key variables:

```env
PORT=4444
HOST=[::]
DATABASE_URL=postgresql+psycopg://...@${{Postgres.RAILWAY_PRIVATE_DOMAIN}}:5432/contextforge
CACHE_TYPE=redis
JWT_SECRET_KEY=${{secret(64)}}
AUTH_ENCRYPTION_SECRET=${{secret(64)}}
PLATFORM_ADMIN_PASSWORD=${{secret(32)}}
PUBLIC_REGISTRATION_ENABLED=false
SSRF_ALLOW_PRIVATE_NETWORKS=false
```

SSRF protection blocks private, loopback and cloud metadata addresses. Public MCP servers work immediately. To reach an MCP server inside the same Railway project, add its private range to `SSRF_ALLOWED_NETWORKS` (for example `["fd12::/16"]`) or use its public domain. Do not rotate `AUTH_ENCRYPTION_SECRET` after storing upstream credentials.

## Why Deploy ContextForge MCP Gateway on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying ContextForge MCP Gateway on Railway, you get an authenticated MCP gateway with Postgres, Redis, generated secrets, health checks, managed SSL, and private networking to the rest of your stack.


## Similar templates

- [Chat Chat](https://railway.com/deploy/-WWW5r) — Chat Chat, your own unified chat and search to AI platform.
- [Weaviate](https://railway.com/deploy/weaviate-1) — Vector database with hybrid search and an API key-protected API
- [Möbius v0.1 Personal AI OS](https://railway.com/deploy/mobius-v01-personal-ai-os) — Self-hosted AI agent that builds and runs apps for you, with memory.

Open this page in a browser: https://railway.com/deploy/contextforge-mcp-gateway-postgres
