Skip to content

Keeping secrets out of Git

Hardcoding an API token in .mcp.json or telling contributors to paste secrets into an untracked .env file is an accident waiting to happen. OpenLune keeps credentials out of your manifest, out of generated client configs, out of .openlune/, and out of review output.

Secrets are resolved only in memory at the exact moment a server launches or tools are installed.

Use openlune secret set to save a credential in your operating system’s credential store (macOS Keychain, Linux Secret Service, or Windows Credential Manager):

Terminal window
openlune secret set tracker-token

OpenLune prompts for the value with hidden terminal input—it intentionally refuses values passed as command-line arguments or piped from stdin, so credentials don’t end up in shell history.

Secrets are stored under the io.openlune.secrets service name for your OS user account, independent of any specific checkout or AI client. If you rotate a token, just run openlune secret set <name> again to replace it—you don’t need to re-run openlune apply or reinstall any tools.

To remove a stored credential:

Terminal window
openlune secret delete tracker-token

Wiring secrets into stdio MCP servers (envFrom)

Section titled “Wiring secrets into stdio MCP servers (envFrom)”

Reference stored secrets—or environment variables—using envFrom on a stdio MCP server:

mcp:
tracker:
transport: stdio
command: tracker-mcp
envFrom:
TRACKER_TOKEN: secret:tracker-token

Each entry under envFrom maps a target variable name (what the MCP server expects to see in its environment) to one or more sources:

  • secret:<name> — Read <name> from the OS credential store.
  • env:<VAR> — Read <VAR> from the environment the AI client (or openlune apply, for install.envFrom) was launched from.

You can pass a list of sources instead of a single string. OpenLune tries them in order and uses the first one that exists:

mcp:
tracker:
transport: stdio
command: tracker-mcp
envFrom:
TRACKER_TOKEN:
- secret:tracker-token
- env:TRACKER_TOKEN

This pattern works great for teams: developers using desktop apps (which don’t inherit shell exports) can store the token once in their OS keychain, while developers in CI or terminal sessions can just export TRACKER_TOKEN.

A few rules to keep in mind:

  • No overlap with env. A variable name cannot appear in both env (literal values) and envFrom.
  • Presence checks without leaking values. After openlune apply and during openlune verify, OpenLune checks whether required secret: entries exist in your OS store and tells you the exact openlune secret set command if one is missing—without printing or storing any secret values.
  • No HOME, PATH, or MISE_* overrides on managed servers. For servers using install.tools, those variables belong to OpenLune’s isolated environment and cannot be set via env or envFrom.

Secrets needed during tool installation (install.envFrom)

Section titled “Secrets needed during tool installation (install.envFrom)”

If downloading a managed MCP package requires registry credentials (like an internal npm or PyPI token), put envFrom inside install: rather than on the server itself:

mcp:
internal-tools:
transport: stdio
command: internal-tools-mcp
install:
tools:
- tool: node
version: "24.22.3"
- tool: npm:@acme/internal-tools-mcp
version: "1.4.0"
envFrom:
NPM_TOKEN: [secret:acme-npm-token, env:NPM_TOKEN]

install.envFrom resolves right before declared tools are installed during openlune apply (reading env: sources from the shell running openlune apply) and never leaks into the MCP server’s runtime environment.

Remote http MCP servers connect directly from the AI client rather than going through openlune mcp run, so OpenLune cannot read your OS credential store on the client’s behalf. Instead, headersFrom writes each client’s native environment-variable reference into its config:

mcp:
metrics:
transport: http
url: https://mcp.metrics.example/v1
headers:
X-Team: platform
headersFrom:
Authorization: "Bearer ${env:METRICS_TOKEN}"

Write every variable reference as ${env:NAME} inside headersFrom. Static headers belong in headers, which rejects ${ and $NAME so literal values are never accidentally expanded by a client.

Because clients differ in what they support for HTTP headers, here is how each one renders headersFrom:

Client How headersFrom is rendered
Claude Code, Copilot Replaces ${env:NAME} with ${NAME} in header values
Grok Build Keeps ${env:NAME} in header values
Codex Supports whole-value headers ("${env:NAME}" via env_http_headers) and Authorization: "Bearer ${env:NAME}" (via bearer_token_env_var). Other mixed templates are omitted as a deviation.
Antigravity Cannot read HTTP headers from environment variables yet; headers in headersFrom are omitted as a deviation.