Deployment guide1-minute readEN · DE · IT

在 Heroku 上部署 AnythingMCP

使用 Heroku Postgres 的容器部署在 Heroku 上部署 AnythingMCP。快速的云部署你的 MCP 网关。

HCBy HelpCode teamUpdated 1 min read Open source on GitHub

No credit card · 7-day trial · Self-host alternative available

  • 7-day free trial
    No credit card required
  • GDPR & SOC 2 ready
    EU data residency, audit logs
  • Open-source on GitHub
    Open source AGPL-3.0
  • Works with ChatGPT, Claude, Gemini
    Any MCP-compatible client

Summary

使用 Heroku Postgres 的容器部署在 Heroku 上部署 AnythingMCP。快速的云部署你的 MCP 网关。

先决条件

创建 Heroku 应用

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

添加 Heroku Postgres

heroku addons:create heroku-postgresql:essential-0

Heroku 会自动设置 DATABASE_URL。通过以下命令验证:

heroku config:get DATABASE_URL

注意: Heroku 具有临时文件系统。所有持久数据必须存储在 Postgres 中。

设置环境变量

生成密钥并配置应用:

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

设置 URL 以匹配你的 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

使用容器堆栈进行部署

将堆栈设置为容器:

heroku stack:set container

在项目根目录创建 heroku.yml

build:
  docker:
    web: Dockerfile

进行部署:

git add heroku.yml
git commit -m "添加 heroku.yml 以进行容器部署"
git push heroku main

监控构建:

heroku logs --tail

自定义域名与 SSL

Heroku 在 *.herokuapp.com 上提供自动 SSL。对于自定义域名:

heroku domains:add mcp.example.com

在你的 DNS 提供商处创建 CNAME 记录:

类型名称
CNAMEmcpyour-app-name.herokuapp.com

更新 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

验证与后续步骤

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

第一个注册的用户将成为管理员。

你的 MCP 端点:https://your-app-name.herokuapp.com/mcp

有用的命令:

heroku logs --tail   # 流式日志
heroku ps            # Dyno 状态
heroku config        # 环境变量
heroku restart       # 重启应用

这份指南对你有帮助吗?

Ready to ship

Ship MCP to your stack in 60 seconds.

Spin up AnythingMCP on managed Cloud or self-host it on your infrastructure. Free for 7 days, no credit card.

相关指南