Skip to content

Configuration

All configuration is read from environment variables (and a .env file when present). Pydantic validates values at startup; invalid config fails fast with a clear message.

VariableTypeDefaultRequiredNotes
STUB_MODEbooltruenoWhen false, real-mode controller config is required (either legacy env vars or MCP_UNIFI_CONTROLLERS_FILE).

These env vars cover the single-controller case. When set without MCP_UNIFI_CONTROLLERS_FILE, they auto-promote to a one-entry controller list named default. v0.4.x users keep working unchanged.

VariableTypeDefaultRequiredNotes
UNIFI_HOSTstring""real modeGateway IP or hostname (no scheme).
UNIFI_API_KEYstring""real modeLocal API key from Settings → Control Plane → Integrations.
UNIFI_PORTint (1-65535)443noHTTPS port for the gateway.
UNIFI_SITEstringdefaultnoController site identifier. Most setups have one site.
UNIFI_VERIFY_SSLboolfalsenoSet true once the gateway has a real TLS certificate.
VariableTypeDefaultRequiredNotes
MCP_UNIFI_CONTROLLERS_FILEpath(unset)noYAML file listing named controllers. When set, the legacy UNIFI_* vars are ignored. See the Multi-Site Setup guide for the schema.
VariableTypeDefaultRequiredNotes
MCP_UNIFI_MODULES_ENABLEDCSV stringnetworknoModules to load. Known values: network, protect. Unknown values fail startup with UnknownModuleError.
VariableTypeDefaultRequiredNotes
MCP_TRANSPORTenum (stdio, streamable-http)streamable-httpnostdio for Claude Desktop / uvx / .dxt installs; streamable-http for the long-running container.
MCP_HOSTstring0.0.0.0noBind address (Streamable HTTP only).
MCP_PORTint (1-65535)3714noListen port (Streamable HTTP only).
VariableTypeDefaultRequiredNotes
LOG_LEVELenumINFOnoOne of DEBUG, INFO, WARNING, ERROR, CRITICAL.
LOG_FORMATenum (json, text)jsonnojson for production, text for local dev. Logs go to stderr (stdout is reserved for stdio JSON-RPC framing).
VariableTypeDefaultRequiredNotes
MCP_UNIFI_AUDIT_SINKenumfilenoOne of file, stdout, syslog.
MCP_UNIFI_AUDIT_PATHpathaudit.jsonlnoFile path when SINK=file. Relative paths resolve from the process CWD.
MCP_UNIFI_AUDIT_SYSLOG_ADDRESSstring/dev/lognoSocket path or host:port when SINK=syslog.

See the Dry-Run & Audit Log guide for the JSONL record schema and mcp-unifi-replay usage.

These shape the subnet and DHCP range that create_iot_network synthesizes when callers don’t specify them.

VariableTypeDefaultRequiredNotes
IOT_SUBNET_TEMPLATEstring10.0.{vlan_id}.0/24noSubnet template. Must contain the literal {vlan_id} placeholder.
IOT_DHCP_START_OFFSETint (2-254)100noFirst DHCP lease offset within the IoT /24.
IOT_DHCP_STOP_OFFSETint (2-254)200noLast DHCP lease offset. Must be greater than IOT_DHCP_START_OFFSET.
  • Pydantic validates types and ranges at startup.
  • Invalid values fail with a clear message that names the field.
  • Real mode with no controller config (no MCP_UNIFI_CONTROLLERS_FILE, no legacy UNIFI_HOST + UNIFI_API_KEY) is a hard error.
  • Duplicate controller names in the YAML are rejected.
  • IOT_DHCP_STOP_OFFSET <= IOT_DHCP_START_OFFSET is rejected.
  • IOT_SUBNET_TEMPLATE without the {vlan_id} placeholder is rejected.

The server reads .env from the process CWD if present. Values in the actual environment override .env. The repo’s .env.example is a good starting template.

On startup, the server logs a safe_repr() of its resolved config. Per-controller api_key values are never included; each controller gets an api_key_set: true/false boolean instead. Grep startup logs for safe_repr to confirm what the server actually loaded.