Kredal Docs
How to

Deploy the Docs RAG

Apply the pgvector schema, deploy the embed-docs function, and embed the docs for semantic search.

The docs MCP server works offline with local full-text search. To also enable semantic (hybrid) search, deploy the pgvector backend once, then embed the docs whenever they change.

One-time setup

  1. Apply the migration (adds docs_chunks and hybrid_search_docs):

    cd kredal-app
    supabase db push
  2. Deploy the Edge Function (uses Supabase's built-in gte-small model — no external key):

    supabase functions deploy embed-docs --no-verify-jwt
  3. Set the ingest secret (protects the write path; keep the value safe):

    supabase secrets set INGEST_SECRET="$(openssl rand -hex 24)"

Embed the docs

From the repo root, build the local index and push embeddings to Supabase:

INGEST_SECRET=<the-secret> npm run docs:index -- --remote

Ingest is idempotent — it embeds only new/changed chunks (matched by content hash), so re-running after a docs edit is cheap. It batches and retries automatically (the gte-small model can transiently exhaust a cold worker's memory).

How it is used

  • The docs MCP server's docs_search_semantic calls the function's query mode and falls back to local keyword search if the backend is offline.
  • hybrid_search_docs() fuses full-text and vector ranks with Reciprocal Rank Fusion.

See the architecture reference and database schema for how this fits together.

On this page