⚒️ Conversational PostgreSQL agent with visuals, multi-KPI, and data editing (MCP)

2,214 views · ⚒️ Engineering

Description

ChatGPT Image 6 mai 2025, 17_58_38.png

Ask your PostgreSQL database complex questions and receive clear summaries, charts, and even update or insert data — all through one smart agent powered by n8n’s Model Context Protocol (MCP).

Supports:


🚀 Why This Version Stands Out

This version goes beyond reporting:

💰 Estimated cost per run: ~$0.02


💬 Example Output

withvisual_sql.png

🧰 Key Components


🤖 Model Configuration Notes

This workflow uses two models:

  1. Claude 3.5 Haiku (Anthropic)
    Used as the MCP agent for reasoning, planning, and tool calling. Claude is the native model for MCP and delivers reliable results in fewer steps.

  2. DeepSeek
    Used in:

🧠 All models are modular — you can plug in OpenAI, Gemini, or Mistral if desired.


🔐 Security by Design


🧪 Try This Prompt

> “Show me top 5 products by revenue, revenue per month chart, and best customers.”

Expected output:


🛠 How to Use

  1. Import:

    • Build_your_own_PostgreSQL_MCP_server__visuals_capable_.json
    • checkdatabase.json
    • Plot_tool.json
  2. Create your PostgreSQL credential under “Credentials” in n8n:

    • Must match the name used in the workflow (e.g., Postgres account 3)
  3. Assign AI models:

    • Claude 3.5 Haiku → MCP agent (Claude 3.5 MCP Agent)
    • DeepSeek → LLM nodes inside checkdatabase and Plot Tool
  4. Trigger the workflow using the URL from the MCP Server Trigger node
    (e.g., in a chatbot, HTTP request, or Webhook UI)


📦 End-User Setup Guide

If you’re using this template for the first time, follow these exact steps:

  1. Go to your n8n dashboard and import all three workflows (main + subflows)
  2. Create a PostgreSQL credential using your host, database, user, and password
  3. Go to the Claude and DeepSeek nodes, and connect them to your account(s)
  4. Use the Webhook URL in the MCP Server Trigger to connect your chatbot or frontend
  5. Send a prompt like:
    “Show me revenue per month, top 5 products, and a chart of best customers.”

Optional:

✅ Once this is done, your AI assistant will:


🔗 More Templates by the Same Creator

  1. PostgreSQL Conversational Agent with Claude & DeepSeek (Multi-KPI, Secure)

  2. Conversing with Data: Transforming Text into SQL Queries and Visual Curves

  3. Customer Feedback Analysis with AI, QuickChart & HTML Report Generator

🔗 Nodes Used

Postgres, Execute Workflow Trigger, AI Agent, Anthropic Chat Model, Simple Memory, Call n8n Workflow Tool

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup