Environment variables
Every env var the Konstera SDK, CLI, or kernel reads. The kernel injects most of these when it spawns an agent container; a few are user-configurable.
KONSTERA_KERNEL_MCP_URLKONSTERA_AGENT_INSTANCE_IDKONSTERA_TENANT_IDKONSTERA_AGENT_IDKONSTERA_AGENT_VERSIONGo to step Agent runtime — user-setoperator; read by the SDKKONSTERA_LOG_LEVELKONSTERA_PORTGo to step CLIyour machine; read by every konstera commandKONSTERA_API_URLKONSTERA_API_TOKENKONSTERA_PROFILEGo to step Platform — self-hosted onlyread by kernel + APIKONSTERA_DOMAINKONSTERA_POSTGRES_CONNECTION_STRINGKONSTERA_TEMPORAL_ADDRESSKONSTERA_OIDC_*KONSTERA_LLM_API_KEYGo to step Agent runtime (injected by the kernel)#
These are set by the kernel's ContainerAgentHost at container-create time.
Agents should not set these themselves — the SDK reads them to construct
the AgentContext. In direct-run mode (local dev), any unset ones fall back
to sentinel values so the agent can still boot.
| Variable | Set by | Unset default (direct-run) |
|---|---|---|
KONSTERA_KERNEL_MCP_URL | Kernel at container create | Direct-run mode — see below |
KONSTERA_AGENT_INSTANCE_ID | Kernel | "unknown-instance" |
KONSTERA_TENANT_ID | Kernel (ADR M8) | "00000000-0000-0000-0000-000000000000" |
KONSTERA_AGENT_ID | Kernel | "unknown-agent" |
KONSTERA_AGENT_VERSION | Kernel | "0.0.0" |
What each injected variable carries#
| Variable | Format | Used by |
|---|---|---|
KONSTERA_KERNEL_MCP_URL | http://konstera-api:8080/mcp/kernel (containerised) or http://host.docker.internal:4500/mcp/kernel (local) | SDK's KernelMcpClient to open the MCP callback session |
KONSTERA_AGENT_INSTANCE_ID | UUID string, e.g. 9f3e1c7a-2b4d-4e8f-9a1b-c3d4e5f6a7b8 | Every service passes it as callerInstanceId on MCP calls so the kernel can scope by instance |
KONSTERA_TENANT_ID | UUID string | Rarely needed directly; the kernel resolves tenant from the instance ID server-side. Available as ctx.tenant_id if your agent needs to tag outputs by tenant |
KONSTERA_AGENT_ID | Agent manifest id, e.g. io.konstera.customer-service-agent | /describe endpoint; log correlation |
KONSTERA_AGENT_VERSION | Semver string from the manifest, e.g. 0.9.2 | /health and /describe endpoints so operators can verify what's deployed |
KONSTERA_KERNEL_MCP_URL unset: direct-run mode#
| Kind of service | Examples | When the URL is unset |
|---|---|---|
| Fire-and-forget | ctx.log.*, ctx.cost.record | Silently no-op |
| Returns data | ctx.state.get, ctx.llm.complete, ctx.capability.call | Raise RuntimeError with an actionable message |
Agent runtime (user-configurable)#
| Variable | Set by | Default | Values | Used by |
|---|---|---|---|---|
KONSTERA_LOG_LEVEL | Operator (via portal → Instance → Environment, or Dockerfile ENV) | INFO | DEBUG, INFO, WARN, ERROR | Python SDK's logging.basicConfig in run() |
KONSTERA_PORT | Operator or kernel (varies by deployment) | 8080 (hardcoded in run() unless port= argument supplied) | — | HTTP server listen address |
CLI (user-configurable)#
| Variable | Set by | Default / format |
|---|---|---|
KONSTERA_API_URL | konstera login (persisted in ~/.konstera/config.yaml) or inline | https://api.konstera.ai (managed cloud) |
KONSTERA_API_TOKEN | konstera login (stored in OS keychain) | Opaque bearer token |
KONSTERA_PROFILE | Operator (optional) | default |
What reads them:
KONSTERA_API_URL— everykonstera *command.KONSTERA_API_TOKEN— everykonstera *HTTP call, asAuthorization: Bearer.KONSTERA_PROFILE— picks which named profile to use when multiple workspaces are configured.konstera config profiles listshows what's available.
Override KONSTERA_API_URL for self-hosted:
KONSTERA_API_URL=https://konstera.your-company.internal konstera invoke my-agent
Platform runtime (kernel + API — self-hosted only)#
These are read by the Konstera platform itself when self-hosting. End users building agents don't touch these.
| Variable | What it's for |
|---|---|
KONSTERA_DOMAIN | Primary domain for the install. Used in generated absolute URLs (OAuth callbacks, portal links). |
KONSTERA_POSTGRES_CONNECTION_STRING | PostgreSQL connection string. Kernel uses konstera_app role (NOBYPASSRLS); cross-tenant admin ops use konstera_admin (BYPASSRLS). |
KONSTERA_TEMPORAL_ADDRESS | Temporal frontend gRPC address, e.g. temporal:7233. Required for the workflow engine (every invocation is a Temporal workflow). |
KONSTERA_OIDC_ISSUER, KONSTERA_OIDC_CLIENT_ID, KONSTERA_OIDC_AUDIENCE | OIDC issuer config (per ADR-004). Required when the platform runs with IAuthProvider=OidcAuthProvider (default). Set to your identity provider (Microsoft Entra, Okta, Auth0, etc.). |
KONSTERA_LLM_API_KEY dev-only | Shared LLM key used in local-dev stacks before tenant-level LLM bindings exist. Not for production. |
Credentials storage#
Tenant secrets (API keys, OAuth tokens, DB credentials) are not stored
in env vars — they live in the kernel's credentials MCP service, encrypted
at rest, per-tenant. Agents fetch them via ctx.credentials.get():
stripe_key = await ctx.credentials.get("stripe-api-key")
- Fetch tenant secrets at run time with
ctx.credentials.get().
- Put tenant secrets (API keys, OAuth tokens, DB credentials) in env vars.
The only secret that lives in an env var is
KONSTERA_API_TOKENon the operator's local machine (OS keychain) for CLI authentication.
Debugging#
To see what the kernel actually injected, call /describe or /health:
curl http://localhost:8080/describe
# {"id": "io.konstera.hello", "version": "0.1.0", ...}
Or print the context in your initialize():
async def initialize(self, ctx: AgentContext) -> None:
print(f"instance_id={ctx.instance_id} tenant_id={ctx.tenant_id}")
print(f"agent={ctx.agent_id}@{ctx.agent_version}")