Configuration#

All settings are read from environment variables or a .env file in the working directory.

Order of precedence#

When the same variable is defined in more than one place, the server resolves it in this order (highest wins):

  1. Constructor arguments (for config-module authors only — not an environment/.env setting) — values passed directly to the Settings(...) call in a Python config module. Deployers cannot set these; they exist only so a config module can pin a value the environment must not be able to override. If you only edit .env/environment variables, ignore this tier and start at tier 2.

  2. Shell environment — variables already exported in the process environment.

  3. .env file — a .env file in the working directory, loaded on startup; overridden by the shell environment.

  4. Class defaults — the values declared on the Settings class. This includes on-prem overrides made by subclassing Settings and re-declaring a field (see Custom Search Tools): a subclass default is still a default, so it is the lowest-precedence tier and a value set for the same field in .env or the environment overrides it.

Note

Set each field in one place. If an on-prem subclass overrides a field (e.g. COLLECTIONS), do not also set that field in .env / the environment — the environment value wins and the subclass override is silently ignored. To pin a value the environment must not override, pass it as a constructor argument (tier 1).

For the minimal set of variables needed to get up and running, see the Configure step in the quickstart guide. The sections below document the supported user-configurable variables, grouped by area.

Capability and data-source variables#

There is no single set of variables required by every deployment. Configure only the capabilities you enable with ONETICK_DB_TOOLS:

Capability

Required configuration

Documentation search

ONETICK_DB_SQL_CONNECTION_STRING plus the embedding settings for the selected backend. The same settings are required when building the index.

Reference data

ONETICK_DB_CSV_DATA_PATH pointing to the cloned or custom coverage files.

OneTick data tools

OTP_HTTP_ADDRESS and the credentials required by ONETICK_DB_OUTBOUND_STRATEGY.

Computation-only custom tools

Only the configuration used by the custom tool itself.

The main capability and data-source settings are:

Variable

Required

Description

ONETICK_DB_SQL_CONNECTION_STRING

for search

Postgres + pgvector connection string. Not needed when no documentation search_* tool is enabled.

OPENAI_API_KEY

for keyed OpenAI embeddings

API key for an OpenAI-protocol embedding endpoint. Not required when using local embeddings, an endpoint that accepts unauthenticated requests, or only non-embedding tools. See Embeddings below.

ONETICK_DB_CSV_DATA_PATH

for reference data

Directory of db_*.txt / mkt_cal_*.txt reference files. Not needed when reference-data tools are not enabled.

ONETICK_DB_COLLECTIONS

no

JSON array of vector collections to index and expose as search tools. Defaults to the OneTick documentation collections. Must be a JSON array, not a plain string: ONETICK_DB_COLLECTIONS='["python-docs","sql-docs"]'. See Active collections.

CUSTOM_COLLECTIONS

no

JSON object declaring config-only (no-code) Markdown collections: { "<name>": {"path": ..., "description": ..., "base_url": ...} }. Each name must also be added to ONETICK_DB_COLLECTIONS. See Option 1 — Config only (markdown directories).

CUSTOM_TOOLS

no

JSON array of custom tool files: [{"path": ...}] (optional per-entry max_results / timeout). Each file is a Python-function tool returning a table. See Custom Tools.

ONETICK_DB_CONFIG_MODULE

no

Importable Python module exposing a module-level settings object. Use this for the Python custom-collection workflow and other subclass-based product configuration; the default is onetick_mcp.config. See Option 2 — Python class.

Server variables#

These settings control the shared KX MCP launcher used internally by onetick-mcp. The KX_MCP_* prefix reflects that implementation detail; continue to start the server with onetick-mcp.

Variable

Required

Description

ONETICK_DB_TOOLS

no

Comma-separated list of tool names to enable (default: all). Every tool (documentation search_*, reference-data, symbology, custom) is named individually. An unknown name fails fast. See Tools.

KX_MCP_HOST / KX_MCP_PORT

no

HTTP bind address (default 127.0.0.1:8000; see Deployment)

KX_MCP_TRANSPORT

no

streamable-http (default) or stdio for single-user bundling

KX_MCP_NAME

no

Server instance name (default kx-mcp)

KX_MCP_LOG_LEVEL

no

Level for the launcher’s own operational/audit log (default INFO). See Logging variables for OneTick’s separate engine log.

Embeddings#

The search_* collection tools turn documents (at index-build time) and queries (at serve time) into vectors. Choose the backend with ONETICK_DB_EMBEDDING_TYPE.

Variable

Required

Description

ONETICK_DB_EMBEDDING_TYPE

no

openai (product default) for an OpenAI-protocol API, or sentence_transformer for a local model.

