Enable the pgvector extension in the Supabase SQL editor: `CREATE EXTENSION IF NOT EXISTS vector;`.
Add a vector column to your table: `ALTER TABLE documents ADD COLUMN embedding vector(1536);` (dimension must match your embedding model output).
Insert rows with embeddings generated by your embedding API: `UPDATE documents SET embedding = '[0.1, 0.2, ...]'::vector WHERE id = 1;`.
Create an HNSW index for approximate nearest-neighbor search: `CREATE INDEX ON documents USING hnsw (embedding vector_cosine_ops);`.
Query for the top-k nearest neighbors: `SELECT id, content, embedding <=> '[...]'::vector AS distance FROM documents ORDER BY distance LIMIT 10;`
Known gotchas
HNSW index builds can be memory-intensive on large tables; set `maintenance_work_mem` appropriately before indexing.
The `<=>` operator computes cosine distance; use `<->` for Euclidean (L2) distance — choose the operator that matches how your embeddings were trained.
Supabase's connection pooler (pgBouncer in transaction mode) does not support all Postgres features; use the direct connection string for DDL and index creation.
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp