Back to Guides

Deploy AnythingMCP on Heroku

Deploy AnythingMCP on Heroku using container deployment with Heroku Postgres. Quick cloud deployment for your MCP gateway.

Prerequisites

Create a Heroku App

git clone https://github.com/HelpCode-ai/anythingmcp.git
cd anythingmcp
heroku create your-app-name

Add Heroku Postgres

heroku addons:create heroku-postgresql:essential-0

Heroku sets DATABASE_URL automatically. Verify with:

heroku config:get DATABASE_URL

Note: Heroku has an ephemeral filesystem. All persistent data must be stored in Postgres.

Set Environment Variables

Generate secrets and configure the app:

heroku config:set \
  JWT_SECRET=$(openssl rand -hex 32) \
  ENCRYPTION_KEY=$(openssl rand -hex 16) \
  NEXTAUTH_SECRET=$(openssl rand -hex 32) \
  NODE_ENV=production \
  PORT=4000 \
  MCP_AUTH_MODE=oauth2

Set URLs to match your Heroku domain:

heroku config:set \
  CORS_ORIGIN=https://your-app-name.herokuapp.com \
  SERVER_URL=https://your-app-name.herokuapp.com \
  FRONTEND_URL=https://your-app-name.herokuapp.com \
  NEXT_PUBLIC_API_URL=https://your-app-name.herokuapp.com

Deploy with Container Stack

Set the stack to container:

heroku stack:set container

Create heroku.yml in the project root:

build:
  docker:
    web: Dockerfile

Deploy:

git add heroku.yml
git commit -m "add heroku.yml for container deployment"
git push heroku main

Monitor the build:

heroku logs --tail

Custom Domain & SSL

Heroku provides automatic SSL on *.herokuapp.com. For a custom domain:

heroku domains:add mcp.example.com

Create a CNAME record at your DNS provider:

| Type | Name | Value | |------|------|-------| | CNAME | mcp | your-app-name.herokuapp.com |

Update the URLs:

heroku config:set \
  CORS_ORIGIN=https://mcp.example.com \
  SERVER_URL=https://mcp.example.com \
  FRONTEND_URL=https://mcp.example.com \
  NEXT_PUBLIC_API_URL=https://mcp.example.com

Verify & Next Steps

curl https://your-app-name.herokuapp.com/health
heroku open

The first user to register becomes administrator.

Your MCP endpoint: https://your-app-name.herokuapp.com/mcp

Useful commands:

heroku logs --tail   # Stream logs
heroku ps            # Dyno status
heroku config        # Environment variables
heroku restart       # Restart app