ONETICK_DB_EMBEDDING_MODEL

no

Model to embed with (product default text-embedding-3-large). For sentence_transformer: a HuggingFace model name (e.g. all-MiniLM-L6-v2) or an absolute path to a local model directory. For openai: the model name served by the endpoint.

OPENAI_BASE_URL

no

Base URL of an OpenAI-compatible endpoint (self-hosted vLLM / LiteLLM or an internal gateway). When unset it targets the public OpenAI API. Also used by the optional self-query LLM when LLM_PROVIDER=openai.

OPENAI_EMBEDDINGS_CHECK_CTX_LENGTH

no

How embedding inputs are sent: true pre-tokenizes into integer token arrays (OpenAI’s default), false sends raw strings. Leave unset to auto-select — true for the public OpenAI API, false when OPENAI_BASE_URL is set. See OpenAI-compatible server.

LLM_PROVIDER

no

Provider for an optional LLM-backed collection retriever. Use openai (default) for the OpenAI-compatible path documented here. The standard search_* tools do not require a chat LLM, but they still use ONETICK_DB_EMBEDDING_MODEL to build the index and embed each search query.

LLM_MODEL_NAME

no

Model name used by an optional LLM-backed collection retriever (product default gpt-5.4). It is ignored by the standard retrieval-only search_* tools; their model is configured separately with ONETICK_DB_EMBEDDING_MODEL.

Note

Re-run build_index on every affected collection after changing ONETICK_DB_EMBEDDING_MODEL or ONETICK_DB_EMBEDDING_TYPE — see Re-index after changing the model.

Two backends are available:

  • Local (offline) embeddings — a local sentence-transformer model loaded in-process; no OpenAI key, supports fully air-gapped deployments.

  • OpenAI-compatible server — the public OpenAI API, or a self-hosted server that speaks the OpenAI API (Ollama, vLLM, LiteLLM, an internal gateway).

Serving without embeddings#

If you enable only non-embedding tools (ONETICK_DB_TOOLS naming no search_* collection tool — for example only the reference-data tools), the server starts with no OpenAI, HuggingFace, or Postgres configuration — the embedding engine is never built. If a collection search tool is enabled but embeddings are unconfigured, the server fails fast at startup with a message naming what to set (rather than starting and erroring later on the first query).

When a collection search tool is enabled and embeddings are configured, building the retrieval engine (the Postgres connection and embedding model load) is bounded to 120 seconds. An unreachable database or embedding endpoint fails startup with a clear timeout error instead of hanging indefinitely.

Index-build variables#

The index build step (python -m onetick_llmbase.build_index) reads ONETICK_DB_SQL_CONNECTION_STRING, ONETICK_DB_COLLECTIONS, CUSTOM_COLLECTIONS, and OPENAI_API_KEY from Capability and data-source variables above. build_index loads .env from the working directory, so the same embedding configuration (including local and offline settings) applies to indexing and serving alike.

If you are not using OpenAI you can omit OPENAI_API_KEY and use Local (offline) embeddings instead.

To rebuild only some collections without changing ONETICK_DB_COLLECTIONS, pass --only_collections to build_index — it restricts this run to the names you list, without altering the ONETICK_DB_COLLECTIONS setting itself:

python -m onetick_llmbase.build_index -c onetick_mcp.config --only_collections python-docs,cloud

OneTick auth variables (OneTick data tools)#

These variables are required only when the onetick data tools (or a custom tool that runs a OneTick query) is enabled. See OneTick WebAPI authentication for a full explanation of each auth mode.

Variable

Required

Description

ONETICK_DB_OUTBOUND_STRATEGY

for OneTick data

service_account (default), basic, or none. See OneTick WebAPI authentication.

ONETICK_DB_OUTBOUND_AUDIENCE

no

Optional token audience requested when ONETICK_DB_OUTBOUND_STRATEGY=service_account and the OneTick WebAPI expects one.

ONETICK_DB_IDENTITY_CLAIMS

no

JSON list of inbound token claims used to identify the caller in tool-call logs and Langfuse; the first present claim wins. Default: ["email","preferred_username","client_id","azp","sub"].

OTP_WEBAPI

for OneTick data

Set 1 for WebAPI / REST mode

OTP_HTTP_ADDRESS

for OneTick data

WebAPI gateway URL

OTP_CLIENT_ID

service_account

OAuth2 client ID

OTP_CLIENT_SECRET

service_account

OAuth2 client secret

OTP_ACCESS_TOKEN_URL

service_account

OAuth2 token endpoint

OTP_HTTP_USERNAME

basic mode

HTTP Basic auth username

OTP_HTTP_PASSWORD

basic mode

HTTP Basic auth password

