Skip to main content
Every FrontMCP instance has a stable machine ID used for session ownership, HA heartbeats, load balancer affinity, and distributed tracing. The ID is resolved differently based on deployment mode.

Resolution Order

The .frontmcp/machine-id file is only read and written in standalone development (NODE_ENV !== 'production', no MACHINE_ID). It is created on the first getMachineId() call, in the background and without blocking startup, with the directory at mode 0700 and the file at 0600. It is never written in distributed (the ID comes from HOSTNAME / os.hostname()) or serverless mode. In production without an env var, a random UUID is generated on each startup, so session ownership does not survive a restart: set MACHINE_ID or run in distributed mode.

Usage

Distributed Deployment

In Kubernetes, each pod automatically gets its machine ID from the HOSTNAME environment variable, which Kubernetes sets to the pod name (e.g., mcp-server-7b8f9-abc12). This ensures:
  • Session affinity: the __frontmcp_node cookie and X-FrontMCP-Machine-Id header are tied to the actual pod
  • Heartbeat identity: each pod’s heartbeat key (mcp:ha:heartbeat:{nodeId}) maps to its pod name
  • Takeover correctness: session ownership references the real pod, not a random ID

Direct API

The create() factory function accepts a machineId option for stable identity in tests and embedded usage:
This calls setMachineIdOverride() internally before initializing the server.

Environment Variables

For local development with multiple instances, set MACHINE_ID to different values for each process to simulate multi-pod behavior.

High Availability

Multi-pod deployment with session failover

Runtime Modes

Standalone, distributed, and serverless modes

Direct Client

In-process MCP server for testing and embedding