Skip to main content

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

Workflow preview

Workflow preview
100%
Conversational PostgreSQL agent with visuals, multi-KPI, and data editing (MCP) preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

Ask your PostgreSQL database complex questions and receive clear summaries, charts, and even update or insert data — all through one smart age...

Best for

  • Engineering automation workflows
  • AI RAG automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.postgrestool, n8n-nodes-base.executeworkflowtrigger, @n8n/n8n-nodes-langchain.toolworkflow, n8n-nodes-base.postgres, n8n-nodes-base.switch, n8n-nodes-base.stickynote, @n8n/n8n-nodes-langchain.mcptrigger, @n8n/n8n-nodes-langchain.agent

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by hippolyte-hu.

Original n8n.io source

1.1 Workflow description

Title
Conversational PostgreSQL agent with visuals, multi-KPI, and data editing (MCP)
Workflow name
Conversational PostgreSQL agent with visuals, multi-KPI, and data editing (MCP)

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:

  • Multi-KPI insights in one prompt
  • Auto-generated QuickChart bar/pie charts
  • Natural-language inserts and updates
  • Markdown-friendly output for dashboards

🚀 Why This Version Stands Out

This version goes beyond reporting:

  • 📈 Auto-generates charts (QuickChart)
  • 🧮 Answers multiple KPIs in one message
  • ✍️ Add and update records securely
  • 🧠 Uses up to 30 planned steps for smart reasoning

💰 Estimated cost per run: ~$0.02


💬 Example Output

🧰 Key Components

  • MCP Server Trigger → Receives natural queries
  • Claude 3.5 Haiku → Plans, reasons, splits tasks
  • DeepSeek → SQL and QuickChart generation
  • checkdatabase subflow → Validates SQL
  • Plot Tool → Converts data to QuickChart URLs
  • Insert/Update nodes → Edits PostgreSQL records
  • Markdown Formatter → Combines output into readable message

🤖 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:

  • checkdatabase for SQL generation
  • Plot Tool for QuickChart JSON generation

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


🔐 Security by Design

  • No raw SQL from user input
  • Fully parameterized queries
  • Structured tool calling with validation
  • Safe output format (text + chart links)

🧪 Try This Prompt

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

Expected output:

  • 3 KPIs
  • Multiple SQL queries
  • 2–3 QuickChart links
  • Markdown summary for dashboard/Slack

🛠 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:

  • You can increase the MCP Agent’s MaxIterations to go deeper (default is 30)
  • You can use Switch nodes to limit access to certain tables or actions
  • Insert/Update nodes are already included and can be safely enabled

✅ Once this is done, your AI assistant will:

  • Read from your database
  • Visualize data via QuickChart
  • Insert or update rows
  • Respond in clear, markdown-formatted summaries

🔗 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

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - GetTableSchema

Type / Role
n8n-nodes-base.postgresTool - postgresTool
Config choices
Version 2.6

Block 2 - ListTables

Type / Role
n8n-nodes-base.postgresTool - postgresTool
Config choices
Version 2.6

Block 3 - When Executed by Another Workflow

Type / Role
n8n-nodes-base.executeWorkflowTrigger - executeWorkflowTrigger
Config choices
Version 1.1

Block 4 - CreateTableRecords

Type / Role
@n8n/n8n-nodes-langchain.toolWorkflow - toolWorkflow
Config choices
Version 2.1

Block 5 - ReadTableRecord

Type / Role
n8n-nodes-base.postgres - postgres
Config choices
Version 2.6

Block 6 - Operation

Type / Role
n8n-nodes-base.switch - switch
Config choices
Version 3.2

Block 7 - UpdateTableRecord

Type / Role
n8n-nodes-base.postgres - postgres
Config choices
Version 2.6

Block 8 - UpdateTableRecords

Type / Role
@n8n/n8n-nodes-langchain.toolWorkflow - toolWorkflow
Config choices
Version 2.1

Block 9 - CreateTableRecord

Type / Role
n8n-nodes-base.postgres - postgres
Config choices
Version 2.6

Block 10 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 11 - PostgreSQL MCP Server

Type / Role
@n8n/n8n-nodes-langchain.mcpTrigger - mcpTrigger
Config choices
Version 1

Block 12 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 13 - AI Agent

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 1.8

Block 14 - MCP Client

Type / Role
@n8n/n8n-nodes-langchain.mcpClientTool - mcpClientTool
Config choices
Version 1

Block 15 - Anthropic Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatAnthropic - lmChatAnthropic
Config choices
Version 1.3

Block 16 - Think

Type / Role
@n8n/n8n-nodes-langchain.toolThink - toolThink
Config choices
Version 1

Block 17 - get table details

Type / Role
@n8n/n8n-nodes-langchain.toolWorkflow - toolWorkflow
Config choices
Version 2.1

Block 18 - ReadTableRows

Type / Role
@n8n/n8n-nodes-langchain.toolWorkflow - toolWorkflow
Config choices
Version 2.1

Block 19 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 20 - Plot tool

Type / Role
@n8n/n8n-nodes-langchain.toolWorkflow - toolWorkflow
Config choices
Version 2.1

Block 21 - Simple Memory

Type / Role
@n8n/n8n-nodes-langchain.memoryBufferWindow - memoryBufferWindow
Config choices
Version 1.3

Block 22 - When chat message received

Type / Role
@n8n/n8n-nodes-langchain.chatTrigger - chatTrigger
Config choices
Version 1.1

3. Summary Table

Workflow Conversational PostgreSQL agent with visuals, multi-KPI, and data editing (MCP)
Complexity advanced
Nodes 22
Categories Engineering, AI RAG
Author hippolyte-hu
Published 06 May 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/3903/3903.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Conversational PostgreSQL agent with visuals, multi-KPI, and data editing (MCP) do?

Ask your PostgreSQL database complex questions and receive clear summaries, charts, and even update or insert data — all through one smart age...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Engineering, AI RAG use case.