npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

n8n-nodes-postgres-vector-store-tool

v0.7.1

Published

AI agent Postgres vector store tool with vector search and custom SQL capabilities

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 10

Regular 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-tool

Manual Installation

  1. Clone or download this repository
  2. Build:
    npm install
    npm run build
  3. 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

  1. Add the node to your AI Agent workflow
  2. Connect an embedding node to the input
  3. Configure Postgres credentials
  4. Choose your mode:
    • Regular Retrieval: Set table name, adjust options
    • Custom SQL: Write your query with $1 for 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:

  1. Create a workflow with Chat Trigger → AI Agent
  2. Connect this node to the Agent's tools
  3. Connect an embedding node
  4. 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