Deployment#

The OneTick MCP server runs on any host with Python 3.12, 3.13, or 3.14.

This page covers running the server, configuring workers and concurrency, health checks, vector database setup, and keeping the server and search index up to date.

Running the server#

Start the server from your virtual environment (see Quickstart for setup):

onetick-mcp

Use KX_MCP_HOST and KX_MCP_PORT to change the default 127.0.0.1:8000 bind address without changing the start command. See Server variables for the full list of server variables.

Workers and concurrency#

The server runs as a single process — the launcher does not currently support multiple worker processes. A single process already serves many clients concurrently (it is I/O-bound, not CPU-bound), so this is not a limitation for most deployments; there is no worker count to tune.

Long-running deployments#

The symbology tool (search_symbol_universe) writes a generated .otq file to a scratch directory that onetick-py (the vendored OneTick client) picks once per process and caches in memory for the life of that process — it never re-checks that the directory still exists. If that directory sits under the OS’s /tmp and gets swept by an age-based cleanup policy (e.g. systemd-tmpfiles, commonly ~10 days of inactivity) while a long-running server keeps the same process alive, every subsequent symbology call fails with FileNotFoundError ([Errno 2] No such file or directory) referencing a .otq path that no longer exists. Other tools are unaffected — this only touches the code path that materializes and runs a live OneTick query (otp.run).

Set OTP_BASE_FOLDER_FOR_GENERATED_RESOURCE to a path outside the OS’s auto-cleaned tmp area (e.g. a directory under your deploy folder) so a long-lived process never outlives the tmp sweep. Restarting the server is an immediate workaround — a fresh process picks a new, currently-existing scratch directory — but only the env var change fixes it durably.

Health check#

The server answers GET /health with OK and HTTP status 200 once it is running. Use it to confirm a start-up worked, or as the liveness or readiness probe for a container or load balancer:

curl -f http://localhost:8000/health

Network exposure#

The server does not terminate TLS or validate the inbound Host/Origin header itself. For any deployment reachable beyond localhost, put a TLS-terminating reverse proxy or ingress in front of it, and enable MCP server authentication — do not expose KX_MCP_HOST=0.0.0.0 directly to an untrusted network with authentication disabled.

Network requirements#

The server and index build make outbound connections to a few external endpoints, depending on which tools and embedding type you use. Share the following with your network/platform team so these endpoints can be allowlisted:

Endpoint

When needed

Notes

PyPI (pypi.org), or your private package registry

Always

Installing onetick-mcp and its dependencies via pip. If you use an internal registry instead of direct PyPI access, confirm with your platform team that onetick-mcp and its dependencies have been added to it. Point pip at it with --index-url (replaces PyPI) or --extra-index-url (adds to it), or the PIP_INDEX_URL / PIP_EXTRA_INDEX_URL environment variables.

GitHub (github.com)

Only if you clone the documentation repositories directly on the server (see Download documentation sources)

Cloning onetick-py-docs, onetick-sql-docs, onetick-py-examples and onetick-cloud-coverage. Not needed if you clone them elsewhere and copy document_sources across.

Docker Hub, or your internal container registry

Only if you use the Docker step in Quickstart to run pgvector

Pulling the pgvector/pgvector image. Not needed if you point at an existing PostgreSQL/pgvector instance instead.

OpenAI API (api.openai.com), or your internal endpoint

When ONETICK_DB_EMBEDDING_TYPE=openai

Needed to embed documents when building the search index, and to embed search queries at query time. OPENAI_BASE_URL unset (the default) targets the public API; set it to redirect to a self-hosted endpoint instead - see OpenAI-compatible server.

Hugging Face (huggingface.co), or your internal registry proxy

When ONETICK_DB_EMBEDDING_TYPE=sentence_transformer, once per host - the first time the model loads

The embedding model is downloaded once and cached locally. Can be left off the allowlist entirely for air-gapped setups - download the model on a separate machine and copy it across instead - or redirected to an internal registry; see Local (offline) embeddings.

OneTick WebAPI gateway (OTP_HTTP_ADDRESS)

Whenever the onetick data tools (or a custom tool that runs a OneTick query) is enabled

Used by the bundled OneTick query tools. The target URL is OTP_HTTP_ADDRESS (default https://rest.cloud.onetick.com for OneTick Cloud); with the default service_account outbound strategy, OTP_ACCESS_TOKEN_URL (default https://cloud-auth.parent.onetick.com/realms/OMD/protocol/openid-connect/token) must also be reachable. See OneTick WebAPI authentication for on-prem configuration. Not needed if no OneTick-querying tool is enabled - see Enabling and disabling tools.

Your PostgreSQL/pgvector host

Always, for the documentation search_* tools

Network access to wherever ONETICK_DB_SQL_CONNECTION_STRING points; this is often internal-only.

The reference-data (csv/calendar) tools make no outbound network calls of their own — they read local CSV files only.

Vector database#

The server requires PostgreSQL 16+ with the pgvector extension. Any existing PostgreSQL instance with pgvector installed can be used - point ONETICK_DB_SQL_CONNECTION_STRING at it and skip the Docker step below.

For a quick local setup, the official pgvector image is the easiest option:

docker run -d \
  --name onetick-pgvector \
  -e POSTGRES_USER=onetick-user \
  -e POSTGRES_PASSWORD=onetick-password \
  -e POSTGRES_DB=onetick-db \
  -p 5432:5432 \
  -v onetick-pgdata:/var/lib/postgresql/data \
  pgvector/pgvector:pg16

The -v onetick-pgdata:/var/lib/postgresql/data flag mounts a named Docker volume so the database persists across container restarts. The credentials above are placeholders for local development only - use strong credentials for any shared or production deployment.

Updating the server#

Before upgrading, check the Release Notes page for any upgrade notes - some releases require a database migration or search index rebuild.

To upgrade to the latest release:

pip install --upgrade onetick-mcp

To pin to a specific version:

pip install onetick-mcp==x.y.z

After upgrading, restart the server. If the release notes indicate a migration or index rebuild is required, follow the steps in Rebuilding the search index below.

Rebuilding the search index#

Rebuild the search index when:

  • The documentation sources under document_sources/ change (e.g. after pulling updated repos).

  • A server upgrade requires it (see Release Notes).

  • The embedding model (ONETICK_DB_EMBEDDING_TYPE / ONETICK_DB_EMBEDDING_MODEL) is changed.

Re-run the same two commands from the initial setup in your virtual environment:

python -m onetick_llmbase.alembic --settings-module onetick_mcp.config upgrade head
python -m onetick_llmbase.build_index -c onetick_mcp.config --source_path ./document_sources

The first command applies any new database migrations; the second re-embeds and reindexes all sources.

Important

The server does not need to be shut down to rebuild the index, and a finished rebuild is served on the next request without a restart. However, searches against the collections being rebuilt return empty or partial results until the rebuild completes. Other collections are unaffected. Perform rebuilds during off-peak periods, and use --only_collections to rebuild only the collections that changed.

To rebuild only specific collections, use the --only_collections flag with a comma-separated list:

python -m onetick_llmbase.build_index -c onetick_mcp.config \
  --source_path ./document_sources \
  --only_collections python-docs,sql-docs