Quickstart#

This guide walks through installing and running the OneTick MCP server from scratch. For the full environment variable reference see Configuration, and for production setup see Deployment. If you run into problems along the way, see the FAQ and troubleshooting.

Prerequisites#

  • Linux, macOS or Windows. Commands are shown for a bash shell; where Windows needs a different command, a Windows (PowerShell) tab shows it. Selecting that tab once switches every such tab on the page.

  • Python 3.12, 3.13, or 3.14

  • Access to PyPI (or an internal registry that mirrors it) to run pip install onetick-mcp.

  • Docker or Podman (optional) - used in this guide to run a PostgreSQL + pgvector container for the search index. This requires access to a container registry with the pgvector/pgvector image (Docker Hub, or an internal mirror). If you already have a PostgreSQL instance with the pgvector extension, you can skip this step and use your existing connection string instead.

  • Choose an embedding provider - one of the following. This determines which pip install command you’ll use below:

    • OpenAI embeddings (the default) - an OpenAI API key with permission to call the embedding models, and outbound access to the OpenAI API. Usage is billed per token, at a rate that depends on the embedding model.

    • Self-hosted OpenAI-compatible embeddings (OpenAI-compatible server) - outbound access to your own endpoint (Ollama, vLLM, LiteLLM, or an internal gateway). No OpenAI access is required.

    • Local embeddings (Local (offline) embeddings) - outbound access to Hugging Face to download the model, or the model loaded via your artifact registry. No OpenAI access is required in this case.

  • OneTick Cloud WebAPI credentials (OTP_CLIENT_ID / OTP_CLIENT_SECRET) - required for the bundled OneTick data tools. You can skip these if you disable all OneTick-querying tools.

See Embedding costs for how each provider is billed.

If you’re behind a restrictive firewall, review Network requirements before proceeding so you know what is required.

Install#

Create and activate a virtual environment:

python3.12 -m venv .venv # or python3.13 / python3.14
source .venv/bin/activate
py -3.12 -m venv .venv  # or -3.13 / -3.14
.venv\Scripts\Activate.ps1

If PowerShell refuses with running scripts is disabled on this system, allow scripts for the current window only (no administrator rights needed; it resets when the window closes) and activate again:

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
.venv\Scripts\Activate.ps1

In cmd.exe, activate with .venv\Scripts\activate.bat instead.

Then install the package, using the tab matching the embedding provider you chose above - the local option pulls in an extra package to run the Hugging Face model in-process instead of calling OpenAI. The pip commands are the same on every platform:

pip install onetick-mcp
pip install onetick-mcp

Same install as the default - see OpenAI-compatible server for the .env settings that point it at your own endpoint.

pip install "onetick-mcp" "onetick-llmbase[local-embeddings]"

Installs the local-embeddings extra as well - no OpenAI key, and no network calls at all once the model is cached. See Local (offline) embeddings for details.

Download documentation sources#

Both the documentation-search tools and the reference-data tools rely on OneTick documentation cloned locally. The onetick-mcp pip package does not include these source files or a prebuilt vector index, so create a document_sources directory and clone the required repositories into it:

mkdir document_sources
git clone https://github.com/onemarketdata/onetick-py-docs        document_sources/onetick-py-docs
git clone https://github.com/onemarketdata/onetick-sql-docs       document_sources/onetick-sql-docs
git clone https://github.com/onemarketdata/onetick-py-examples    document_sources/onetick-py-examples
git clone https://github.com/onemarketdata/onetick-cloud-coverage document_sources/onetick-cloud-coverage

These commands work unchanged in Windows PowerShell and cmd.exe.

Note

Run these commands in the same directory that contains your .venv, so document_sources sits next to it. The rest of this quickstart (the index build and starting the server) uses relative paths such as ./document_sources and reads .env from the current directory, so we recommend working from this one directory throughout.

Run git pull in each repository to pick up updates before rebuilding the index (see Deployment).

The two tool families use this content differently:

  • The documentation search tools (the search_* tools) require an index build step before use — the documentation is embedded and stored in pgvector. This is covered in the Build the search index step below.

  • The reference data tools read the CSV files directly at request time — no build step is needed.

These OneTick repositories are the defaults and are what this quickstart uses. Get the server working with them first, then customise if you need to:

  • To search your own Markdown documentation, add it as a new search tool. It sits next to the OneTick search tools rather than replacing them — see Custom Search Tools.

  • To use your own reference data instead of the OneTick coverage files, point ONETICK_DB_CSV_DATA_PATH at your own files — see Custom Reference Data.

Start PostgreSQL with pgvector#

The search tools store their index in a PostgreSQL database (version 16 or later) with the pgvector extension. If you already have a PostgreSQL 16+ instance with pgvector available, skip this step and use your existing connection string in the Configure step below.

Otherwise, the quickest way to get started is with Docker (Podman is a drop-in replacement - substitute podman for docker below). The image name is fully qualified with the docker.io/ registry below; unlike Docker, Podman doesn’t always default unqualified image names to Docker Hub (depends on the distro’s registries.conf), so leaving it off can prompt interactively or fail outright:

mkdir -p onetick-pgdata

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 "$(pwd)/onetick-pgdata:/var/lib/postgresql/data" \
  docker.io/pgvector/pgvector:pg16

