n8n-nodes-postgres-vector-store-tool
v0.7.1
Published
AI agent Postgres vector store tool with vector search and custom SQL capabilities
Maintainers
Readme
Postgres Vector Store Tool (n8n)
AI agent tool for Postgres/pgvector with flexible vector search capabilities. Unlike the built-in Vector Store Tool, this node gives you full control over your queries through Custom SQL mode.
Why This Tool?
The built-in n8n Vector Store Tool is limited to basic similarity search. This tool solves that by offering Custom SQL mode - write any query you need while still getting vector embeddings from connected embedding nodes.
Helps With
- Standard vector similarity search - quick setup with configurable table/columns
- Complex search queries - JOINs, filters, aggregations with vector operations
- Access control patterns - implement row-level security, user-scoped searches
- Multi-table retrieval - search across related tables in one query
- Custom ranking - combine vector similarity with other scoring factors
- Hybrid search - mix full-text search with vector similarity
Features
Custom SQL Mode (Recommended)
Write any SQL query with $1 placeholder for the embedding vector:
SELECT content, metadata, 1 - (embedding <=> $1) AS similarity
FROM documents
WHERE user_id = 'user123'
ORDER BY embedding <=> $1
LIMIT 10Regular Retrieval Mode
Quick setup for standard similarity search:
- Configurable table and column names
- Adjustable result limit (Top K)
- Optional metadata inclusion
Debug Mode
Enable in Options to get detailed logging for troubleshooting:
- SQL queries being executed
- Embedding vector dimensions
- Query execution timing
- Connection details
- Error stack traces
All debug output goes to n8n logs - essential for tracing issues in production.
Installation
Via npm
npm install n8n-nodes-postgres-vector-store-toolManual Installation
- Clone or download this repository
- Build:
npm install npm run build - Link to n8n:
npm link cd ~/.n8n/custom npm link n8n-nodes-postgres-vector-store-tool
Usage
Prerequisites
- PostgreSQL with pgvector extension
- Standard Postgres credentials in n8n
- Embedding node connected (OpenAI, Cohere, etc.)
Quick Start
- Add the node to your AI Agent workflow
- Connect an embedding node to the input
- Configure Postgres credentials
- Choose your mode:
- Regular Retrieval: Set table name, adjust options
- Custom SQL: Write your query with
$1for embeddings
Column Configuration (Regular Mode)
Default column names (customizable in Options):
- Vector:
embedding - Content:
text - Metadata:
metadata
Output Format
Results return in text field for direct AI agent consumption:
[
{"text": "Document content here", "metadata": {...}},
{"text": "Another document", "metadata": {...}}
]Testing
This node works as an AI Agent tool. To test:
- Create a workflow with Chat Trigger → AI Agent
- Connect this node to the Agent's tools
- Connect an embedding node
- Chat with the agent and ask questions that trigger vector search
Note: "Execute Step" button doesn't work for AI Tool nodes in n8n - this is a platform limitation, not a bug.
License
MIT
