Configuration
All application configuration is managed through the central getConfig() function in src/lib/core/config.ts. Environment variables are the default source, but the abstraction supports swapping to database-backed configuration.
Rule: Never read
process.envdirectly in application code. Always usegetConfig().
Environment Variables Reference
Required
| Variable | Description | Default |
|---|---|---|
JWT_SECRET | Secret for JWT signing (min 32 chars) | — |
PROVIDER_ENCRYPTION_SECRET | Key that encrypts provider credentials at rest (min 32 chars, must differ from JWT_SECRET) | — |
Both secrets are checked at startup; see Validation.
Database
| Variable | Description | Default |
|---|---|---|
DB_PROVIDER | Database backend: sqlite, mongodb or postgres (Enterprise: the community build refuses it at start-up, see PostgreSQL) | sqlite |
SQLITE_DATA_DIR | Data directory for SQLite files | ./data |
MONGODB_URI | MongoDB connection string (required when DB_PROVIDER=mongodb) | — |
MAIN_DB_NAME | Main database name | console_main |
MONGODB_MIN_POOL_SIZE | Min connection pool size | 2 |
MONGODB_MAX_POOL_SIZE | Max connection pool size | 10 |
MONGODB_CONNECT_TIMEOUT_MS | Connection timeout | 10000 |
MONGODB_SOCKET_TIMEOUT_MS | Socket timeout | 45000 |
MONGODB_SERVER_SELECTION_TIMEOUT_MS | Server selection timeout | 30000 |
MONGODB_SINGLE_DATABASE | Keep tenant collections in MAIN_DB_NAME instead of a separate tenant_<slug> database per tenant. A second tenant is refused in this mode. | true when DEPLOYMENT_MODE is onprem and DB_PROVIDER=mongodb, otherwise false |
DB_TENANT_SCOPE_MISMATCH | What a switch to another tenant does inside code that already runs in a tenant scope (the scope's tenant keeps serving its queries): warn allows it and logs a rate-limited warning, error refuses the switch. | warn |
TENANT_SCOPE_STRICT | Set to 1 to make a tenant query outside a tenant scope throw instead of logging a warning (recommended for development and CI). | off |
PostgreSQL (Enterprise)
Only with DB_PROVIDER=postgres. One database and one schema hold every workspace; row-level security keeps tenants apart. An invalid value stops start-up. See PostgreSQL.
| Variable | Description | Default |
|---|---|---|
DATABASE_URL | Connection string of the application role: not the owner of the tables and without BYPASSRLS, for example postgresql://app:password@host:5432/cognipeer. | — |
DATABASE_MIGRATION_URL | The role that owns the schema and runs the migrations. Empty uses DATABASE_URL (development only). | (empty) |
PG_APP_ROLE | The role the migrations grant table access to. Empty uses the user of DATABASE_URL. | (empty) |
PG_POOL_MAX | Connections per process. Size it against the server's max_connections and the number of replicas. | 10 |
PG_STATEMENT_TIMEOUT_MS | Limit per statement, and on every wait for a writer lock, in milliseconds (digits only). 0 turns it off. The migrations at start-up always run without it. | 60000 |
PG_SSL | require (verify the certificate and host), no-verify or disable. When set it alone decides TLS: sslmode, ssl and sslrootcert in the URLs are ignored and start-up warns. A private CA with require: NODE_EXTRA_CA_CERTS. | (unset: the URLs decide) |
PG_MAX_LIFETIME_S | Recycle a connection after this many seconds. 0 = never. | 0 |
Set DEPLOYMENT_MODE to onprem for a self-hosted PostgreSQL install: it defaults to saas for MongoDB and PostgreSQL.
Deployment mode
| Variable | Description | Default |
|---|---|---|
DEPLOYMENT_MODE | saas for the hosted multi-tenant service, onprem for an installation you run yourself. | onprem when DB_PROVIDER=sqlite, otherwise saas |
Only the exact values saas and onprem are read; anything else is ignored and the default applies. The default follows the database because SQLite is the self-hosted choice, so an installation that uses MongoDB starts in saas mode unless you set DEPLOYMENT_MODE=onprem. The Docker Compose file in the repository sets it to onprem.
The mode alone decides whether plan limits apply: saas always enforces them and onprem never measures them. PLAN_LIMITS_MODE and PLAN_LIMITS_DEFAULT_ENFORCEMENT are no longer read, and a plan's own enforcement setting is ignored.
What the mode changes:
| Area | saas | onprem |
|---|---|---|
| Endpoints of providers (model, embedding, image, speech, moderation, decision and file providers, the hosts of a GridFS connection string included) | A private, loopback or link-local endpoint is refused. The one exception is a private network the operator has opened for the organization with PROVIDER_PRIVATE_NETWORKS; neither OUTBOUND_HTTP_BLOCK_PRIVATE_NETWORK nor OUTBOUND_HTTP_ALLOWED_HOSTS changes anything here. | Private and loopback endpoints are allowed, unless OUTBOUND_HTTP_BLOCK_PRIVATE_NETWORK is set to true explicitly. The saas rule then applies, with PROVIDER_PRIVATE_NETWORKS to open networks and OUTBOUND_HTTP_ALLOWED_HOSTS to list the hosts that stay allowed. |
| Options of a MongoDB GridFS connection string | Certificate files (tlsCAFile, tlsCertificateKeyFile, tlsCRLFile) are refused, and so are the sign-in methods that use the identity of the server. | Available (the sign-in methods unless private networks are blocked explicitly). |
MONGODB_SINGLE_DATABASE | Defaults to false: one database per tenant. | Defaults to true with MongoDB: one database for the whole installation. |
| Modules for self-hosted installations (for example LDAP) | Not available (404). | Available; they still need the module in the licence package. |
| IAM engine statistics | This tenant's own counters. | Also the process-wide figures of the engine. |
| Plan limits (seats, quotas and rates of the workspace's plan) | Always enforced. | Never measured or enforced. |
| Support entry points | Shown only when the Support hand-off is fully configured (SUPPORT_BASE_URL, SUPPORT_CRM_API_URL and SUPPORT_HANDOFF_SECRET). | Also shown when only SUPPORT_BASE_URL is set; the link then opens the Support login. |
Skip TLS verification and plain http:// endpoints of storage providers (S3-compatible storage, Amazon S3 with a custom endpoint, Azure Blob) do not depend on the mode: both are the provider's own choice on every deployment, and the address rules above still apply to them.
On an installation you run yourself, set DEPLOYMENT_MODE=onprem to use storage on your internal network (a MinIO on a private address, Azurite). On a hosted deployment the operator opens that network for your organization instead, as described under Provider private networks. See Files for the rules per provider.
Changing the mode of an existing MongoDB installation
DEPLOYMENT_MODE=onprem also changes the default of MONGODB_SINGLE_DATABASE to true. An installation that has run in saas mode keeps tenant data in per-tenant databases (tenant_<slug>); after the switch Cognipeer would look for that data in the main database. Set MONGODB_SINGLE_DATABASE=false together with DEPLOYMENT_MODE=onprem to keep the data where it is.
Authentication
| Variable | Description | Default |
|---|---|---|
JWT_EXPIRES_IN | JWT token expiry. A number of seconds (604800) or a duration string (30m, 12h, 7d, 2 weeks). Validated at startup — production refuses to boot on a value it cannot parse. | 7d |
PROVIDER_ENCRYPTION_SECRET | Key that encrypts provider credentials at rest. Required: min 32 chars, must differ from JWT_SECRET. | — |
AUTH_LOGIN_ACCOUNT_MAX_ATTEMPTS | Failed sign-ins one account may have from one client address in 15 minutes. 0 turns the per-account limit off. | 20 |
AUTH_PASSWORD_CHANGE_ENDS_SESSIONS | Changing or resetting a password ends the sessions issued before it. false keeps them valid until they expire; a startup warning is logged. | true |
AUTH_LOGIN_TENANT_SCAN | Legacy: a sign-in for an address the user directory does not know is also looked up in every tenant database, and a found account is added to the directory. A startup warning is logged while it is on. false turns it off. | true |
Production refuses to start unless PROVIDER_ENCRYPTION_SECRET is valid, and in production credentials are never encrypted with JWT_SECRET. Outside production, an unset PROVIDER_ENCRYPTION_SECRET is reported as a configuration error and new credentials are encrypted with JWT_SECRET instead. Decryption also tries JWT_SECRET, so credentials that an earlier version saved under it stay readable and are encrypted under PROVIDER_ENCRYPTION_SECRET the next time they are saved.
Registration
| Variable | Description | Default |
|---|---|---|
REGISTRATION_MODE | open (anyone can sign up), beta (signup requires a beta access code), or disabled (public signup off) | open |
BOOTSTRAP_ORG_NAME | On-prem bootstrap: organization name to create on first boot when no organization exists | — |
BOOTSTRAP_ADMIN_EMAIL | On-prem bootstrap: owner user email | — |
BOOTSTRAP_ADMIN_PASSWORD | On-prem bootstrap: owner user password (must satisfy the password policy) | — |
BOOTSTRAP_ADMIN_NAME | On-prem bootstrap: owner display name | Administrator |
With REGISTRATION_MODE=beta, seed single-use access codes into the main database with npm run seed:beta-codes -- --count 10 (or pass explicit codes; --list shows all codes and their status). The signup form then requires a valid unused code, and each code is consumed on successful registration.
For on-prem deployments, set REGISTRATION_MODE=disabled together with the three BOOTSTRAP_* variables: the server creates exactly one organization owned by the given user on first boot and public signup stays off.
Gateway (Resilience)
| Variable | Description | Default |
|---|---|---|
GATEWAY_REQUEST_TIMEOUT_MS | Request timeout for provider calls | 120000 |
GATEWAY_RETRY_ENABLED | Enable automatic retries | true |
GATEWAY_RETRY_MAX_ATTEMPTS | Maximum retry attempts | 3 |
GATEWAY_RETRY_INITIAL_DELAY_MS | Initial retry delay (exponential) | 200 |
GATEWAY_CIRCUIT_BREAKER_ENABLED | Enable circuit breaker | true |
GATEWAY_CIRCUIT_BREAKER_THRESHOLD | Failures before opening circuit | 5 |
GATEWAY_CIRCUIT_BREAKER_RESET_MS | Time before half-open test | 30000 |
Cache
| Variable | Description | Default |
|---|---|---|
CACHE_PROVIDER | Cache backend: none, memory, redis | memory |
CACHE_TTL_SECONDS | Default cache TTL | 300 |
REDIS_URL | Redis connection URL (required when provider=redis) | — |
REDIS_KEY_PREFIX | Key prefix for Redis cache | console: |
Rate Limiting
| Variable | Description | Default |
|---|---|---|
RATE_LIMIT_PROVIDER | Provider: mongodb, memory, redis. memory and redis require the same CACHE_PROVIDER. | mongodb |
RATE_LIMIT_SYNC_INTERVAL_MS | Sync interval for distributed counters | 5000 |
RATE_LIMIT_MAX_TRACKED_KEYS | Counters the in-process limiter (login and other auth endpoints, public MCP endpoints) keeps at once. When it is full, counters whose window has ended are dropped, then the ones counted least recently. A whole number from 1; any other value (0, a negative or non-numeric one, 1e5, 100,000) uses the default. | 100000 |
CLIENT_API_IP_RATE_LIMIT_PER_MINUTE | Requests one client address may make per minute to /api/client/* and /api/public/*, counted before authentication; over it the API answers 429. IPv6 addresses are counted per /64. The address follows TRUSTED_PROXIES, so set that first behind a proxy. 0 turns it off. | 0 |
QUOTA_POLICY_CACHE_TTL_SECONDS | How long the license and quota policies behind a limit check are cached; editing a policy through the API clears the cache at once. 0 turns the cache off, so every guarded request reads them from the database. | 30 |
Sign-in, registration, password reset and session issuance are limited per client address (request.ip, which follows TRUSTED_PROXIES). A forwarded value that is not an IP address, such as an empty or unusually long one, is limited together with every other such value instead of getting a counter of its own. A trailing port (203.0.113.9:51234, [2001:db8::1]:443) is ignored.
Service Switches
| Variable | Description | Default |
|---|---|---|
CONSOLE_DISABLED_SERVICES | Comma-separated service ids switched off for the whole deployment (e.g. browser,crawler). | (empty) |
CONSOLE_ENABLED_SERVICES | Comma-separated service ids to keep on; every other switchable service is off. | (empty) |
Both empty = every service on. An unknown id refuses to start in production. Service ids, dependencies and what a switched-off service does: Turning services off.
Guardrails
| Variable | Description | Default |
|---|---|---|
GUARDRAIL_DEFAULT_FAIL_MODE | Fail mode of a new guardrail created without one. auto: guardrails that run PII or prompt-shield checks fail closed, all others fail open. open: every new guardrail fails open. Guardrails that already exist keep their own setting. | auto |
See Guardrails.
Egress proxy
On a network that reaches the internet only through a corporate (forward) proxy, set the standard proxy variables on every Cognipeer process:
| Variable | Description | Default |
|---|---|---|
HTTPS_PROXY | Proxy for every outbound request: http://host:port, or http://user:password@host:port with special characters in the password percent-encoded. The managed browser and the crawler use it for http:// and https:// sites alike. | (unset: direct) |
HTTP_PROXY | Used when HTTPS_PROXY is not set. | (unset) |
NO_PROXY | Comma-separated hosts reached directly, without the proxy: localhost, 127.0.0.1, the cluster's services, internal hosts. | (unset) |
The managed browser and the crawler's Playwright engine launch Chromium with the proxy and with NO_PROXY as its bypass list. fetch() (model providers, webhooks and the other plain HTTP calls) goes through undici's environment proxy agent, installed at startup. The crawler's axios engine and local MCP servers (stdio) read the variables themselves.
- Spelling. Use
HTTPS_PROXYorhttps_proxy(likewise for the other two). A variable spelled any other way, such asHTTPS_Proxy, is adopted at startup with a warning in the log, but tools outside Cognipeer do not read it. http://for most proxies. The scheme says how Cognipeer talks to the proxy, not to the sites behind it: HTTPS sites are tunnelled through anhttp://proxy withCONNECT. Usehttps://only for a proxy that itself speaks TLS; otherwise every connection to it fails.NO_PROXYis read differently by different clients. For the browser and the crawler a plain entry (corp.example) covers the domain and its subdomains,.corp.exampleits subdomains only, and CIDR ranges (10.0.0.0/8) match addresses. Node'sfetch()reads a plain entry as that exact host and ignores CIDR ranges, so write internal domains in the leading-dot form (.svc.cluster.local).- TLS inspection. A proxy that re-signs certificates with a corporate CA needs
NODE_EXTRA_CA_CERTSfor Node andBROWSER_IGNORE_CERTIFICATE_ERRORSfor the browser, which cannot read it.
To check the whole path, run this inside the Cognipeer container with the sites the browser cannot reach:
npm run diagnose:egress-proxy -- https://www.example.com https://other.example.comIt prints the proxy configuration it found, whether each URL goes through the proxy, what the server's DNS answers, what the proxy answers when asked for the host (403: its policy does not allow the host; 407: it wants credentials), and the outcome of a real browser navigation with every request that failed. When a navigation times out, the error names the hosts the page was still waiting on: behind an allow-listing proxy those are usually third-party hosts (CDNs, fonts, analytics) the firewall does not let through.
Browser Runtime
| Variable | Description | Default |
|---|---|---|
BROWSER_BLOCK_PRIVATE_NETWORK | Blocks localhost, link-local, private, and reserved network egress from managed browser sessions. | true |
BROWSER_IGNORE_CERTIFICATE_ERRORS | Ignores certificate errors in the managed browser and the crawler's Playwright engine, for a TLS-inspecting proxy whose CA Chromium cannot trust. Turns certificate checks off for every page. | false |
BROWSER_CHROMIUM_EXTRA_ARGS | Extra Chromium flags, comma-separated, appended to every launch. | (empty) |
BROWSER_DEFAULT_MAX_CONCURRENT | Default number of concurrent browser sessions per tenant. | 10 |
BROWSER_DEFAULT_ARTIFACT_BUCKET | Default artifact bucket key. | browser-artifacts |
BROWSER_ACTION_CONCURRENCY | Browser actions executed at once per node. | 4 |
BROWSER_VIEWPORT_HEIGHT | Default viewport height of a managed browser session, in pixels. | 800 |
See Browser for how a session uses them.
Outbound HTTP (SSRF Guard)
Services that fetch tenant-supplied URLs (tools, MCP servers, custom reranker endpoints, connected external agents, inference-monitoring pollers) route through a shared guard that blocks requests resolving to loopback, private, link-local, CGNAT, or cloud-metadata address space, and re-validates every redirect hop.
| Variable | Description | Default |
|---|---|---|
OUTBOUND_HTTP_BLOCK_PRIVATE_NETWORK | Block outbound requests to private/loopback address space from tenant-configured integrations. | true |
OUTBOUND_HTTP_ALLOWED_HOSTS | Comma-separated hostnames exempt from the block. Use a leading dot to match subdomains (e.g. .svc.cluster.local). | (empty) |
OUTBOUND_HTTP_DEFAULT_TIMEOUT_MS | Default timeout for guarded outbound requests. | 30000 |
PROVIDER_PRIVATE_NETWORKS | Private ranges that provider endpoints may reach, per organization. Entries are separated by ;; each is <tenantId>=<cidr>[,<cidr>...], and * in place of a tenant ID opens the ranges for every organization. IPv4 and IPv6 CIDRs are accepted (a bare address means one host); host names are not. Whitespace is ignored and two entries for one organization merge. An entry or range that cannot be read opens nothing and is logged as an error at startup. Example: "64f0c0ffee1234567890abcd=10.50.0.0/16,fd12:3456::/48;*=100.64.10.0/24". See Provider private networks. | (empty: nothing is opened) |
PROVIDER_PRIVATE_NETWORKS_DENY | Comma-separated CIDRs that stay refused even inside an opened range. Set it to the cluster's pod and service ranges and to any other internal range. An entry that cannot be read closes every opened network until it is fixed. | (empty) |
PROVIDER_RUNTIME_GUARD | warn or enforce. What happens when a provider call made at request time (model, embedding, image, speech, moderation, OCR and web search) targets an address the provider rules refuse. warn keeps the path the call took before the setting existed and logs a warning (once per host every 10 minutes); enforce refuses the call. Endpoints are always checked when a provider is saved. | warn |
CRAWLER_ALLOW_PRIVATE_NETWORK_OPT_IN | Whether a crawler's allowPrivateNetwork setting takes effect. When off, the setting is ignored and the crawler follows the private-network block. Turning it on for a saas deployment logs a startup warning. | true for onprem, false for saas |
CRAWLER_RESOLVED_PRIVATE_POLICY | What the crawler does with a host name that resolves to a private address (and with internal-only names such as .svc or .cluster.local): refuse blocks the request, warn allows it and logs a warning per host at most every 10 minutes. | warn for onprem, refuse for saas |
Self-hosted deployments that legitimately call in-network services (e.g. a vLLM server on a private IP) should list those hosts in OUTBOUND_HTTP_ALLOWED_HOSTS rather than disabling the guard globally.
Endpoints that a person types into a provider (model, embedding, image, speech, moderation, decision and file providers) follow the deployment mode instead of that global default. In saas mode the block is always on and the allow-list does not apply; networks opened with PROVIDER_PRIVATE_NETWORKS are the exception. In onprem mode private addresses are allowed unless OUTBOUND_HTTP_BLOCK_PRIVATE_NETWORK is set to true explicitly; only then do OUTBOUND_HTTP_ALLOWED_HOSTS entries matter for providers. For file providers the check runs when the provider is saved or tested and each time its storage client is built, and the client's connections are checked when they are opened. See Providers and Files.
Provider private networks
Provider endpoints (model, embedding, image, speech, moderation, decision and file providers) are checked by a guard of their own. On SaaS it always refuses private, loopback and link-local addresses; on a self-hosted installation it does so only when OUTBOUND_HTTP_BLOCK_PRIVATE_NETWORK is explicitly true. A customer's own store or model server often sits on a private address of the customer's network, which the operator has connected to the deployment with a VPN or a peering. PROVIDER_PRIVATE_NETWORKS opens those networks for chosen organizations, and PROVIDER_PRIVATE_NETWORKS_DENY keeps ranges closed inside them:
PROVIDER_PRIVATE_NETWORKS="64f0c0ffee1234567890abcd=10.50.0.0/16,fd12:3456::/48;*=100.64.10.0/24"
PROVIDER_PRIVATE_NETWORKS_DENY="10.244.0.0/16,10.96.0.0/12"- A private address is allowed for an organization only when it lies inside one of its ranges (or a
*range) and is not one of the addresses that are never opened. A name is resolved and every address it answers with has to pass. Public addresses are decided as before. For a file provider the rule applies again each time its storage client is built and a connection is opened. - An entry or a range that cannot be read opens nothing and is logged as an error at startup; the readable ranges of the same entry still apply. A deny list with an entry that cannot be read opens nothing for anyone until it is fixed, because what it was meant to keep out is unknown.
- Both settings are read once, when Cognipeer starts, on every Cognipeer process (a
workernode included, see Cluster): restart every replica after changing them. The startup log has one line with the counts (organizations with ranges of their own, opened ranges, ranges opened for every organization, deny ranges), an error line that lists the entries that cannot be read, and a warning for an opened range that overlaps an address that is never opened. - They apply wherever the provider guard blocks private targets: always on SaaS and, on a self-hosted installation, only with
OUTBOUND_HTTP_BLOCK_PRIVATE_NETWORK=true(hosts inOUTBOUND_HTTP_ALLOWED_HOSTSkeep passing there). Webhooks, tools, MCP servers, alert channels, browser sessions, the crawler, OCR webhooks and imports are not covered: they follow theOUTBOUND_HTTP_*settings above. - Never opened, whatever the entries say: loopback, link-local (which holds the cloud metadata services), multicast and reserved addresses, the IPv6 forms that carry an IPv4 address, Cognipeer's own addresses and the ranges in
PROVIDER_PRIVATE_NETWORKS_DENY. The nameslocalhostand*.localhoststay refused as well.
Private networks on SaaS describes the procedure, the complete list of addresses that are never opened, how to find a tenant ID, and how mongodb+srv:// connection strings are checked.
Networking (Reverse Proxy Trust)
Fastify's request.ip — the value the auth rate limiter, quota keys and the audit log all key on — is resolved through this trust boundary. It decides which immediate peer is allowed to set X-Forwarded-For and have it believed; a request from anywhere else always resolves to the raw socket address, never a header.
| Variable | Description | Default |
|---|---|---|
TRUSTED_PROXIES | Comma-separated list of the IP addresses or CIDR ranges of your reverse proxies or load balancers (for example 10.0.0.0/8,192.168.1.5). Only a request that comes from one of them has its X-Forwarded-For believed. | (empty: every hop is trusted) |
IAM_VALIDATE_REQUESTS | Set to 1 to validate every authorization request against the engine's schema (diagnostics; adds about 0.1 ms per decision). | off |
There is no switch for the authorization engine itself: it decides every request. See IAM.
TRUSTED_PROXIES takes addresses and ranges, not a hop count. A single whole number (1, 2) is not a number of hops: the list then trusts no proxy at all, X-Forwarded-For is ignored and every request resolves to the address of the connection that reached Cognipeer, which behind a proxy is the proxy itself.
The empty default trusts every hop (X-Forwarded-For is believed unconditionally) — this preserves behavior for existing deployments, but means any caller who can reach the process directly can forge their own client IP. With NODE_ENV=production and the variable unset, Cognipeer logs a startup warning saying so. Set TRUSTED_PROXIES to your actual proxy's address as soon as you put one in front of Cognipeer; on-prem installs behind nginx/an ingress controller should set this explicitly rather than rely on the default. If your proxy sets only X-Real-IP (not X-Forwarded-For), configure it to also set X-Forwarded-For — this app no longer reads X-Real-IP directly.
Token IP allowlists and the ip condition of access policies are stricter than the rest. With TRUSTED_PROXIES set they use the address resolved through the listed proxies. With it unset they use the direct connection address and ignore forwarded headers altogether, so a caller cannot claim an allowed address; behind a proxy every caller then looks like the proxy and an allowlist never matches until the proxy is listed. See Authentication.
MCP Gateway Limits
Limits on the MCP gateway: what a failed tool call and a server's request log keep, the pool of stdio subprocesses, the SSE transport, and the public (unauthenticated) endpoints. Secret values the server holds (its upstream credential, stdio environment values, runtime headers) are masked as [REDACTED] in the error text before it is cut to length or stored.
| Variable | Description | Default |
|---|---|---|
MCP_ERROR_MESSAGE_MAX_CHARS | Longest error message a failed tool call hands back to its caller (minimum 256). | 8192 |
MCP_LAST_ERROR_MAX_CHARS | Longest lastError message stored on an MCP server record (minimum 64). | 2048 |
MCP_LAST_ERROR_THROTTLE_MS | An identical lastError is not written again within this window. 0 writes every time. | 60000 |
MCP_LOG_TOOL_NAME_MAX_CHARS | Longest tool name stored in an MCP request-log row (minimum 16). | 200 |
MCP_LOG_USER_AGENT_MAX_CHARS | Longest caller user-agent stored with an MCP request-log row (minimum 16). | 300 |
MCP_UPSTREAM_TIMEOUT_MS | Longest a call to the upstream of an OpenAPI or remote MCP server may take, headers and body together (minimum 1000). | 90000 |
MCP_UPSTREAM_MAX_RESPONSE_BYTES | Largest response body read from that upstream; a bigger one fails the call (minimum 65536). | 8388608 |
MCP_ALLOWED_ORIGINS | Comma-separated browser origins that may call the MCP endpoints besides the app's own (APP_URL): exact origins or *.example.com wildcards. A request whose Origin header is not allowed gets 403; a request without one (server-side MCP clients) is not affected. | (empty) |
MCP_SERVER_INFO_NAME | serverInfo.name the gateway answers initialize with. | cognipeer-mcp-gateway |
MCP_INVOKE_CONCURRENCY | Concurrent MCP tool invocations per node when calls are routed through the job queue. | 4 |
MCP_STDIO_ENABLED | Allow stdio (npx/uvx) MCP servers to run as subprocesses of the gateway. Set false, 0, no or off to disable. | true |
MCP_STDIO_MAX_CONCURRENT | Stdio (npx/uvx) MCP subprocesses running at once, all tenants together. | 8 |
MCP_STDIO_MAX_CONCURRENT_PER_TENANT | One tenant's share of them; a call over it is refused with an error saying so. 0 leaves only the process-wide limit, which suits an installation with a single tenant. | half of MCP_STDIO_MAX_CONCURRENT, at least 1 |
SSE streams
The legacy SSE transport keeps one open stream per client (GET …/sse), fed by POST …/message?sessionId=…. A session belongs to the caller that opened it: a message naming a session that does not exist, or that another token (or the public endpoint) opened, is answered 404. A stream over a limit is answered 429 or 503 with a Retry-After header and a JSON body. 0 turns a limit off.
| Variable | Description | Default |
|---|---|---|
MCP_SSE_MAX_SESSIONS | Open streams per process. Streams on public endpoints stop at 75% of it, so API-token callers keep room. | 2000 |
MCP_SSE_MAX_SESSIONS_PER_IP | Open streams one client address may hold on the public endpoints. | 50 |
MCP_SSE_IDLE_TIMEOUT_MS | A stream that has received no message for this long is closed. The keep-alive comments the gateway sends do not count. | 1800000 |
MCP_SSE_MAX_BUFFERED_BYTES | A stream whose unsent output (a client that stopped reading) exceeds this is closed. | 8388608 |
MCP_SSE_KEEPALIVE_MS | Interval of the comment frame that keeps a quiet stream open through proxies. | 25000 |
The endpoint event carries the path of the message URL (/api/…/message?sessionId=…), never an absolute URL. MCP clients resolve it against the URL they opened the stream on, so it does not depend on APP_URL or on the request's Host and X-Forwarded-* headers, and a client may reach the gateway under any hostname.
With several replicas and a Redis relay, a message for a stream on a public endpoint may reach a different replica than the one holding the stream: the response is relayed to that replica, provided the stream was opened on the same endpoint by an anonymous caller. Streams opened with an API token stay on the replica that holds them, so route their POST …/message calls to the same replica (session affinity) or use the streamable HTTP transport instead.
Public endpoints
Servers whose access mode is public answer at /api/public/mcp/… without a token. Those routes accept JSON bodies only (415 otherwise), answer a request over its rate with 429 and a Retry-After, and report a failed tool call without the upstream's text: Tool execution failed or Upstream request failed (status N), followed by the id of the request-log row that holds the detail. Invalid arguments and unknown tool names are reported as such (JSON-RPC -32602). Calls are also logged with the caller's address and user agent, and with smaller payloads than token calls.
| Variable | Description | Default |
|---|---|---|
MCP_PUBLIC_RATE_LIMIT_PER_MINUTE | Requests per client address and endpoint per minute (and ten times that per address across all public endpoints). 0 turns these limits off. | 300 |
MCP_PUBLIC_ENDPOINT_RATE_LIMIT_PER_MINUTE | Requests per endpoint per minute from all callers together, whatever address they appear to come from. Unset, it is twenty times MCP_PUBLIC_RATE_LIMIT_PER_MINUTE. 0 turns it off. | 6000 |
MCP_PUBLIC_BODY_LIMIT_BYTES | Largest request body a public POST may carry (minimum 1024). | 1048576 |
MCP_PUBLIC_MAX_INFLIGHT_PER_TENANT | Tool calls one tenant may have running at once through its public endpoints; a call over it gets 503. 0 turns the cap off. | 100 |
MCP_PUBLIC_LOG_PAYLOAD_LIMIT_BYTES | Largest request or response payload a public call stores in the request log (minimum 256). | 16384 |
MCP_PUBLIC_MAX_ARGUMENT_CHARS | Longest string a public tool call may carry in its arguments, at any depth; a longer one fails the call (minimum 256). | 32768 |
The client address is the one Fastify resolves; when the gateway runs behind a reverse proxy, list the proxy in TRUSTED_PROXIES so the address cannot be supplied by the caller. The per-endpoint rate (MCP_PUBLIC_ENDPOINT_RATE_LIMIT_PER_MINUTE) does not depend on the address. An endpoint used by many people behind one corporate gateway may need MCP_PUBLIC_RATE_LIMIT_PER_MINUTE raised, since everyone behind an address shares that address's rate. The counters are kept under the server's stored ids and per process; with RATE_LIMIT_PROVIDER=redis the per-endpoint limits are shared by all replicas.
Cluster & Queue
| Variable | Description | Default |
|---|---|---|
NODE_ROLE | Node role: main, worker, or all | all |
NODE_NAME | Unique node name (used in the cluster registry) | <hostname>-<pid> |
NODE_URL | Public URL of this node (informational) | (empty) |
NODE_TAGS | Comma-separated tags of this node | (empty) |
NODE_HEARTBEAT_MS | How often the node writes its heartbeat | 10000 |
NODE_OFFLINE_AFTER_MS | A node is marked offline after this gap without a heartbeat | 30000 |
CLUSTER_DEFAULT_NODE_NAME | Default node for new instance assignments | First online node |
QUEUE_PROVIDER | Queue backend: auto, memory, bullmq | auto (bullmq when Redis is configured) |
QUEUE_REDIS_URL | Redis URL for BullMQ | Falls back to REDIS_URL |
QUEUE_PREFIX | BullMQ key prefix | console:q: |
QUEUE_DEFAULT_ATTEMPTS | Default retry attempts per job | 3 |
QUEUE_DEFAULT_BACKOFF_MS | Default backoff between retries | 1000 |
CRAWLER_RESTART_ORPHANED_RUNS | Re-queue crawl runs that were in flight when the process stopped (each run a bounded number of times). false fails them for a manual re-run instead. | true |
See Cluster for the full topology / assignment model.
Job concurrency
Jobs a node works on at once, per job type. Each is a whole number from 1; restart to change.
| Variable | Description | Default |
|---|---|---|
AGENT_CHAT_CONCURRENCY | Interactive agent chat turns | 4 |
AGENT_RUN_CONCURRENCY | Agent background runs, default class | 4 |
AGENT_DEFERRED_CONCURRENCY | Agent deferred runs | half of AGENT_RUN_CONCURRENCY, at least 1 |
AGENT_RUN_CALLBACK_CONCURRENCY | Agent run callback deliveries | 4 |
WEBHOOK_CONCURRENCY | Outgoing webhook deliveries | 8 |
MCP_INVOKE_CONCURRENCY | MCP tool invocations routed through the queue | 4 |
CRAWLER_RUN_CONCURRENCY | Crawl runs | 2 |
RAG_INGEST_CONCURRENCY | Knowledge Engine documents indexed in the background | 2 |
RAG_REINDEX_CONCURRENCY | Knowledge Engine re-index jobs | 1 |
VECTOR_MIGRATION_CONCURRENCY | Vector index migration jobs | 2 |
EVALUATION_RUN_CONCURRENCY | Evaluation runs | 2 |
DATASET_GEN_CONCURRENCY | Dataset generation jobs | 2 |
ANALYSIS_RUN_CONCURRENCY | Analysis runs | 2 |
REDTEAM_SCAN_CONCURRENCY | Red-team scans | 2 |
BATCH_ITEM_CONCURRENCY | Batch items | 4 |
SNAPSHOT_JOB_CONCURRENCY | Snapshot jobs | 2 |
BROWSER_ACTION_CONCURRENCY is in Browser Runtime. Enterprise modules have job variables of their own on their module pages.
Portal Address
Enterprise portals open at /p/{portalKey} on the Cognipeer host. With one of these settings they get an address of their own, and /p links are sent on to it. Nothing changes while all three are empty. See Portal address.
| Variable | Description | Default |
|---|---|---|
PORTAL_BASE_DOMAIN | Wildcard mode: each workspace's portals at https://<workspace slug>.<base>/{portalKey}, with the portal chooser at /. Needs a wildcard DNS record and certificate for *.<base>. Must not contain the Cognipeer host (APP_URL). | (empty) |
PORTAL_HOST | One fixed host without a wildcard, for example assistant.example.com. Must not be the Cognipeer host. | (empty) |
PORTAL_HOST_TENANT | The slug of the workspace PORTAL_HOST serves. Empty: the workspace of the person's session, as /p does. Needs PORTAL_HOST. | (empty) |
An invalid value stops Cognipeer from starting when NODE_ENV=production. People still sign in on the Cognipeer host (password, LDAP and SSO are unchanged, so identity providers need no new redirect URI), and signing out of a portal also ends the Cognipeer session. Portal links use the scheme and port of APP_URL, so production needs an https APP_URL.
Channels
Slack and Microsoft Teams channels for agents (Enterprise). See Slack and Microsoft Teams channels. The Teams messaging endpoint is built from APP_URL (the older NEXT_PUBLIC_APP_URL is read too), and the channels service switch turns the feature off.
| Variable | Description | Default |
|---|---|---|
CHANNELS_INBOUND_CONCURRENCY | Incoming messages each node handles at the same time (1 to 64). Restart to change. | 8 |
CHANNELS_TEAMS_EXTRA_SERVICE_HOSTS | Comma-separated extra hostnames Cognipeer may send Teams replies to, for Microsoft clouds not in the built-in list. Exact host names only. | (empty) |
Entity Health & Alerting
Health views, alert rules and reports for agents, models, knowledge bases, MCP servers and tools read 5-minute rollups that every node buffers in memory and flushes to the database. See Monitoring for how alert rules use them and Agent Tracing for how a session's status is decided.
| Variable | Description | Default |
|---|---|---|
ENTITY_METRICS_FLUSH_MS | How often buffered rollup increments are written to the database (minimum 1000). Alert evaluation only reads data older than this, so a longer interval delays alerts by the same amount | 30000 |
ENTITY_METRICS_RETENTION_DAYS | Rollup buckets older than this many days are expired (database TTL plus an hourly purge, minimum 1). Health ranges and baselines cannot look further back than this | 45 |
ENTITY_METRICS_MAX_BUFFERED_ROWS | Cap on distinct rollup rows buffered per process (minimum 100); new rows beyond the cap are dropped and counted, existing rows keep accumulating | 50000 |
ENTITY_METRICS_MAX_BUFFERED_ROWS_PER_TENANT | Cap on distinct rollup rows one tenant may hold in the buffer (minimum 100), so a single tenant cannot use up the share of the others; the effective cap is the lower of this and ENTITY_METRICS_MAX_BUFFERED_ROWS. Excess new rows are dropped and counted per tenant | 10000 |
TRACING_STALE_SESSION_MINUTES | A traced session still in_progress this many minutes after its last activity is marked abandoned (minimum 5). An abandoned session is not an error | 360 |
TRACING_FINALIZER_INTERVAL_MS | How often stale traced sessions are swept (minimum 10000) | 300000 |
ALERT_CHANNEL_TIMEOUT_MS | Per-channel timeout when delivering an alert notification: webhook, Slack, Teams and PagerDuty (minimum 1000) | 10000 |
ALERT_DEFAULT_RULES_ON_CREATE | New projects and the Default Project of a new workspace get the five default alert rules (the default set of the rule templates, each a threshold rule on the error rate of every entity of its module). false turns that default off; a project can still add them from Alerts → Templates, and a create request that sends defaultAlertRules: true still gets them | true |
OTLP sessions are closed earlier than the stale window: one that has been quiet for 10 minutes (or the stale window, whichever is shorter) is finalized as success or error instead of abandoned. The 10 minutes are fixed.
Agent Runs
| Variable | Description | Default |
|---|---|---|
AGENT_STATE_MAX_BYTES | Cap on one stored conversation state document (the turn snapshot plus, while a run waits for an approval or an answer, the paused copy), as stored: compressed and base64 (100000 to 15000000). The default suits Cosmos DB for MongoDB RU (2 MB document limit); MongoDB and Cosmos vCore (16 MB) can go up to 15 MB. A state over the cap is trimmed, tool outputs first. A pause that still does not fit ends the run as failed | 1500000 |
Operator settings for background runs, triggers and reminders, read once at start-up. What each one does is explained in Background runs and Reminders.
| Variable | Description | Default |
|---|---|---|
AGENT_SYNC_TIMEOUT_MS | How long a synchronous call waits for its run; after that the call answers 202 and the run keeps going (minimum 5000). Keep it below the shortest infrastructure timeout in the deployment | 600000 |
AGENT_BACKGROUND_MAX_DURATION_MS | Longest wall-clock time any run may take (minimum 10000) | 1800000 |
AGENT_RUN_MAX_ACTIVE_PER_TENANT | Default-class runs queued or running per tenant, every mode; 0 = no cap | 250 |
AGENT_RUN_MAX_ACTIVE_PER_PROJECT | The same per project; 0 = off | 0 |
AGENT_DEFERRED_MAX_RUNNING_PER_TENANT | Deferred (low priority) runs executing at once per tenant | 2 |
AGENT_DEFERRED_MAX_QUEUED_PER_TENANT | Deferred runs queued or scheduled per tenant; over it a new run is refused with 429 | 10000 |
AGENT_DEFERRED_MAX_WAIT_MS | A deferred or scheduled run that has not started this long after it was due fails as expired (minimum 60000) | 86400000 |
AGENT_RUN_DRAIN_TIMEOUT_MS | On shutdown, how long to wait for local runs before marking the rest interrupted; kept below SHUTDOWN_TIMEOUT_MS minus 3 seconds | 10000 |
AGENT_RUN_REQUEUE_AFTER_MS | A queued run that no worker picked up is published again after this long (minimum 10000) | 120000 |
AGENT_RUN_HEARTBEAT_INTERVAL_MS | How often a running run records that it is alive (minimum 1000) | 15000 |
AGENT_RUN_HEARTBEAT_STALE_MS | A running run whose heartbeat is older than this is declared lost (at least three heartbeat intervals) | 45000 |
AGENT_RUN_RETENTION_DAYS | How long run records are kept | 30 |
AGENT_SESSION_EVENT_RETENTION_DAYS | How long a session's event log is kept | 30 |
AGENT_TRIGGER_TICK_MS | How often the trigger scheduler looks for due slots (minimum 5000) | 30000 |
AGENT_TRIGGER_MISFIRE_GRACE_MS | A missed trigger slot older than this is skipped, a younger one fires once to catch up | 3600000 |
AGENT_WEBHOOK_BODY_LIMIT_BYTES | Largest incoming webhook-trigger body (16384 to 26214400); a larger one gets 413 | 5242880 |
AGENT_WEBHOOK_RATE_LIMIT_PER_MINUTE | Runs one webhook trigger may start per minute; 0 = off. Counted per node unless RATE_LIMIT_PROVIDER=redis | 60 |
AGENT_REMINDERS_ENABLED | false: agents cannot set reminders and due reminders do not run | true |
AGENT_REMINDER_MIN_DELAY_SECONDS | Shortest reminder delay any agent may use (minimum 30) | 60 |
AGENT_REMINDER_MAX_HORIZON_HOURS | Furthest ahead any agent may set a reminder (1 to 720) | 168 |
AGENT_REMINDER_MAX_ACTIVE_PER_SESSION | Scheduled reminders one session may hold at once | 10 |
AGENT_REMINDER_MAX_FIRES_PER_SESSION | Reminders one session may ever create (a repeating one counts once) | 100 |
AGENT_REMINDER_SERIES_ENABLED | false: no agent may set repeating reminders; waiting series end at their next occurrence | true |
AGENT_REMINDER_SERIES_MAX_ACTIVE_PER_USER | Ceiling for the running repeating reminders of one person and one agent (1 to 100; an agent defaults to 5) | 20 |
AGENT_REMINDER_SERIES_MAX_DAYS | Ceiling for how long a series may run (1 to 366) | 90 |
AGENT_REMINDER_SERIES_MAX_OCCURRENCES | Ceiling for the occurrence count of a series (1 to 1000) | 90 |
AGENT_REMINDER_SERIES_MAX_PER_MONTH | Ceiling for the occurrences of one series in 30 days (1 to 744; an agent defaults to 62) | 744 |
AGENT_DURABLE_RUNS | Durable runs: a background run's turn is checkpointed and an orphaned run continues on another node. false turns it off | true |
AGENT_CHECKPOINT_INTERVAL_MS | Longest time between two checkpoints of a durable run's turn (minimum 1000) | 10000 |
AGENT_RUN_MAX_RECOVERIES | Times an orphaned durable run is continued elsewhere before it fails with worker_lost (0 to 10) | 2 |
Concurrency settings (AGENT_RUN_CONCURRENCY, AGENT_DEFERRED_CONCURRENCY, AGENT_RUN_CALLBACK_CONCURRENCY, AGENT_CHAT_CONCURRENCY) are listed under Job concurrency.
Agent Canvas
Platform-wide limits of the Canvas feature (the enterprise canvas module). They are not changeable per agent.
| Variable | Description | Default |
|---|---|---|
AGENT_CANVAS_ENABLED | false: no agent is offered the canvas tools. Stored canvases stay readable | true |
AGENT_CANVAS_MAX_CONTENT_BYTES | Largest canvas version, in UTF-8 bytes (1024 to 4194304) | 262144 |
AGENT_CANVAS_MAX_PER_CONVERSATION | Canvases one conversation may make | 20 |
AGENT_CANVAS_MAX_VERSIONS | Versions kept per canvas besides version 1; older ones are pruned (minimum 2) | 100 |
AGENT_CANVAS_MAX_BYTES_PER_OWNER | Bytes of all versions of one person's canvases (minimum 65536) | 52428800 |
AGENT_CANVAS_MAX_EDITS_PER_CALL | Find/replace pairs in one canvas_edit call (1 to 100) | 20 |
AGENT_CANVAS_STATE_INLINE_BYTES | The open canvas's content is put in each turn's context up to this size (0 to 262144) | 24576 |
AGENT_CANVAS_READ_CHUNK_BYTES | Bytes canvas_read returns per call (4096 to 1048576) | 65536 |
Outgoing Webhooks
Delivery of webhook subscriptions (see Webhooks). A failed delivery is retried on the schedule below; a 3xx answer or a blocked address disables the endpoint at once.
| Variable | Description | Default |
|---|---|---|
WEBHOOK_TIMEOUT_MS | Timeout of one delivery attempt (minimum 1000) | 10000 |
WEBHOOK_RETRY_SCHEDULE_SECONDS | Comma-separated seconds to wait before retry 1, 2, and so on. Unreadable input keeps the default | 60,300,1800,7200,21600,43200,86400 |
WEBHOOK_AUTO_DISABLE_HOURS | An endpoint that has failed continuously for longer than this is disabled | 72 |
WEBHOOK_DELIVERY_RETENTION_DAYS | Settled delivery records older than this are deleted | 30 |
WEBHOOK_CONCURRENCY | Deliveries sent at once per node | 8 |
Knowledge Engine Ingest
Used when a client posts an ingest with async: true: the document is stored as pending and chunked and embedded by a job instead of inside the request.
| Variable | Description | Default |
|---|---|---|
RAG_INGEST_CONCURRENCY | Documents indexed at once per node | 2 |
RAG_INGEST_BOOT_RESUME_MAX | Pending documents re-published per start-up sweep | 500 |
MCP OAuth
Defaults for MCP servers whose upstream authentication is OAuth 2.0: one shared connection or each person's own. See OAuth 2.0 for a remote server.
| Variable | Description | Default |
|---|---|---|
MCP_OAUTH_DEFAULT_CONNECTION_MODE | The connection mode of an OAuth server that has none set: tenant (one shared account) or user (each person's own) | tenant |
MCP_OAUTH_TENANT_FALLBACK | true allows "the person's own, else the shared connection" (user_then_tenant) | false |
MCP_OAUTH_UNATTENDED_RUNS | What a per-person server does in a trigger, schedule or flow run, where nobody can sign in: deny or accountable_user | deny |
MCP_OAUTH_PERSON_CHANNELS | What a per-person server does when called from a channel, the API or an MCP client: own (the person's own connection) or deny | own |
MCP_OAUTH_NOTIFY_REFUSED | E-mail the person when a call needed their connection (once a day per server) | true |
MCP_OAUTH_AUTHORIZE_TIMEOUT_SECONDS | How long a paused agent turn waits for the person to connect (minimum 60) | 900 |
MCP Request Logging
| Variable | Description | Default |
|---|---|---|
MCP_LOG_CLIENT_META | Store the params._meta an MCP host sends with a tool call in the request-log row, under _client.meta. Bounded, sensitive values masked, coordinates never stored. false stores nothing | true |
MCP_LOG_CLIENT_META_MAX_BYTES | Largest serialized _meta kept per request-log row. Keys beyond it are dropped and the row is marked _truncated (minimum 256) | 2048 |
See MCP Servers.
Data Retention
One policy ages out every log the console writes. The engine runs in every edition. It starts in dry run, so nothing is deleted until you set RETENTION_DRY_RUN=false. See Data retention before you do.
| Variable | Description | Default |
|---|---|---|
RETENTION_ENGINE_ENABLED | Scheduled sweeps. With false only the scheduled sweeps stop; Clean now still works | true |
RETENTION_DRY_RUN | Sweeps only count and record what they would delete or redact. Turn off after checking npm run retention:inventory | true |
RETENTION_INTERVAL_SECONDS | How often the cluster-wide tick queues the sweeps (minimum 60) | 3600 |
RETENTION_BUDGET_SECONDS | How long one sweep slice may run before it queues its continuation (10 to 840) | 240 |
RETENTION_BATCH_SIZE | Rows per delete or redact batch (50 to 5000) | 500 |
RETENTION_SHORTEN_DELAY_HOURS | How long a shortened duration waits before it applies (0 to 168; 0 is immediate) | 24 |
RETENTION_AUDIT_MIN_DAYS | Floor for the audit class, for every workspace and every purge (minimum 30) | 365 |
RETENTION_RECORDS_DAYS | How long destruction records are kept (minimum 1095) | 1095 |
RETENTION_ENFORCE_CLASSES | Comma-separated classes to enforce even while RETENTION_DRY_RUN is on (for example content). Malformed or unknown classes stop start-up | unset |
RETENTION_ENFORCE_TENANTS | Pilot workspaces, on top of the above: slug:class,class;slug2:class. A malformed value stops start-up | unset |
RETENTION_PLAN_DOWNGRADE_GRACE_DAYS | Grace for a lower plan cap, and for a new or lower gateway or agent-file cap (0 to 90) | 14 |
RETENTION_<CLASS>_DAYS | Deployment default for one data class: CONTENT, TELEMETRY, TRACE, JOBS, METRICS, ALERTS, AUDIT, USAGE, RESULTS, CONVERSATIONS. Unset or 0 uses the class default (for CONVERSATIONS: kept until the user deletes it); the value is then clamped to the class range. For example the TELEMETRY class is RETENTION_TELEMETRY_DAYS (default 90, range 30 to 400) | class default |
RETENTION_<CLASS>_MAX_DAYS | Optional deployment cap for one class (same class names, for example RETENTION_TELEMETRY_MAX_DAYS=180). It lowers the ceiling (the class maximum on SaaS, 3650 days on-premises) for every workspace and setting, and never overrides a class floor | unset |
The tracing retention sweep and its interval variable no longer exist. Traces age out only under the retention policy (the trace class), and a trace session stays until the daily rollups cover its day. The quota policy maxTracingRetentionDays is retired: setting it answers 400 retired_limit.
Logging
| Variable | Description | Default |
|---|---|---|
LOG_LEVEL | Log level: error, warn, info, debug | debug (dev) / info (prod) |
LOG_FORMAT | Output format: json, pretty | pretty (dev) / json (prod) |
LOG_REQUEST_BODY | Log request bodies | false |
LOG_RESPONSE_BODY | Log response bodies | false |
CORS
| Variable | Description | Default |
|---|---|---|
CORS_ENABLED | Enable CORS for client API | false |
CORS_ALLOWED_ORIGINS | Comma-separated allowed origins | — |
CORS_MAX_AGE | Preflight cache duration (seconds) | 86400 |
SMTP (Email)
| Variable | Description | Default |
|---|---|---|
SMTP_HOST | SMTP server host | smtp.gmail.com |
SMTP_PORT | SMTP server port | 587 |
SMTP_SECURE | Use TLS | false |
SMTP_USER | SMTP username | — |
SMTP_PASS | SMTP password | — |
SMTP_FROM | From address | Falls back to SMTP_USER |
SENDGRID_API_KEY | SendGrid API key; used through SendGrid SMTP when SMTP_* credentials are absent | — |
SENDGRID_FROM_EMAIL | Verified SendGrid sender address | — |
Invitation emails go through SendGrid when it is configured; if you use it for outbound mail, check that invited users receive the password-setup email through the provider you intend.
Application
| Variable | Description | Default |
|---|---|---|
APP_URL | Server-side public application URL, used in emails and generated links. Preferred over NEXT_PUBLIC_APP_URL. | http://localhost:3000 |
NEXT_PUBLIC_APP_URL | Legacy fallback for APP_URL | http://localhost:3000 |
SHUTDOWN_TIMEOUT_MS | Graceful shutdown timeout | 15000 |
DOCS_BASE_URL | Root of the docs site that the Documentation panel and every docs link in Cognipeer open. Set it to a copy of this site that people's browsers can reach when they cannot reach the public one (an installation without internet access). Read at start-up, no rebuild needed. When the site does not answer, the panel shows a notice and a link instead of an empty frame. | https://docs.cognipeer.com |
NEXT_BODY_SIZE_LIMIT | Largest request body the server accepts by default: a whole number with an optional b, kb, mb or gb unit (10mb). A value that does not read this way uses 10mb. | 10mb |
TRACING_MAX_BODY_SIZE_MB | Max tracing payload size | 10 |
HEALTH_ENDPOINT_ENABLED | Enable health endpoints | true |
HF_ENDPOINT | Hugging Face Hub API used by GPU Fleet model search and suggestions. Set a mirror or proxy for installs that cannot reach the public Hub (an http(s) URL; anything else keeps the default). A host you set here may be on the private network. | https://huggingface.co |
AUTHZ_STRICT_REGISTRATION | For developers: 1 makes the API refuse to build when a route declares no authorization. Always on under NODE_ENV=test; otherwise an undeclared route is logged at start-up and refused at request time. | off |
PROVIDER_RUNTIME_CACHE_TTL_SECONDS | Runtime pool entry TTL. 0 turns expiry off (entries are still replaced when a provider's configuration changes). | 300 |
PROVIDER_RUNTIME_DISPOSE_GRACE_SECONDS | How long an evicted runtime keeps its connections open before they are closed, so a request that still holds it can finish. 0 closes immediately. See Runtime Pool. | 300 |
Files
| Variable | Description | Default |
|---|---|---|
FILE_UPLOAD_MAX_MB | Largest single file an upload may carry, in MB. An upload request body may be that size as base64 plus 64 KiB. Stored files are read back (download, preview, zip) up to the larger of twice this value and 100 MB. | 50 |
FILE_UPLOAD_ALLOWED_MIME_TYPES | Comma-separated allow-list of content types; image/* style wildcards work. An upload of another type is refused with 415. Empty allows any type. | (empty) |
See Files for the other limits of the Document Store.
Document extraction (OCR)
These apply only where a Knowledge Engine module, an agent, an upload or a crawler turns OCR on; with OCR off nothing here is used. See OCR jobs.
| Variable | Description | Default |
|---|---|---|
OCR_DEFAULT_LANGUAGES | Languages (ISO 639-1) the local engine reads when a setting names none. The bundled data covers tr and en | tr,en |
OCR_MAX_PAGES | Pages read by OCR per document when a setting names no limit | 100 |
OCR_MAX_PAGES_LIMIT | The largest page limit a setting may ask for | 500 |
OCR_MODEL_CONCURRENCY | Concurrent calls to an OCR or vision model inside one document | 4 |
OCR_LOCAL_CONCURRENCY | Pages recognised in parallel inside one document by the local engine | 1 |
OCR_LOCAL_MAX_DOCS | Documents the local engine reads at once per node | 1 |
OCR_CALL_TIMEOUT_MS | One OCR call (a page, an image or a whole-document request) | 180000 |
OCR_DOCUMENT_TIMEOUT_MS | A whole document read by a job. When it is reached the document keeps its native text and a warning is recorded | 900000 |
OCR_INLINE_TIMEOUT_MS | A whole document read while the request waits | 120000 |
OCR_TESSDATA_DIR | Directory with <lang>.traineddata.gz files for the local engine. Empty uses the bundled Turkish and English data | (empty) |
OCR_ITEM_CONCURRENCY | Items of an OCR job processed at once per node | 5 |
License
| Variable | Description | Default |
|---|---|---|
LICENSE_GRACE_DAYS | Days past its expiry a license package still activates, with a warning | 14 |
OFFLINE_LICENSE_PUBLIC_KEY | Public key (PEM) that verifies an offline license. Use \n escapes for a multi-line value in an environment variable. Takes precedence over the path | (empty) |
OFFLINE_LICENSE_PUBLIC_KEY_PATH | File that holds that public key | (empty) |
OFFLINE_LICENSE_ISSUER | Issuer an offline license must name | cognipeer |
OFFLINE_LICENSE_AUDIENCE | Audience an offline license must name | cognipeer-console |
Licenses are activated per workspace under Settings → License; there is no license variable. See Licensing.
Enterprise modules
The variables of the persistent sandbox (SANDBOX_*) are on Agent Sandbox. The ones below belong to modules that are part of a licence package.
JavaScript sandbox
Limits of the platform's isolated JavaScript executions (V8 isolates).
| Variable | Description | Default |
|---|---|---|
JS_SANDBOX_DEFAULT_MAX_CONCURRENT | Default concurrent executions per workspace | 5 |
JS_SANDBOX_DEFAULT_TIMEOUT_MS | Default execution timeout | 5000 |
JS_SANDBOX_MAX_TIMEOUT_MS | Longest execution timeout that can be asked for | 30000 |
JS_SANDBOX_MEMORY_LIMIT_MB | V8 isolate memory limit | 64 |
JS_SANDBOX_MAX_CODE_SIZE_BYTES | Largest submitted code | 65536 |
JS_SANDBOX_MAX_RESULT_SIZE_BYTES | Largest serialized result | 524288 |
JS_SANDBOX_MAX_LOG_ENTRIES | Most console log entries captured | 100 |
JS_SANDBOX_CHILD_PROCESS_TIMEOUT_BUFFER_MS | How long after the timeout the parent kills the worker process | 1000 |
Realtime voice (Enterprise, realtime module)
The ones already described on Realtime (REALTIME_PUBLIC_URL, REALTIME_MAX_SESSIONS, REALTIME_MAX_FRAME_BYTES, REALTIME_MAX_PENDING_INPUT_BYTES, REALTIME_MAX_SOCKET_BUFFER_BYTES) are not repeated.
| Variable | Description | Default |
|---|---|---|
REALTIME_STREAM_TOKEN_SECRET | Key the Twilio media-stream tokens are encrypted and signed with | derived from JWT_SECRET |
REALTIME_OUTBOUND_CALLS_PER_MINUTE | Outbound calls per workspace per minute (0 = unlimited). Counted through RATE_LIMIT_PROVIDER, so it holds across nodes; a counter that cannot be read refuses the call (503) | 30 |
REALTIME_CALL_BLOCKED_PREFIXES | Destinations outbound calls may not dial (empty = none blocked) | +1900,+979,+870,+881,+882,+883 |
REALTIME_CALL_ALLOWED_PREFIXES | When set, outbound calls may only dial these prefixes, for example +90,+44 | (empty) |
REALTIME_MODELS_DIR | Where the bundled turn-detection ONNX models live (Docker image: /app/models/realtime) | ./models/realtime |
REALTIME_SILERO_VAD_PATH | Explicit Silero VAD .onnx file, used as is | (empty) |
REALTIME_SMART_TURN_PATH | Explicit Smart Turn .onnx file for the selected variant, used as is | (empty) |
REALTIME_SMART_TURN_VARIANT | int8 (quantized, smaller) or fp32 (unquantized; CPU cost depends on the hardware) | int8 |
REALTIME_PREWARM_MODELS | 1 loads the models when the server starts (lowest first-call latency). Otherwise the first session loads them | (unset) |
REALTIME_MODEL_LOAD_TIMEOUT_MS | A session waits this long for the models, then starts degraded and swaps them in when they land | 5000 |
REALTIME_ONNX_WORKERS | Inference worker threads. Unset: starts with 2 and grows on demand up to max(2, cores - 2), at most 8; N fixes the pool; 0 runs in the main process | (unset) |
REALTIME_SMART_TURN_THREADS | ONNX threads per Smart Turn call (1 to 8) | 1 |
REALTIME_MAX_AUDIO_BYTES | Largest buffered input audio per manual commit | 26214400 |
REALTIME_MAX_HISTORY | Conversation messages kept per session; the oldest drop first | 200 |
REALTIME_SESSION_RETENTION_DAYS | Delete sessions and their turns older than this many days (0 = keep) | 0 |
REALTIME_RETENTION_INTERVAL_SECONDS | How often that retention sweep runs | 3600 |
Config Source Abstraction
The config module uses a ConfigSource interface, making it easy to swap between ENV-based and database-backed configuration:
interface ConfigSource {
readonly name: string;
get(key: string): string | undefined;
}The default EnvConfigSource reads from process.env. You can replace it:
import { setConfigSource } from '@/lib/core/config';
setConfigSource(myDatabaseConfigSource);Validation
At startup, critical configuration is validated:
const cfg = getConfig();
const errors = validateConfig(cfg);
// Checks: MONGODB_URI required, JWT_SECRET required (min 32 chars),
// PROVIDER_ENCRYPTION_SECRET required (min 32 chars, different from JWT_SECRET),
// REDIS_URL required when CACHE_PROVIDER=redis, etc.Every error is logged. In production the server then refuses to start, so a misconfigured value (for example a missing or invalid JWT_SECRET, PROVIDER_ENCRYPTION_SECRET or JWT_EXPIRES_IN, or an invalid service switch or portal address) fails loudly at deploy time instead of serving requests under a forgeable session token or a setting that silently did not apply. In any other environment it keeps running and logs a warning that some features may not work, which lets Kubernetes secrets be injected after the first start.
Example .env.local
SQLite mode (default, zero dependencies)
# Required
JWT_SECRET=your-secret-key-must-be-at-least-32-chars
PROVIDER_ENCRYPTION_SECRET=another-secret-key-of-at-least-32-chars
# Database (SQLite is the default — no MongoDB needed)
# DB_PROVIDER=sqlite
# SQLITE_DATA_DIR=./data
# Cache
CACHE_PROVIDER=memory
# Logging
LOG_LEVEL=debug
LOG_FORMAT=pretty
# CORS (for client SDKs)
CORS_ENABLED=true
CORS_ALLOWED_ORIGINS=http://localhost:3001,http://localhost:5173MongoDB mode
# Required
JWT_SECRET=your-secret-key-must-be-at-least-32-chars
PROVIDER_ENCRYPTION_SECRET=another-secret-key-of-at-least-32-chars
# Database
DB_PROVIDER=mongodb
MONGODB_URI=mongodb://localhost:27017
# Cache
CACHE_PROVIDER=memory
# REDIS_URL=redis://localhost:6379
# Logging
LOG_LEVEL=debug
LOG_FORMAT=pretty
# CORS (for client SDKs)
CORS_ENABLED=true
CORS_ALLOWED_ORIGINS=http://localhost:3001,http://localhost:5173
# SMTP (optional)
# SMTP_HOST=smtp.gmail.com
# SMTP_USER=your@email.com
# SMTP_PASS=your-app-password