This container persists data to the ./onetick-pgdata directory so the index survives restarts.

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 `
  docker.io/pgvector/pgvector:pg16

PowerShell continues a line with a backtick at the end instead of \. This persists data to a Docker named volume, onetick-pgdata, so the index survives restarts. A named volume is used rather than a folder on the Windows file system because PostgreSQL needs Linux file permissions on its data directory, which a Windows folder mount can’t provide.

Configure#

Create a .env file in the directory you will run the server from, with the minimal settings for your chosen embedding provider:

# pgvector connection - matches the Docker container started above
ONETICK_DB_SQL_CONNECTION_STRING=postgresql+psycopg://onetick-user:onetick-password@localhost:5432/onetick-db

# Path to the reference data CSV files
ONETICK_DB_CSV_DATA_PATH=./document_sources/onetick-cloud-coverage

# OneTick Cloud credentials - required for the OneTick data tools
OTP_CLIENT_ID=
OTP_CLIENT_SECRET=

# OpenAI details
ONETICK_DB_EMBEDDING_TYPE=openai
ONETICK_DB_EMBEDDING_MODEL=text-embedding-3-small
OPENAI_API_KEY=sk-...
# pgvector connection - matches the Docker container started above
ONETICK_DB_SQL_CONNECTION_STRING=postgresql+psycopg://onetick-user:onetick-password@localhost:5432/onetick-db

# Path to the reference data CSV files
ONETICK_DB_CSV_DATA_PATH=./document_sources/onetick-cloud-coverage

# OneTick Cloud credentials - required for the OneTick data tools
OTP_CLIENT_ID=
OTP_CLIENT_SECRET=

# Self-hosted OpenAI-compatible endpoint
ONETICK_DB_EMBEDDING_TYPE=openai
ONETICK_DB_EMBEDDING_MODEL=<the-embedding-model-your-endpoint-serves>
OPENAI_BASE_URL=<your-endpoint-base-url>
# OPENAI_API_KEY=   # only if your endpoint requires one

See OpenAI-compatible server for endpoint-specific notes (e.g. Ollama, vLLM).

# pgvector connection - matches the Docker container started above
ONETICK_DB_SQL_CONNECTION_STRING=postgresql+psycopg://onetick-user:onetick-password@localhost:5432/onetick-db

# Path to the reference data CSV files
ONETICK_DB_CSV_DATA_PATH=./document_sources/onetick-cloud-coverage

# OneTick Cloud credentials - required for the OneTick data tools
OTP_CLIENT_ID=
OTP_CLIENT_SECRET=

# Local embedding model - no OpenAI key needed
ONETICK_DB_EMBEDDING_TYPE=sentence_transformer
ONETICK_DB_EMBEDDING_MODEL=all-MiniLM-L6-v2

See Local (offline) embeddings for model selection, artifact-registry mirrors, and air-gapped setup.

Note

If you do not have OneTick WebAPI credentials, omit the OTP_* variables and add the following setting to .env. It enables the documentation-search and reference-data tools while leaving out every tool that queries OneTick WebAPI:

ONETICK_DB_TOOLS=search_python-docs,search_python-examples,search_cloud_coverage,search_sql-docs,list_databases,db_tables,db_table_schemas,db_field_descriptions,db_field_enumerations,calendar_holidays,trading_hours

See Enabling and disabling tools for more about selecting individual tools.

See Configuration for the full list of environment variables, including local, offline (air-gapped), and internal OpenAI-compatible embedding endpoints, running without embeddings, logging, and inbound authentication.

Build the search index#

The search tools require a one-time index build. For OpenAI and OpenAI-compatible embeddings, this incurs usage cost - see Embedding costs to estimate it before running. Run these two commands:

# Apply the database schema to the pgvector database
python -m onetick_llmbase.alembic --settings-module onetick_mcp.config upgrade head

# Embed and index all documentation sources
python -m onetick_llmbase.build_index -c onetick_mcp.config --source_path ./document_sources

The index build reads from ./document_sources, embeds each document, and stores the vectors in pgvector. Indexing time depends on the number of documents and the embedding model; with OpenAI embeddings expect a few minutes on a first run, and with local embeddings expect somewhat longer (around 5 minutes), plus a one-time model download. To rebuild the index after updating documentation sources, see Deployment.

Note

Documentation Markdown files are read as UTF-8 on every platform, including Windows. Save any additional documentation as UTF-8; no PYTHONUTF8 setting or python -X utf8 flag is needed for the Markdown loader. See Custom Search Tools.

Run the server#

onetick-mcp

Run this from the directory that contains your .env file. The server loads .env from the current working directory only; if you start it from another directory, your settings are not picked up and the server falls back to defaults.

By default the server binds to 127.0.0.1:8000 (localhost only). To change the port, or to bind 0.0.0.0 for remote access, see Server variables. If exposing the server beyond localhost, see Network exposure first — the server does not terminate TLS or filter inbound hosts itself.

Important

The server must be run with the same ONETICK_DB_EMBEDDING_TYPE / ONETICK_DB_EMBEDDING_MODEL used for the index build above - it embeds every search query with that model at request time, and a mismatch against the vectors already in the index produces meaningless search results. See Embedding costs for cost, including at serve time.

Verify it is running:

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

Type curl.exe in full: in Windows PowerShell, curl is an alias for Invoke-WebRequest, which does not accept -f.

A successful response confirms the server is running. Startup can continue with a reduced tool set when one capability’s prerequisites are unavailable, so inspect the startup logs and complete the tool-list check below to verify that every tool you selected was loaded.

Validate with MCP Inspector#

To confirm the tools load correctly, you can use the official MCP Inspector. To install the inspector you will first need Node.js installed and on your path - then run:

npx @modelcontextprotocol/inspector

This opens the Inspector UI in your browser. Connect to the running server:

  • Transport Type - Streamable HTTP

  • URL - http://localhost:8000/mcp

Click Connect, then open the Tools tab and click List Tools to confirm the tools enabled by your ONETICK_DB_TOOLS environment variable are present. Select a low-risk tool to run — e.g. a documentation search tool with a simple query, or a reference-data tool like list_databases — and click Run Tool to confirm it returns results.

Next step: connect a real client - see MCP Client setup.