---
title: "Deploy MCPHub MCP Server Hub + Postgres"
description: "Self-hosted MCP server hub with Postgres, admin and bearer key generated"
category: "AI/ML"
url: https://railway.com/deploy/mcphub-mcp-server-hub-postgres
---

# Deploy MCPHub MCP Server Hub + Postgres

Self-hosted MCP server hub with Postgres, admin and bearer key generated

**[Deploy MCPHub MCP Server Hub + Postgres on Railway](https://railway.com/template/mcphub-mcp-server-hub-postgres)**

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

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

## Template content

### MCPHub https://raw.githubusercontent.com/samanhappy/mcphub/main/docs/favicon.svg

- **Image:** samanhappy/mcphub:1.2.6
- **Start command:** `sh -c 'echo Ly8gRmlyc3QgYm9vdCBzZWVkIGZvciBNQ1BIdWIgb24gUmFpbHdheS4gUnVucyBiZWZvcmUgdGhlIHN0b2NrIGVudHJ5cG9pbnQuCi8vIFdoZW4gbm8gc2V0dGluZ3MgZmlsZSBleGlzdHMgeWV0LCB3cml0ZXMgb25lIHRoYXQgaG9sZHMgYSBzaW5nbGUgc3lzdGVtIGJlYXJlciBrZXkgdGFrZW4KLy8gZnJvbSBNQ1BfQkVBUkVSX0tFWS4gT24gdGhlIGZpcnN0IGRhdGFiYXNlIG1vZGUgYm9vdCBNQ1BIdWIgaW1wb3J0cyB0aGF0IGtleSBpbnRvIFBvc3RncmVzCi8vIGFuZCByZXdyaXRlcyB0aGUgZmlsZSB3aXRoIHRoZSBTSEEtMjU2IGhhc2ggKG1pZ3JhdGlvbi50cyBzY3J1YlNvdXJjZUZpbGVTZWNyZXRzKSwgc28gdGhlCi8vIHBsYWludGV4dCBuZXZlciBzdGF5cyBvbiBkaXNrLiBMYXRlciBib290cyBmaW5kIHRoZSBmaWxlIGFuZCBsZWF2ZSBldmVyeXRoaW5nIGFsb25lLgovLyBUaGUgYmFzZTY0IG9mIHRoaXMgZmlsZSBpcyBlbWJlZGRlZ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Z3MsIG51bGwsIDIpLCB7IG1vZGU6IDBvNjAwIH0pOwogIGNvbnNvbGUubG9nKCdbc2VlZF0gd3JvdGUgZmlyc3QgYm9vdCBzZXR0aW5ncyB3aXRoIG9uZSBiZWFyZXIga2V5IChyYWlsd2F5LWRlZmF1bHQpJyk7Cn0K | base64 -d > /tmp/seed-settings.js && node /tmp/seed-settings.js && unset MCP_BEARER_KEY && exec /usr/local/bin/entrypoint.sh node dist/index.js'`
- **Health check:** /health
- **Public domain:** Yes

### Postgres https://avatars.githubusercontent.com/u/98363230?v=4

- **Image:** pgvector/pgvector:pg17
- **Start command:** `docker-entrypoint.sh postgres -c "listen_addresses=*"`

## Documentation

# Deploy and Host MCPHub MCP Server Hub on Railway

MCPHub is an open source hub for Model Context Protocol servers. You add MCP servers once (npx, uvx, or remote HTTP/SSE servers), organize them into groups, and every AI client connects to a single endpoint: `/mcp` for everything, `/mcp/` for a curated set, or `/mcp/$smart` for vector search over all your tools.

## About Hosting MCPHub

This template runs MCPHub 1.2.6 in database mode with PostgreSQL (pgvector), the upstream recommendation for production. It is locked down from the first second: the admin password, the MCP bearer key, the session secret and the credential encryption key are all generated at deploy time, so there is no default login and no open MCP endpoint. Self registration stays off.

**Plan note:** each stdio MCP server runs as its own child process. A few servers fit the Trial plan; plan on Hobby if you run many.

## Common Use Cases

- **One endpoint for every client**: point Claude, Cursor, Cline or any MCP client at one URL
- **Groups**: expose only the tools a given agent should see at `/mcp/`
- **Smart Routing**: with an OpenAI key, `/mcp/$smart` searches all tools by meaning
- **Keys and users**: scoped bearer keys per client, OAuth for MCP clients that support it

## Dependencies for MCPHub Hosting

- **PostgreSQL with pgvector**: included
- **npm and PyPI access**: used when a stdio server starts for the first time
- **OpenAI API key**: optional, only for Smart Routing

### Deployment Dependencies

- [MCPHub documentation](https://docs.mcphub.app)
- [MCPHub GitHub repository](https://github.com/samanhappy/mcphub)
- [Environment variables reference](https://docs.mcphub.app/configuration/environment-variables)

### Implementation Details

First steps after deploy:

1. Wait until MCPHub and Postgres are green.
2. Open the MCPHub domain and sign in as `admin` with `ADMIN_PASSWORD` from the MCPHub service variables.
3. Add a server under Servers, or install one from the Market, then create a group.
4. Connect a client to `https:///mcp` (or `/mcp/`) with the header `Authorization: Bearer `.
5. Rotate or add scoped keys under Settings, Keys. Change the admin password under the user menu.

Key environment variables:

```env
ADMIN_PASSWORD=${{secret(24)}}            # first boot only, username admin
MCP_BEARER_KEY=${{secret(48)}}            # seeded once as key railway-default
JWT_SECRET=${{secret(64,"abcdef0123456789")}}
MCPHUB_CREDENTIAL_ENCRYPTION_KEY=...      # generated 32 byte base64, never change
DB_URL=${{Postgres.DATABASE_URL}}
INSTALL_BASE_URL=https://${{RAILWAY_PUBLIC_DOMAIN}}
OPENAI_API_KEY=                           # optional, Smart Routing
SMART_ROUTING_ENABLED=                    # optional, set true
```

## Why Deploy MCPHub 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 MCPHub on Railway, you are one step closer to supporting a complete full stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.


## 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 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/mcphub-mcp-server-hub-postgres