OTP_QUERY_TIMEOUT

no

Tool query timeout in seconds (default 120); bounds any tool’s otp.run.

OTP_BASE_FOLDER_FOR_GENERATED_RESOURCE

recommended for long-running deployments

Directory the symbology tool writes generated .otq files to. Defaults to a system tmp directory; set this to a path outside the OS’s auto-cleaned tmp area for a long-lived server process — see Deployment.

MAX_QUERY_SPAN_DAYS

no

Maximum [start, end] span in days the bundled symbology tool will query (default 1). See OneTick Data Tools.

QUERY_TOOL_MAX_RESULTS

no

Number of rows a query tool returns before the result is truncated (default 100). Setting this variable overrides any per-tool max_results; when it is left unset, a tool’s own max_results applies, otherwise the 100 default (see Custom Tools). Raise it for an MCP client that accepts larger payloads, or set 0 to disable the cap. See OneTick Data Tools.

Logging variables#

Variable

Required

Description

LOG_DIR

no

Directory for dated log files (default ./logs)

LOG_FILE_PREFIX

no

Log filename prefix (default onetick-mcp)

LOG_LEVEL

no

Log level (default INFO)

LOG_TO_FILE

no

Write dated log files (default true)

LOG_TO_STDOUT

no

Also log to stdout (default true)

LOG_UTC

no

Use UTC for timestamps and daily file rollover (default true)

LOG_FORMAT

no

Python logging format for the OneTick engine log (default %(asctime)s %(levelname)s: worker %(process)d:%(message)s)

LOG_DATEFMT

no

Python logging date format for the OneTick engine log (default %Y%m%d%H%M%S)

Inbound authentication variables#

Inbound authentication is disabled by default (KX_MCP_AUTH unset). Set KX_MCP_AUTH to an authenticated mode and supply that mode’s variables below to require a valid bearer token on every incoming MCP client connection. See MCP server authentication.

Variable

Required

Description

KX_MCP_AUTH

no

Inbound auth mode: unset (off, default), jwks, oidc_proxy, entra, or static. See MCP server authentication.

KX_MCP_AUTH_JWKS_URI

for jwks

The IdP’s JWKS endpoint, used to validate token signatures.

KX_MCP_AUTH_ISSUER

recommended

Expected iss claim; validated if set. Also the discovery-document base for oidc_proxy.

KX_MCP_AUTH_CONFIG_URL

no

Full OIDC discovery-document URL for oidc_proxy. When unset, the server derives the standard /.well-known/openid-configuration URL from KX_MCP_AUTH_ISSUER. Set this for an issuer that publishes discovery elsewhere.

KX_MCP_AUTH_AUDIENCE

recommended

Expected aud claim. Optional for jwks/static — if unset, the aud claim is not validated; set it (with a matching audience mapper on the provider) to restrict tokens to this server. Strongly recommended for oidc_proxy.

KX_MCP_AUTH_ALGORITHM

no

Accepted JWT signing algorithm (default RS256)

KX_MCP_AUTH_REQUIRED_SCOPES

no

Scopes the bearer token must carry. Mandatory for entra.

KX_MCP_AUTH_RESOURCE_URL

recommended

This server’s own public URL, as MCP clients connect to it. Enables RFC 9728 discovery so clients can find the IdP and log in themselves for jwks — see MCP server authentication. Required for oidc_proxy/entra.

KX_MCP_AUTH_CLIENT_ID / KX_MCP_AUTH_CLIENT_SECRET

for oidc_proxy/entra

The single app pre-registered at the issuer that the server proxies logins through.

KX_MCP_AUTH_JWT_SIGNING_KEY

no

In oidc_proxy mode, signs the tokens the server issues to clients and encrypts its stored OAuth state. If unset, both are derived from the client secret. Required if the pre-registered app is a public client with no secret. Set it explicitly so that rotating the client secret does not invalidate issued tokens or re-key stored registrations, PKCE verifiers, and upstream tokens.

KX_MCP_AUTH_OIDC_STRICT

no

Whether oidc_proxy requires every standard OIDC discovery field (default true). Set to false only for a known issuer whose discovery document omits a required field, such as subject_types_supported. The MCP server refuses to start with Missing required configuration metadata when that happens.

KX_MCP_AUTH_TENANT_ID

for entra

The Entra tenant GUID.

KX_MCP_AUTH_IDENTIFIER_URI

no

Application ID URI for entra. Defaults to api://<client-id>; set it only when the Entra app registration uses a custom Application ID URI.

KX_MCP_AUTH_PUBLIC_KEY / KX_MCP_AUTH_PUBLIC_KEY_PATH

for static

Inline PEM or a path to one; validates bearers against this key with no IdP involved.