Distribuire AnythingMCP su Heroku
Distribuisci AnythingMCP su Heroku utilizzando la distribuzione tramite container con Heroku Postgres. Distribuzione cloud rapida per il tuo gateway MCP.
Prerequisiti
- Un account Heroku con un metodo di pagamento verificato
- Heroku CLI installato
- Git e Docker installati localmente
Creare un'app Heroku
git clone https://github.com/HelpCode-ai/anythingmcp.git
cd anythingmcp
heroku create your-app-name
Aggiungere Heroku Postgres
heroku addons:create heroku-postgresql:essential-0
Heroku imposta automaticamente DATABASE_URL. Verifica con:
heroku config:get DATABASE_URL
Nota: Heroku ha un filesystem effimero. Tutti i dati persistenti devono essere memorizzati in Postgres.
Impostare le variabili d'ambiente
Genera i segreti e configura l'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
Imposta gli URL in base al tuo dominio Heroku:
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
Distribuire con Container Stack
Imposta lo stack su container:
heroku stack:set container
Crea heroku.yml nella directory principale del progetto:
build:
docker:
web: Dockerfile
Distribuisci:
git add heroku.yml
git commit -m "add heroku.yml for container deployment"
git push heroku main
Monitora la compilazione:
heroku logs --tail
Dominio personalizzato e SSL
Heroku fornisce SSL automatico su *.herokuapp.com. Per un dominio personalizzato:
heroku domains:add mcp.example.com
Crea un record CNAME presso il tuo provider DNS:
| Tipo | Nome | Valore | |------|------|-------| | CNAME | mcp | your-app-name.herokuapp.com |
Aggiorna gli URL:
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
Verifica e passaggi successivi
curl https://your-app-name.herokuapp.com/health
heroku open
Il primo utente a registrarsi diventa amministratore.
Il tuo endpoint MCP: https://your-app-name.herokuapp.com/mcp
Comandi utili:
heroku logs --tail # Streaming dei log
heroku ps # Stato dei dyno
heroku config # Variabili d'ambiente
heroku restart # Riavvio dell'app