Skip to main content
Feedback

Environment variables

MCP Gateway can be configured via environment variables to control logging, authentication, metrics, configuration paths, and runtime behavior.

In order to change the environment variables from the default add the tag -e with the desired variable and updated value. For example, to change LOG_LEVEL to debug and disable metrics, run the following Docker command:

docker run --rm -e LOG_LEVEL=debug -e ENABLE_METRICS=false --pull always --privileged -v ./:/lunar/packages/mcpx-server/config -p 9000:9000 -p 5173:5173 -p 9001:9001 -p 3000:3000 --name mcpx us-central1-docker.pkg.dev/prj-common-442813/mcpx/mcpx:latest

Below is a list of supported variables, their meaning, expected input, and default values.

LOG_LEVEL

Description: Sets the logging verbosity for MCP Gateway.
Accepted Values: error, warn, info, http, verbose, debug, silly
Default: info

AUTH_KEY

Description: Optional shared secret used for authenticating incoming connections to MCP Gateway. When set, all requests must include the x-lunar-auth-key header matching this value. This will only be effective if auth.enabled is set to true in app.yaml
Accepted Values: Any string
Default: None (authentication is disabled)

MCPX_PORT

Description: Specifies the port MCP Gateway will bind to for incoming HTTP traffic to MCP Gateway.
Accepted Values: Any valid port number (integer)
Default: 9000

WEBSERVER_PORT

Description: Sets the host URL of the AI Gateway MCP Gateway should connect to.
Accepted Values: Any valid URL
Default: http://localhost:9001

ENABLE_METRICS

Description: Controls whether metrics should be exposed (for example, for Prometheus scraping).
Accepted Values: true, false (as strings)
Default: true

SERVE_METRICS_PORT

Description: Defines the port on which MCP Gateway serves its metrics endpoint.
Accepted Values: Any valid port number (integer)
Default: 3000

APP_CONFIG_PATH

Description: Path to the YAML file containing application-level configuration (for example, ACLs, rate limits).
Accepted Values: String path to a .yaml file
Default: config/app.yaml

SERVERS_CONFIG_PATH

Description: Path to the JSON file that defines which MCP servers/tools should be spawned by MCP Gateway.
Accepted Values: String path to a .json file
Default: config/mcp.json

LUNAR_API_KEY

Description: AI Gateway API Key used for interception
Accepted Values: API Key
Default: ""

CORS_ORIGINS

Description: Comma-separated list of allowed origins for CORS requests from the UI. This is essential for remote MCP Gateway deployments and enterprise setups where the UI is served from different domains or IP addresses.
Accepted Values: Comma-separated list of URLs (for example, "https://mycompany.com,https://192.168.1.100:5173,http://localhost:3000")
Default: "http://localhost:5173,http://127.0.0.1:5173" (Vite dev server)

Example for remote deployment:

docker run --rm -e CORS_ORIGINS="https://mycompany.com,https://192.168.1.100:5173" --pull always --privileged -v ./:/lunar/packages/mcpx-server/config -p 9000:9000 -p 5173:5173 -p 9001:9001 -p 3000:3000 --name mcpx us-central1-docker.pkg.dev/prj-common-442813/mcpx/mcpx:latest
On this Page