Querying Supabase With Natural Language in n8n

Resumen

Querying a database using natural language sounds like magic, but it becomes real when you connect Supabase to an MCP Server inside n8n. Here you'll learn how to design that solution step by step, who benefits from it, and why it matters for anyone building AI agents that talk to structured data.

What is an MCP Server and why connect it to Supabase?

An MCP Server (Model Context Protocol) is the bridge that lets an AI agent reach into external tools, like a database, and pull answers in plain language. When you pair it with Supabase, you get a Postgres database in the cloud that your agent can read on demand.

The goal of this build is simple: query a fictional company called Platzi Utopya and ask things like who works in marketing or how many employees are remote, all in natural language.

What is Supabase? It's an open source platform that gives you a hosted Postgres database, authentication, and APIs ready to use. Perfect for prototyping AI agents fast.

How do you create and populate the tables in Supabase?

The setup happens in three moves: create the tables, populate the support tables, and finally load the employees table. Each one runs from the SQL Editor in Supabase [01:00].

Creating the schema

You copy the table definitions and paste them into the SQL Editor, then hit the green Run button. Supabase replies with Success, no rows returned, which means the structure is ready. Open the Table Editor and you'll see the new tables: departments, employee performance, salary level, and more.

Loading the support tables first

Before touching employees, you fill in the smaller tables that act as references:

  • Countries where employees come from.
  • Areas or departments inside the company.
  • Performance ratings: needs improvement, good, very good, excellent.
  • Salary levels tied to each position.
  • Work type: hybrid, on site, or remote.

You paste the insert query, run it, and validate that each table now shows its values [02:30].

Loading the employees table

This is the heaviest query because it inserts more than 210 people. It's dummy data, not real, but enough to simulate a company. After running it and refreshing the Table Editor, you'll see 212 records, meaning Platzi Utopya now has 212 collaborators ready to be queried [03:45].

How do you connect Supabase to n8n through the MCP Server?

With the database populated, the next move is wiring it into n8n. In Supabase, click Connect and choose Transaction Pooler. There you'll find the parameters you need: host, database, user, password, and port.

Why use the Transaction Pooler instead of the direct connection? The pooler handles many short lived connections efficiently, which is exactly what an AI agent needs when it fires multiple queries in a row.

Setting up the workflow in n8n

Go to n8n, click Create Workflow, and search for MCP Server Trigger. Then add a tool by searching Postgres Tool. Click Create New Credential and fill in the values from Supabase:

  • Host: copied from Supabase.
  • Database: postgres.
  • User: copied from Supabase.
  • Password: the one generated when you created the project.
  • Max connections: set to 220 because there are over 210 employees.
  • Port: change from 5432 to 6543, which is the pooler port.

Save the credential and you're connected [05:30].

Configuring the Postgres Tool

Leave Tool Description as Set Automatically. In Operation pick Select, since you're reading from the database. Keep Schema as public, the default in Supabase. In Table, choose employees and set the limit to 220 to cover every record.

How do you secure and activate the MCP Server Trigger?

Double click the MCP Server Trigger to open its settings. This is where authentication lives, and it matters more than people think.

For production projects, the recommendation is to enable at least Bearer Auth, which validates that only authorized clients reach your server. For this demo it stays as None, but in a real deployment you'd lock it down.

In the Path field, type mcp. n8n gives you two URLs: a test one and a production one. Always copy the production URL when you want a real client to connect.

One detail people miss: the workflow has to stay active all the time. If it's inactive, you'd need to click Test Workflow manually, which breaks the connection for any external client. Toggle it on and your MCP Server is live [07:15].

What's the difference between the test URL and the production URL in n8n? The test URL only works while you're clicking Test Workflow. The production URL stays available as long as the workflow is active, which is what you need for real clients.

With the server running, the next piece is the MCP Client, the part that actually sends the natural language questions. That's the bridge you'll build next.

Did you run into issues with the pooler port or the credentials? Share what worked for you in the comments.