---
title: "Deploy MetaMCP"
description: "Self-hosted MCP gateway — aggregate all your MCP servers in one place."
category: "AI/ML"
url: https://railway.com/deploy/metamcp
---

# Deploy MetaMCP

Self-hosted MCP gateway — aggregate all your MCP servers in one place.

**[Deploy MetaMCP on Railway](https://railway.com/template/metamcp)**

- **Creator:** Omry atia's Projects
- **Category:** AI/ML
- **Total deploys:** 8

## Template content

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

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

### Metamcp

- **Image:** ghcr.io/metatool-ai/metamcp:latest
- **Public domain:** Yes

## Documentation

# Deploy and Host MetaMCP on Railway

MetaMCP is a self-hosted MCP aggregator, orchestrator, middleware, and gateway in one Docker container. It manages multiple MCP servers through a single GUI, aggregating tools, prompts, and resources into unified endpoints that any MCP client can connect to — Claude Desktop, Cursor, Windsurf, or anything that speaks MCP.

[![Deploy on Railway](https://railway.com/button.svg)](https://railway.com/deploy/eG1rpS?referralCode=4pD7Sc&amp;utm_medium=integration&amp;utm_source=template&amp;utm_campaign=generic)

## About Hosting MetaMCP

Deploying MetaMCP requires two services: the MetaMCP application container (`ghcr.io/metatool-ai/metamcp:latest`) and a PostgreSQL database for persistent storage. The application runs both the web GUI (Next.js) and the MCP proxy engine (Express) in a single container. Seven environment variables configure the MetaMCP service — three are auto-generated secrets, two reference the public domain, one points to Postgres, and one sets the Node environment. Postgres needs a persistent volume at `/var/lib/postgresql/data`. Once deployed, you register the first account through the web UI (there is no default admin), generate an API key, and point your MCP clients at the Railway URL.

## Common Use Cases

- **Centralizing MCP servers** — one dashboard to manage GitHub, Slack, database, and custom MCP servers instead of per-developer configs scattered across machines.
- **Namespace isolation** — separate namespaces for different projects or environments, each exposing its own endpoint with its own set of MCP servers and tools.
- **Multi-tenant access** — each team member gets their own account, API keys, and namespace assignments with controlled access.
- **Middleware and tool filtering** — intercept MCP requests to filter inactive tools, add annotations, rename tools, or log usage before they reach the underlying server.
- **Enterprise SSO** — lock down access with Google, Azure AD, Okta, or any OIDC provider instead of managing local passwords.
- **Exposing STDIO servers over HTTP** — turn local STDIO-only MCP servers into remote SSE or Streamable HTTP endpoints accessible from cloud-based tools.

## Dependencies for MetaMCP Hosting

- **MetaMCP** (`ghcr.io/metatool-ai/metamcp:latest`) — the application container running the web GUI, API, and MCP proxy engine.
- **PostgreSQL** (`ghcr.io/railwayapp-templates/postgres-ssl`) — stores users, MCP server configs, namespaces, endpoints, and API keys. Requires a persistent volume at `/var/lib/postgresql/data`.

No external dependencies are required. Both services communicate over Railway's private network — no database ports are exposed to the internet unless you explicitly enable the TCP proxy.

### Deployment Dependencies

- [MetaMCP GitHub Repository](https://github.com/metatool-ai/metamcp)
- [MetaMCP Documentation](https://docs.metamcp.com)
- [MCP Server MetaMCP (client proxy)](https://github.com/metatool-ai/mcp-server-metamcp)
- [MetaMCP Cloud (hosted version)](https://metamcp.com)

### Implementation Details

**MetaMCP service variables:**

| Variable | Value | Notes |
|----------|-------|-------|
| `APP_URL` | `https://${{RAILWAY_PUBLIC_DOMAIN}}` | Public URL. CORS enforced on this URL only. |
| `DATABASE_URL` | `postgresql://postgres:${{Postgres.PGPASSWORD}}@${{Postgres.PGHOST}}:${{Postgres.PGPORT}}/railway` | Auto-configured. Do not edit. |
| `BETTER_AUTH_URL` | `https://${{RAILWAY_PUBLIC_DOMAIN}}` | Must match APP_URL. Session cookies and redirects. |
| `BETTER_AUTH_SECRET` | `${{secret(32)}}` | Signs auth tokens. Do not change after first deploy. |
| `ENCRYPTION_KEY` | `${{secret(32)}}` | Encrypts API keys/credentials. Do not change after first deploy. |
| `NODE_ENV` | `production` | Leave as production. |
| `LOG_LEVEL` | `warn` | Options: error, warn, info, debug. |

**Postgres service variables:**

| Variable | Value |
|----------|-------|
| `PGDATA` | `/var/lib/postgresql/data` |
| `PGPORT` | `5432` |
| `POSTGRES_DB` | `railway` |
| `POSTGRES_USER` | `postgres` |
| `POSTGRES_PASSWORD` | `${{ secret(32, "a-zA-Z") }}` |
| `SSL_CERT_DAYS` | `820` |
| `RAILWAY_DEPLOYMENT_DRAINING_SECONDS` | `30` |

Remaining Postgres variables (`PGHOST`, `PGUSER`, `PGDATABASE`, `PGPASSWORD`, `DATABASE_URL`, `DATABASE_PUBLIC_URL`) are auto-references to the values above. Do not edit.

## First-Time Setup

1. **Deploy the template.** Railway auto-generates secrets and provisions Postgres.
2. **Wait for both services to show "Online."**
3. **Visit your app URL** (e.g. `https://metamcp-production-XXXX.up.railway.app`).
4. **Register the first account.** No default admin — the first user you create is your admin.
5. **Go to API Keys** in the sidebar to generate a key for connecting MCP clients.

## Connecting MCP Clients

**Claude Desktop** — add this to your Claude Desktop config:

```json
{
  "mcpServers": {
    "MetaMCP": {
      "command": "npx",
      "args": ["-y", "@metamcp/mcp-server-metamcp@latest"],
      "env": {
        "METAMCP_API_KEY": "",
        "METAMCP_API_BASE_URL": "https://your-railway-url.up.railway.app"
      }
    }
  }
}
```

**Cursor / Streamable HTTP clients** — point directly to your endpoint:
`https://your-railway-url.up.railway.app/metamcp//mcp`

## Adding OIDC / SSO

MetaMCP supports OpenID Connect for enterprise SSO, working alongside default email/password auth. The setup is the same for any provider (Google, Azure AD, Okta, Keycloak, Auth0, Authentik):

1. Create an OAuth/OIDC application in your identity provider.
2. Set the **redirect URI** to `https:///api/auth/callback/oidc`
3. Add these variables to the MetaMCP service:

| Variable | Example (Google) |
|----------|-----------------|
| `OIDC_CLIENT_ID` | Your OAuth client ID |
| `OIDC_CLIENT_SECRET` | Your OAuth client secret |
| `OIDC_DISCOVERY_URL` | `https://accounts.google.com/.well-known/openid-configuration` |
| `OIDC_AUTHORIZATION_URL` | `https://accounts.google.com/o/oauth2/v2/auth` |
| `OIDC_PROVIDER_ID` | `google` |
| `OIDC_SCOPES` | `openid email profile` |
| `OIDC_PKCE` | `true` |

4. Redeploy. A "Login with OIDC" button appears on the login page.
5. Go to **Settings** inside MetaMCP to control whether email/password registration stays enabled alongside SSO.

## Updating MetaMCP

Go to MetaMCP service → Settings → Docker image section. If Railway detects a newer image digest, click **Update** to redeploy. You can also enable **automatic image updates** with a maintenance window in the service settings.

## Troubleshooting

**CORS blocked / blank page:** Browser URL doesn't match `APP_URL`. If using a custom domain, update both `APP_URL` and `BETTER_AUTH_URL` to match.

**Auth errors or can't register:** Check that `BETTER_AUTH_SECRET` and `ENCRYPTION_KEY` are not empty strings. Both must contain actual secret values.

**Database connection errors:** Verify Postgres is online and check MetaMCP deploy logs for connection errors.

**OIDC login fails:** Redirect URI must match exactly: `https:///api/auth/callback/oidc`. Ensure `OIDC_AUTHORIZATION_URL` is set — MetaMCP doesn't fully auto-discover endpoints from the discovery URL alone.

## Why Deploy MetaMCP 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 MetaMCP 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.
- [stella](https://railway.com/deploy/stella) — Self-host stella with web, API, Postgres, Redis, and object storage.
- [Hermes Agent | OpenClaw Alternative with Dashboard](https://railway.com/deploy/hermes-agent-or-openclaw-alternative-wit) — Self-Hosted Hermes AI Agent for Telegram, Discord & Slack

Open this page in a browser: https://railway.com/deploy/metamcp
