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.Documentation Index
Fetch the complete documentation index at: https://docs.agentfront.dev/llms.txt
Use this file to discover all available pages before exploring further.
Resolution Order
| Priority | Source | When Used |
|---|---|---|
| 1 | MACHINE_ID env var | Always (explicit override, highest priority) |
| 2 | setMachineIdOverride() | Programmatic override (testing, direct API) |
| 3 | HOSTNAME env var | Distributed mode (Kubernetes pod name) |
| 4 | os.hostname() | Distributed mode fallback |
| 5 | Random UUID | Serverless mode (ephemeral, per-invocation) |
| 6 | .frontmcp/machine-id file | Development only (persisted across restarts) |
| 7 | Random UUID | Production fallback |
The
.frontmcp/machine-id file is only created in development (NODE_ENV !== 'production'). In production without an env var, a random UUID is generated on each startup.Usage
Distributed Deployment
In Kubernetes, each pod automatically gets its machine ID from theHOSTNAME environment variable, which Kubernetes sets to the pod name (e.g., mcp-server-7b8f9-abc12). This ensures:
- Session affinity: the
__frontmcp_nodecookie andX-FrontMCP-Machine-Idheader 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
Thecreate() factory function accepts a machineId option for stable identity in tests and embedded usage:
setMachineIdOverride() internally before initializing the server.
Environment Variables
| Variable | Purpose | Default |
|---|---|---|
MACHINE_ID | Explicit machine ID override (highest priority) | --- |
MACHINE_ID_PATH | Custom path for the machine-id file | .frontmcp/machine-id |
FRONTMCP_DEPLOYMENT_MODE | Affects resolution strategy (distributed / serverless / standalone) | standalone |
HOSTNAME | Kubernetes pod name (used in distributed mode) | Set by K8s |
Related
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