Skip to main content

Deploying HAPI MCP Server on Fly.io

This guide explains how to deploy the HAPI MCP Server on Fly.io using the official pre-built image (hapimcp/hapi-cli). You do not need to build or customize a Dockerfileβ€”just use the official image for a fast, reliable deployment.

Prerequisites​

Quick Start: Run a HAPI MCP Server Instantly​

For rapid prototyping or testing, you can use fly machine run to launch a HAPI MCP Server instance immediately, bypassing the need for manual app creation or configuration files.

fly machine run hapimcp/hapi-cli:latest --command "hapi serve" \
-e openapi="https://petstore3.swagger.io/api/v3/openapi.json" \
-e url="https://petstore3.swagger.io/api/v3"
  • Replace latest with a specific version tag if needed.
  • The --command "hapi serve" flag tells the container to start the HAPI MCP server.
  • Use -e to set required environment variables.

Possible Combinations

  • Custom Port: Add -p 8080 to expose a specific port.

  • Additional Environment Variables: Add more -e VAR=value flags as needed.

  • Custom Command: Run a different command if you need to override the default entrypoint.

Ephemeral Machines:​

Add --ephemeral to create a machine that is automatically destroyed when stopped.

Recommended: Launch and Deploy for Production

If you plan to run a production MCP server, follow the full deployment steps below to create a persistent app with proper configuration that can be managed and scaled.

Steps​

1. Authenticate with Fly.io​

Log in to your Fly.io account:

fly auth login

If you don't have an account, sign up with:

fly auth signup

2. Create and Configure Your App/MCP Server​

Create a new Fly.io app and generate a configuration file:

fly launch --no-deploy --image hapimcp/hapi-cli:latest \
-e openapi="https://petstore3.swagger.io/api/v3/openapi.json" \
-e url="https://petstore3.swagger.io/api/v3"
  • When prompted, choose a unique app name and region.
  • For the HAPI MCP Server instance, you need to provide at least:
    • the openapi - the URL to your OpenAPI specification (e.g., https://petstore3.swagger.io/api/v3/openapi.json)
    • and url - the 'head' URL of the MCP server (e.g., https://petstore3.swagger.io/api/v3).

This will create a fly.toml file in your directory. If you prefer, you can also manually create the fly.toml file with the necessary configuration. Example is provided at the end of this guide.

3. Edit fly.toml for the Pre-Built Image​

Open the generated fly.toml and ensure it does not reference a build section. You will deploy using the pre-built image, so the build section can be removed or ignored.

4. Deploy the Pre-Built HAPI MCP Image​

Deploy your app using the official image:

fly deploy -- serve
# Or specify the image explicitly:
fly deploy --image hapimcp/hapi-cli:latest
  • Replace latest with a specific version tag if needed.
  • This command will push the pre-built image to Fly.io and start your HAPI MCP Server.

5. (Optional) Set Environment Variables​

If your HAPI MCP Server requires environment variables, set them with:

fly secrets set VAR_NAME=value

Or add them to your fly.toml under the [env] section.

warning

Use secrets for sensitive data like API keys.

6. Monitor and Access Your App/MCP Server​

After deployment, Fly.io will provide a public URL for your app. You can monitor logs with:

fly logs

Notes​

  • No Dockerfile or local build is required.
  • You can redeploy at any time with the same fly deploy --image ... command.
  • For advanced configuration (volumes, scaling, etc.), refer to the Fly.io documentation.

fly.toml example for HAPI MCP Server​

app = 'my-mcp-server'
primary_region = 'dfw'

[build]
image = 'hapimcp/hapi-cli:latest'

[http_service]
internal_port = 8080
force_https = true
auto_stop_machines = 'stop'
auto_start_machines = true
min_machines_running = 0
processes = ['app']

[env]
openapi = 'https://petstore3.swagger.io/api/v3/openapi.json'
url = 'https://petstore3.swagger.io/api/v3'

[[vm]]
memory = '256mb'
cpus = 1
memory_mb = 256