Skip to content
Konstera
Docs · Reference
Konstera documentation.

Getting started, SDK quickstart, manifest reference, kernel MCP services, deploy guide and FAQ — everything you need to build and run agents on Konstera.

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.

ArchitectureWho reads which variables — and who sets them Interactive — click a block

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.

VariableSet byUnset default (direct-run)
KONSTERA_KERNEL_MCP_URLKernel at container createDirect-run mode — see below
KONSTERA_AGENT_INSTANCE_IDKernel"unknown-instance"
KONSTERA_TENANT_IDKernel (ADR M8)"00000000-0000-0000-0000-000000000000"
KONSTERA_AGENT_IDKernel"unknown-agent"
KONSTERA_AGENT_VERSIONKernel"0.0.0"

What each injected variable carries#

VariableFormatUsed by
KONSTERA_KERNEL_MCP_URLhttp://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_IDUUID string, e.g. 9f3e1c7a-2b4d-4e8f-9a1b-c3d4e5f6a7b8Every service passes it as callerInstanceId on MCP calls so the kernel can scope by instance
KONSTERA_TENANT_IDUUID stringRarely 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_IDAgent manifest id, e.g. io.konstera.customer-service-agent/describe endpoint; log correlation
KONSTERA_AGENT_VERSIONSemver 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 serviceExamplesWhen the URL is unset
Fire-and-forgetctx.log.*, ctx.cost.recordSilently no-op
Returns datactx.state.get, ctx.llm.complete, ctx.capability.callRaise RuntimeError with an actionable message

Agent runtime (user-configurable)#

VariableSet byDefaultValuesUsed by
KONSTERA_LOG_LEVELOperator (via portal → Instance → Environment, or Dockerfile ENV)INFODEBUG, INFO, WARN, ERRORPython SDK's logging.basicConfig in run()
KONSTERA_PORTOperator or kernel (varies by deployment)8080 (hardcoded in run() unless port= argument supplied)—HTTP server listen address

CLI (user-configurable)#

VariableSet byDefault / format
KONSTERA_API_URLkonstera login (persisted in ~/.konstera/config.yaml) or inlinehttps://api.konstera.ai (managed cloud)
KONSTERA_API_TOKENkonstera login (stored in OS keychain)Opaque bearer token
KONSTERA_PROFILEOperator (optional)default

What reads them:

  • KONSTERA_API_URL — every konstera * command.
  • KONSTERA_API_TOKEN — every konstera * HTTP call, as Authorization: Bearer.
  • KONSTERA_PROFILE — picks which named profile to use when multiple workspaces are configured. konstera config profiles list shows what's available.

Override KONSTERA_API_URL for self-hosted:

Terminal
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.

VariableWhat it's for
KONSTERA_DOMAINPrimary domain for the install. Used in generated absolute URLs (OAuth callbacks, portal links).
KONSTERA_POSTGRES_CONNECTION_STRINGPostgreSQL connection string. Kernel uses konstera_app role (NOBYPASSRLS); cross-tenant admin ops use konstera_admin (BYPASSRLS).
KONSTERA_TEMPORAL_ADDRESSTemporal 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_AUDIENCEOIDC 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-onlyShared 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():

Python
stripe_key = await ctx.credentials.get("stripe-api-key")
Do
  • Fetch tenant secrets at run time with ctx.credentials.get().
Avoid
  • Put tenant secrets (API keys, OAuth tokens, DB credentials) in env vars. The only secret that lives in an env var is KONSTERA_API_TOKEN on the operator's local machine (OS keychain) for CLI authentication.

Debugging#

To see what the kernel actually injected, call /describe or /health:

Terminal
curl http://localhost:8080/describe
# {"id": "io.konstera.hello", "version": "0.1.0", ...}

Or print the context in your initialize():

Python
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}")

See also#