Skip to content

Configuration

All configuration is done through environment variables. Variables are validated at startup; the server fails fast with a clear message if a required variable is missing.

Environment variables

VariableDefaultDescription
MCP_API_KEY(required in HTTP)Bearer token for REST + MCP over HTTP. Ignored in stdio mode.
EMBEDDINGS_BASE_URLhttp://localhost:11434/v1OpenAI-compatible /v1/embeddings endpoint.
EMBEDDINGS_API_KEY(none)Bearer token for the embeddings API.
EMBEDDINGS_MODELbge-m3Embedding model name.
EMBEDDINGS_DIMENSION1024Fixed vector dimension for the embedding column (bge-m3 = 1024). Used by the PostgreSQL backend to size the pgvector column.
KB_ROOT./kbs (stdio) / /data/kbs (http)Root directory for knowledge base folders.
SCAN_INTERVAL300Scan interval in seconds (0 = disabled). HTTP mode only.
PORT8000HTTP listen port. HTTP mode only.
DB_PATH./rag.db (stdio) / /data/index/rag.db (http)SQLite database path.
STORE_BACKENDsqlitesqlite (default, standalone) or postgres (requires a reachable Postgres).
DATABASE_URL(none)Postgres connection string. Takes precedence over the individual PG_* vars.
PG_HOSTlocalhostPostgres host.
PG_PORT5432Postgres port.
PG_DATABASEraghubPostgres database name.
PG_USER(none)Postgres user.
PG_PASSWORD(none)Postgres password.
PG_SSLfalseEnable TLS for the Postgres connection.
CORS_ORIGINS(none)Allowed CORS origins (comma-separated). Empty = disables the CORS restriction.
RAG_TRANSPORTstdiostdio or http. The --http flag wins.
VERSION1.0.0Reported version.
ModelNotes
bge-m3Multilingual (FR/EN), 1024d, best open-source retrieval, CPU-friendly. Recommended.
nomic-embed-textLighter, English-focused.
text-embedding-3-smallOpenAI API.

Any OpenAI-compatible /v1/embeddings endpoint works — Ollama, Bifrost, OpenAI, LM Studio…

Storage backends

Two backends implement the same Store interface. SQLite is the default and runs standalone; PostgreSQL is opt-in.

SQLite (default)

A single file (DB_PATH) with FTS5 full-text search. No database server required — nothing else to start.

PostgreSQL (pgvector)

Opt-in for deployments that prefer a server-side store. Embeds the pgvector extension (vector column + ts_rank full-text search). Point the server at a reachable Postgres with the vector extension:

bash
STORE_BACKEND=postgres \
DATABASE_URL=postgres://raghub:raghub@localhost:5432/raghub \
node dist/index.js

The schema and the vector extension are created idempotently on first connect. Set EMBEDDINGS_DIMENSION to match your model before ingesting — the column is sized once at migration time.

Tests : the PostgreSQL backend is exercised without any server via PGlite, a real Postgres engine compiled to WASM with the pgvector extension bundled, instantiated in-memory for the duration of the suite (see src/e2e/pgstore.e2e.test.ts).

Transport modes

  • stdio (default): serve MCP tools on stdin/stdout for a local agent. No scan loop, no REST.
  • http (--http / RAG_TRANSPORT=http): REST API + streamable-http MCP on PORT.

In stdio mode, logs go to stderr (stdout is reserved for JSON-RPC); there is no periodic scan.

Released under the MIT License.