You Don't Need Embeddings for RAG

This title could be clearer and more informative.Try out Clickbait Shieldfor free (5 uses left this month).

Traditional RAG pipelines rely on chunking, embeddings, and vector stores. An alternative approach gives Claude direct access to a PostgreSQL database via the Model Context Protocol (MCP), letting the LLM write its own SQL queries instead of relying on similarity search. Using the Claude Agent SDK for TypeScript and the DBHub MCP server, you can build a RAG pipeline where Claude discovers the schema, executes SELECT queries, and synthesizes answers — including joins across multiple tables — without any hand-written retrieval logic. The post covers setup with Docker Compose, installing dependencies, building the query function, guarding tool calls with a canUseTool callback, and trade-offs: this agentic approach is more flexible for complex relational queries but slower and costlier than vector search, which remains better for unstructured text and low-latency needs.

4m read timeFrom typescript.tv
Post cover image
Table of contents
ContentsWhat Changes Without EmbeddingsSetting Up PostgreSQL with Docker ComposeInstalling DependenciesBuilding the Query FunctionRunning a QueryGuarding Tool CallsTrade-offs

Sort: