MDK Logo

Environment requirements

The Node.js, npm, Git and network baseline every MDK guide assumes, and why npm stays below 12

Overview

Every guide and tutorial in this repo assumes the same baseline; this page explains the npm ceiling and lists the environment variables MDK packages read. The core SDK README covers Worker admission in depth, and the hosted-site settings table maps each setting a managed site touches to its spec field and boot option.

Requirements

Across hosts (the DHT discovery shape), the backend hosts also need hole-punched UDP to each other, as the hosted-site port table lays out.

Check the installed npm version with npm --version.

Environment variables

Most of these matter when you run MDK processes yourself rather than through mdk run: the services startServices() generates for PM2 or Docker, the agent outside the CLI, or a UI built on the MDK packages.

Service processes

backend/core/mdk/worker.js is the one entry point the generated PM2 and Docker configs run, once per service. startServices() writes these variables into that config; set them yourself only when you start worker.js by hand.

VariableRead byDefaultPurpose
SERVICEworker.jsRequiredThe service this process runs: gateway, worker or dht-bootstrap
MDK_ENVSERVICE=gatewaydevelopmentPassed to the Gateway as --env: it prefers config/<env>.<name>.json over config/<name>.json, and reads the <env> section of a config file that has one
PORTSERVICE=gateway3000Gateway HTTP port
MDK_REPO_ROOTSERVICE=workerRequiredThe MDK source checkout the Worker seeds its config from; /app/repo under Docker
WORKERSERVICE=workerRequiredThe Worker to boot: miner-avalon, container-antspace, container-bitdeer, powermeter-abb, powermeter-satec, powermeter-schneider, sensor-seneca or minerpool-f2pool
TYPESERVICE=workerRequired, except for minerpool-f2poolThe device model, one of that Worker's models
RACKSERVICE=workerRequiredRack name, the last part of the Worker id
MDK_WORKER_ROOTSERVICE=workerdata/<RACK> under the working directoryState root; the Worker's store is <root>/workers/<workerId>/store
MDK_WORKER_ALLOWED_KEYSSERVICE=workerNoneComma-separated hex public keys the Worker admits, on top of the Kernel key in the default trusted-keys directory
MDK_WORKER_ALLOW_ALLSERVICE=workerUnset1 or true admits every peer with no policy check; for throwaway local experiments only
MDK_DHT_BOOTSTRAPSERVICE=gateway, SERVICE=workerThe public HyperDHT bootstrap setComma-separated host:port list of private bootstrap nodes
MDK_DHT_HOSTEvery serviceEvery interface; 127.0.0.1 for SERVICE=dht-bootstrapIP address the process's DHT nodes bind; for dht-bootstrap, also the address it advertises
MDK_DHT_PORTSERVICE=dht-bootstrap49737UDP port of the private bootstrap
MDK_DHT_NODESSERVICE=dht-bootstrap2Persistent DHT nodes started beside the bootstrap

Agent

VariableRead byDefaultPurpose
MDK_AGENT_API_KEYmdk-agentNoneAPI key for a hosted model endpoint. --provider openai reads OPENAI_API_KEY before it; --api-key is the fallback. The default local qvac provider takes no key. See talking to a hosted model
MDK_EVAL_DIRmdk-agent, eval/analyse.mjsThe package's eval/ directoryWhere the eval ledger and run files are written and read
MDK_NODEThe agent's run.sh/usr/bin/nodeNode.js binary run.sh starts the agent with

UI

VariableRead byDefaultPurpose
VITE_MDK_API_URL@tetherto/mdk-ui-foundation, in a Vite buildhttp://localhost:3000Gateway base URL when MdkProvider gets no apiBaseUrl. apiBaseUrl="" keeps every request same-origin and skips it
MDK_API_URL@tetherto/mdk-ui-foundation, under Nodehttp://localhost:3000The same, read after VITE_MDK_API_URL

VITE_API_BASE_URL and API_BASE_URL are still read after both, with a deprecation warning.

Variables in mdk.yaml

A string in spec.workers[].env, spec.gateway.config or spec.apps[].config can name a variable as ${NAME}. The CLI replaces it from its own environment first, then from the project's .env, and leaves the text as written when neither sets it. mdk onboard keeps a plugin's secret answers out of mdk.yaml this way: it writes each to .env as MDK_<PLUGIN>_<KEY>, such as MDK_AUTH_GOOGLE_CLIENTSECRET, and puts the ${...} reference in mdk.yaml.

Set by the CLI

The CLI passes these to its own child processes. You don't set them.

VariableSet for
MDK_DASHBOARD_APPSThe dashboard dev server mdk run dashboard starts: a JSON array of the installed apps whose UIs it loads
MDK_APP_RUNTIME_OPTIONSEach app's runtime process: the app's resolved options, config included, as JSON
MDK_UI_ENTRY, MDK_UI_ID, MDK_UI_IMPORTSThe child process that checks an app's UI module against its contract

Examples and tooling

VariableRead byDefaultPurpose
MDK_UI_PORTexamples/mvp-site UI dev server3040Port of the example's UI dev server
MDK_WORKER_BASEThe mdk-worker skill's worker-smoke.mjsThe Worker's @tetherto/mdk-worker dependency, then a monorepo checkoutmdk-worker package directory the smoke test loads from

Why npm stays below 12

npm 12 disables fetching git-based dependencies by default and fails with EALLOWGIT:

npm error code EALLOWGIT
npm error Fetching packages of type "git" have been disabled

examples/mvp-site takes several third-party Workers as git dependencies, each pinned to a commit in a vendor-controlled repository. Its package.json carries the current set.

On npm 12, npm install fails on the first of these before it reaches anything else. The ceiling lifts only once every one of them resolves from the registry, so it is not a single pending fix.

If npm --version already reports 12 or higher, repin with:

npm install -g npm@11

On this page